Skip to content

[Arm64] Extend Compiler::lvaFrameAddress() and JIT to allow using SP as base register #47810

Open

Description

@echesakov

At the moment, on Arm64 we always establish frame pointer when allocating a stack frame. Given that fact and based on the logic in Compiler::lvaFrameAddress() the JIT would always use fp as a base register for addressing locals and temps. This can lead to un-optimal codegen in a situation when the JIT is required to use frameType=5 (i.e., when fp points to a location above locals) instead of frameType=3 (i.e., when fp points to a location below locals). The following is a snippet of such un-optimal codegen when such restriction on fp value is imposed:

-;  V285 tmp284      [V285    ] (  2,  4   )  struct ( 8) [fp+0x1C50]   do-not-enreg[XSB] addr-exposed "Inlining Arg"
+;  V285 tmp284      [V285    ] (  2,  4   )  struct ( 8) [fp-0x7E8]   do-not-enreg[XSB] addr-exposed "Inlining Arg"

-;  TEMP_01                                   byref  ->  [fp+0x10]
+;  TEMP_01                                   byref  ->  [fp-0x2428]

- ldrh    w11, [fp,#0xd1ffab1e]      // [V285 tmp284]
+ movn    xip1, #0xd1ffab1e
+ ldrh    w11, [fp, xip1]    // [V285 tmp284]

- str     x14, [fp,#16]      // [TEMP_01]
+ movn    xip1, #0xd1ffab1e
+ str     x14, [fp, xip1]    // [TEMP_01]

I noticed this while implementing stack probe helper support on Arm64 in #43250 when the JIT is required to store fp,lr register pair earlier during prolog execution to be able to call a helper.

@dotnet/jit-contrib

category:cq
theme:register-allocator

Activity

  1. added
    area-CodeGen-coreclr
    on Feb 3, 2021
  2. added this to the 6.0.0 milestone on Feb 3, 2021
  3. ghost added
    untriaged
    on Feb 3, 2021
  4. removed
    untriaged
    on Feb 3, 2021
  5. added
    needs-further-triage
    and removed
    needs-further-triage
    on Mar 23, 2021
  6. modified the milestones: 6.0.0, Future on Mar 29, 2021
  7. added
    Priority:2
    on Mar 29, 2021
  8. echesakov commented on Mar 15, 2022

    @echesakov
    ContributorAuthor

    Un-assigning myself
    cc @BruceForstall

  9. removed their assignment
    on Mar 15, 2022
  10. moved this to Optimizations in .NET Core CodeGenon Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:2arch-arm64area-CodeGen-coreclroptimization

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions