Stream: git-cranelift

Topic: cranelift / Issue #1201 Improve code generation for Windo...


view this post on Zulip GitHub (Jan 16 2020 at 23:05):

peterhuene edited Issue #1201:

Improve the code generation for Windows x64 ABI (fastcall) to reduce function size by omitting frame pointers, using the caller-provided shadow space as spill slots (for optimized compilation), and potentially omit prologues/epilogues entirely (for "leaf" functions).

Reduced code generation size and improved performance on optimized compilations when targeting Windows.

Windows x64 ABI has strict requirements for function prologues and epilogues. This enables the OS to consistently walk and unwind the stack during exception handling.

Because of these strict requirements, a frame pointer is rarely needed for the purpose of unwinding and is only required for a frame doing a dynamic allocation (i.e. alloca). However, keeping the frame pointer may mean smaller instruction sizes based on the displacement from a frame pointer vs. the current stack pointer.

Additionally, an explicit stack frame is not necessary at all for "leaf" functions. We can omit prologue, epilogue, and unwind information generation entirely for functions that don't:

I therefore propose the following changes:

The result should be smaller function code generation on Windows, especially in the case of leaf functions.

I have not considered alternative implementations.

This issue was motivated by #1199.

view this post on Zulip GitHub (Jan 16 2020 at 23:07):

peterhuene edited Issue #1201:

Improve the code generation for Windows x64 ABI (fastcall) to reduce function size by omitting frame pointers, using the caller-provided shadow space as spill slots (for optimized compilation), and potentially omit prologues/epilogues entirely (for "leaf" functions).

Reduced code generation size and improved performance on optimized compilations when targeting Windows.

Windows x64 ABI has strict requirements for function prologues and epilogues. This enables the OS to consistently walk and unwind the stack during exception handling.

Because of these strict requirements, a frame pointer is rarely needed for the purpose of unwinding and is only required for a frame doing a dynamic allocation (i.e. alloca). However, keeping the frame pointer may mean smaller instruction sizes based on the displacement from a frame pointer vs. the current stack pointer.

Additionally, an explicit stack frame is not necessary at all for "leaf" functions. We can omit prologue, epilogue, and unwind information generation entirely for functions that don't:

I therefore propose the following changes:

The result should be smaller function code generation on Windows, especially in the case of leaf functions.

I have not considered alternative implementations.

This issue was motivated by #1199.

view this post on Zulip GitHub (Jan 16 2020 at 23:09):

peterhuene edited Issue #1201:

Improve the code generation for Windows x64 ABI (fastcall) to reduce function size by omitting frame pointers, using the caller-provided shadow space as spill slots (for optimized compilation), and potentially omit prologues/epilogues entirely (for "leaf" functions).

Reduced code generation size and improved performance on optimized compilations when targeting Windows.

Windows x64 ABI has strict requirements for function prologues and epilogues. This enables the OS to consistently walk and unwind the stack during exception handling.

Because of these strict requirements, a frame pointer is rarely needed for the purpose of unwinding and is only required for a frame doing a dynamic allocation (i.e. alloca). However, keeping the frame pointer may mean smaller instruction sizes based on the displacement from a frame pointer vs. the current stack pointer.

Additionally, an explicit stack frame is not necessary at all for "leaf" functions. We can omit prologue, epilogue, and unwind information generation entirely for functions that don't:

I therefore propose the following changes:

The result should be smaller function code generation on Windows, especially in the case of leaf functions.

I have not considered alternative implementations.

This issue was motivated by #1199.

view this post on Zulip GitHub (Jan 16 2020 at 23:13):

peterhuene edited Issue #1201:

Improve the code generation for Windows x64 ABI (a.k.a. "fastcall") by omitting frame pointers when possible, using the caller-provided shadow space as spill slots for optimized compilation, and omit prologues/epilogues entirely for true "leaf" functions.

Reduced code generation size and improved performance on optimized compilations when targeting Windows.

Windows x64 ABI has strict requirements for function prologues and epilogues. This enables the OS to consistently walk and unwind the stack during exception handling.

Because of these strict requirements, a frame pointer is rarely needed for the purpose of unwinding and is only required for a frame doing a dynamic allocation (i.e. alloca). However, omitting the frame pointer might actually increase instruction sizes based on the displacement from a frame pointer vs. the current stack pointer. This should be taken into account when deciding if a frame pointer should be omitted.

Additionally, an explicit stack frame is not necessary at all for "leaf" functions. We can omit prologue, epilogue, and unwind information generation entirely for functions that don't:

I therefore propose the following changes:

The result should be smaller function code generation on Windows, especially in the case of leaf functions.

I have not considered alternative implementations.

This issue was motivated by #1199.

view this post on Zulip GitHub (Feb 28 2020 at 23:27):

alexcrichton transferred Issue #1201:

Improve the code generation for Windows x64 ABI (a.k.a. "fastcall") by omitting frame pointers when possible, using the caller-provided shadow space as spill slots for optimized compilation, and omit prologues/epilogues entirely for true "leaf" functions.

Reduced code generation size and improved performance on optimized compilations when targeting Windows.

Windows x64 ABI has strict requirements for function prologues and epilogues. This enables the OS to consistently walk and unwind the stack during exception handling.

Because of these strict requirements, a frame pointer is rarely needed for the purpose of unwinding and is only required for a frame doing a dynamic allocation (i.e. alloca). However, omitting the frame pointer might actually increase instruction sizes based on the displacement from a frame pointer vs. the current stack pointer. This should be taken into account when deciding if a frame pointer should be omitted.

Additionally, an explicit stack frame is not necessary at all for "leaf" functions. We can omit prologue, epilogue, and unwind information generation entirely for functions that don't:

I therefore propose the following changes:

The result should be smaller function code generation on Windows, especially in the case of leaf functions.

I have not considered alternative implementations.

This issue was motivated by #1199.


Last updated: Dec 23 2024 at 13:07 UTC