Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Control-flow guard checked calls should preference call target to validator-preserved register #65077

Open
jakobbotsch opened this issue Feb 9, 2022 · 2 comments
Labels
arch-arm64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI optimization
Milestone

Comments

@jakobbotsch
Copy link
Member

jakobbotsch commented Feb 9, 2022

Description

We currently see an unnecessary reg-reg mov for the call target when CFG enabled code is generated. Usually only happens on arm64 because on x64 the register that the validator takes the target in is rcx and so conflicts with the first argument anyway.

Reproduction Steps

$env:COMPlus_TieredCompilation=0
$env:COMPlus_JitForceControlFlowGuard=1
[MethodImpl(MethodImplOptions.NoInlining)]
public static void M(I i)
{
    i.Foo();
}

We produce the following code:

G_M6547_IG02:              ;; offset=0008H
        D280010F          movz    x15, #8
        F2B9218F          movk    x15, #0xc90c LSL #16
        F2CFFFCF          movk    x15, #0x7ffe LSL #32
        F94001EF          ldr     x15, [x15]
        94000000          bl      CORINFO_HELP_VALIDATE_INDIRECT_CALL
        AA0F03E1          mov     x1, x15
        D280010B          movz    x11, #8
        F2B9218B          movk    x11, #0xc90c LSL #16
        F2CFFFCB          movk    x11, #0x7ffe LSL #32
        D63F0020          blr     x1

Expected behavior

G_M6547_IG02:              ;; offset=0008H
         D280010F          movz    x15, #8
         F2B9218F          movk    x15, #0xc90c LSL #16
         F2CFFFCF          movk    x15, #0x7ffe LSL #32
         F94001EF          ldr     x15, [x15]
         94000000          bl      CORINFO_HELP_VALIDATE_INDIRECT_CALL
-        AA0F03E1          mov     x1, x15
         D280010B          movz    x11, #8
         F2B9218B          movk    x11, #0xc90c LSL #16
         F2CFFFCB          movk    x11, #0x7ffe LSL #32
-        D63F0020          blr     x1
+        D63F0020          blr     x15

Actual behavior

No unnecessary reg-reg mov.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

category:cq
theme:register-allocator

@dotnet-issue-labeler dotnet-issue-labeler bot added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner labels Feb 9, 2022
@jakobbotsch
Copy link
Member Author

@kunalspathak This is the issue I spoke to you about last week.

@ghost
Copy link

ghost commented Feb 9, 2022

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

We currently see an unnecessary reg-reg mov for the call target when CFG enabled code is generated. Usually only happens on arm64 because on x64 the register that the validator takes the target in is rcx and so conflicts with the first argument anyway.

Reproduction Steps

$env:COMPlus_TieredCompilation=0
$env:COMPlus_JitForceControlFlowGuard=1
[MethodImpl(MethodImplOptions.NoInlining)]
public static void M(I i)
{
    i.Foo();
}

We produce the following code:

G_M6547_IG02:              ;; offset=0008H
        D280010F          movz    x15, #8
        F2B9218F          movk    x15, #0xc90c LSL #16
        F2CFFFCF          movk    x15, #0x7ffe LSL #32
        F94001EF          ldr     x15, [x15]
        94000000          bl      CORINFO_HELP_VALIDATE_INDIRECT_CALL
        AA0F03E1          mov     x1, x15
        D280010B          movz    x11, #8
        F2B9218B          movk    x11, #0xc90c LSL #16
        F2CFFFCB          movk    x11, #0x7ffe LSL #32
        D63F0020          blr     x1

Expected behavior

G_M6547_IG02:              ;; offset=0008H
        D280010F          movz    x15, #8
        F2B9218F          movk    x15, #0xc90c LSL #16
        F2CFFFCF          movk    x15, #0x7ffe LSL #32
        F94001EF          ldr     x15, [x15]
        94000000          bl      CORINFO_HELP_VALIDATE_INDIRECT_CALL
        D280010B          movz    x11, #8
        F2B9218B          movk    x11, #0xc90c LSL #16
        F2CFFFCB          movk    x11, #0x7ffe LSL #32
        D63F0020          blr     x15

Actual behavior

No unnecessary reg-reg mov.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: jakobbotsch
Assignees: -
Labels:

arch-arm64, area-CodeGen-coreclr, untriaged

Milestone: -

@JulieLeeMSFT JulieLeeMSFT added this to Needs Triage in .NET Core CodeGen via automation Feb 11, 2022
@JulieLeeMSFT JulieLeeMSFT added this to the Future milestone Feb 24, 2022
@JulieLeeMSFT JulieLeeMSFT removed the untriaged New issue has not been triaged by the area owner label Feb 24, 2022
@JulieLeeMSFT JulieLeeMSFT removed this from Needs Triage in .NET Core CodeGen Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-arm64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI optimization
Projects
None yet
Development

No branches or pull requests

2 participants