Skip to content

ARM32 register conflict for large stack frames and tailcalls #66585

Closed

Description

@jakobbotsch

Description

ARM32 may need a scratch register to free large local stack frames. This can currently conflict with the register used for the target in fast tail calls.

Reproduction Steps

using System.Runtime.InteropServices;

public class Program
{
    public static void Main()
    {
        Caller(0, 1, 2, 3);
    }

    private static SLarge s_s;
    public static void Caller(int r0, int r1, int r2, int r3)
    {
        SLarge s = s_s;
        Consume(s);
        Callee(r0, r1, r2, r3);
    }

    public static void Callee(int r0, int r1, int r2, int r3)
    {
    }

    private static void Consume(SLarge s)
    {
    }

    [StructLayout(LayoutKind.Sequential, Size = 0x1008)]
    private struct SLarge
    {
        public int Value;
    }
}

Expected behavior

No crash.

Actual behavior

Segfault/access violation as we generate the following code:

002F84  F648 5C69      movw    r12, 0x8d69
002F88  F6C0 2C34      movt    r12, 0xa34
                                                ;; bbWeight=1    PerfScore 60.00
G_M42316_IG18:              ;; offset=2F8CH
002F8C  F242 0C04      movw    r12, 0x2004
002F90  44E5           add     sp, r12
002F92  E8BD 4CF0      pop     {r4,r5,r6,r7,r10,r11,lr}
002F96  4760           bx      r12              // Program:Callee(int,int,int,int)
                                                ;; bbWeight=1    PerfScore 4.00

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

  1. ghost added
    area-CodeGen-coreclr
    on Mar 14, 2022
  2. ghost added
    untriaged
    on Mar 14, 2022
  3. self-assigned this
    on Mar 14, 2022
  4. removed
    untriaged
    on Mar 14, 2022
  5. added this to the 7.0.0 milestone on Mar 14, 2022
  6. added a commit that references this issue on Mar 14, 2022
    780a804
  7. ghost added
    in-pr
    on Mar 14, 2022
  8. ghost removed
    in-pr
    on Mar 15, 2022
  9. added a commit that references this issue on Mar 15, 2022
    3eea15a
  10. added a commit that references this issue on Mar 30, 2022
    aa7bd03
  11. ghost locked as resolved and limited conversation to collaborators on Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions