Skip to content

Win ARM64 prolog prevents use of packed unwind info #169588

@LouisLaf

Description

@LouisLaf

The prolog for Win ARM64 functions allocates stacks for the parameter home area and locals with a single SUB. While this sometimes results in 1 less instruction in the prolog, it does prevent taking advantage of the packed unwind data format.

For example, for this test case:

extern void bar(int*);
int foo(int x)
{
    int z;
    bar(&z);
    return x+z;
}

LLVM emits this prolog:

sub         sp,sp,#0x20
str         x19,[sp,#0x10]
str         lr,[sp,#0x18]

This results in an unpacked unwind info record.

Emitting this prolog instead:

sub         sp,sp,#0x10
stp         x19,lr,[sp]
sub         sp,sp,#0x10

Would allow to take advantage of the packed unwind data format according to https://learn.microsoft.com/en-us/cpp/build/arm64-exception-handling

Using packed records reduce the size of the unwind information in rdata significantly and improves the speed of stack walking.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions