ARM64: Display method names for indirect calls in JitDisasm output#126000
ARM64: Display method names for indirect calls in JitDisasm output#126000
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
…ail) In the IF_BR_1B case of emitDispInsHelp, after displaying the register, check if idMemCookie is set and display the method name as a comment. This matches x64 behavior where indirect calls show the target method name. Also add a small FileCheck test for ARM64 specifically. Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/b2a47cb3-cb3d-4479-a881-733d20b8576b
Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/b2a47cb3-cb3d-4479-a881-733d20b8576b
There was a problem hiding this comment.
Pull request overview
This PR updates ARM64 JitDisasm output so indirect calls (blr / br_tail) include a method-name annotation comment, matching the existing behavior on other architectures. It also adds an ARM64 FileCheck-based JIT test to prevent regressions.
Changes:
- ARM64: For
IF_BR_1Binstruction display, print the method name fromidMemCookieas a//comment for indirect calls. - Tests: Add a new ARM64 disasm FileCheck test validating
blrlines include the target method name annotation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/jit/emitarm64.cpp | Adds method-name comment emission for IF_BR_1B (indirect branch/call register format) when idMemCookie is present. |
| src/tests/JIT/opt/Calls/IndirectCallAnnotation.csproj | New JIT disasm/FileCheck-enabled test project configuration. |
| src/tests/JIT/opt/Calls/IndirectCallAnnotation.cs | New test that forces a virtual call and checks ARM64 disasm contains the callee method name on the blr instruction line. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/coreclr/jit/emitarm64.cpp
Outdated
| if (id->idDebugOnlyInfo()->idMemCookie != 0) | ||
| { | ||
| methodName = m_compiler->eeGetMethodFullName((CORINFO_METHOD_HANDLE)id->idDebugOnlyInfo()->idMemCookie); | ||
| printf(" // %s", methodName); | ||
| } |
There was a problem hiding this comment.
Shouldn't we use emitDispCommentForHandle?
Normal checked disassembly displays this not on the blr, but on the constant:
G_M27646_IG02: ;; offset=0x001C
add x0, fp, #24 // [V00 loc0]
movz x1, #0xD8D8 // code for Program:MutateImplicitByRef(ImpByRef):System.Threading.Tasks.Task`1[long]
movk x1, #0xCA44 LSL #16
movk x1, #0x7FFA LSL #32
ldr x1, [x1]
blr x1
I think this should do the same. (Honestly I think this regressed at some point, I am quite sure this used to work in release.)
There was a problem hiding this comment.
tbh, my impression it never worked. only in crossgen2 for arm64
There was a problem hiding this comment.
Switched to emitDispCommentForHandle(0, id->idDebugOnlyInfo()->idMemCookie, GTF_ICON_FTN_ADDR) in 43bdb17. This produces // code for MethodName matching the format used by the movz/movk constant annotations in checked builds.
| public class IndirectCallAnnotation | ||
| { | ||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| public virtual int VirtualCallee() => 42; | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static int Caller(IndirectCallAnnotation obj) | ||
| { | ||
| // Verify that the indirect call target is annotated with the method name. | ||
| // ARM64: blr {{.*}}VirtualCallee() | ||
| return obj.VirtualCallee(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public static int TestEntryPoint() | ||
| { | ||
| return Caller(new IndirectCallAnnotation()) == 42 ? 100 : 0; | ||
| } | ||
| } |
There was a problem hiding this comment.
This test probably isn't that interesting, won't it run in checked? This was only broken in release
There was a problem hiding this comment.
ah, we don't run these in Release? we probably should, but then I agree it's useless
There was a problem hiding this comment.
To be honest I am not sure, we might?
|
@copilot address the feedback. |
Use emitDispCommentForHandle instead of directly calling eeGetMethodFullName and printf, matching the pattern used by movz/movk constant annotations. Remove the FileCheck test since it would only run in checked mode where the method name already appears on the movz/movk constant instructions. Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/84a22a2e-9c3e-40ef-ab3b-97113c002f92
Description
ARM64
JitDisasmoutput for indirect calls (blr/br_tail) was missing method name annotations. On x64, indirect calls render ascall [addr] ; MethodName, but on ARM64 the equivalentblr x2had no function name comment.The method handle is already stored in
idMemCookiefor all call types. TheIF_BR_1Bdisplay case inemitDispInsHelpsimply never read it.Before:
blr x2After:
Changes
src/coreclr/jit/emitarm64.cpp: In theIF_BR_1Bcase ofemitDispInsHelp, callemitDispCommentForHandlewithGTF_ICON_FTN_ADDRto display the method name — matching the format used bymovz/movkconstant annotations in checked builds and the convention used by other architectures.Original prompt
JitDisasmdoes not include function names for calls on arm64 #125951💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.