Skip to content

SuperPMI: fix spurious arm asmdiffs from out-of-range BL relocs#130913

Open
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:AndyAyersMS/superpmi-arm-branch24-diff
Open

SuperPMI: fix spurious arm asmdiffs from out-of-range BL relocs#130913
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:AndyAyersMS/superpmi-arm-branch24-diff

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

For an arm32 direct BL (ARM32_THUMB_BRANCH24), applyRelocs substitutes a placeholder target when the code block lands more than +-16MB from the call target, so the two sides' immediates differ even though both call the same recorded target.

Compare the recorded reloc kind and target instead.

Also error out when base and diff JITs are the same module (this has burned me a few times).

Fixes #130736

The near-differ applies recorded relocations before comparing. For an
arm32 direct BL (ARM32_THUMB_BRANCH24), applyRelocs substitutes a
placeholder target when the code block lands more than +-16MB from the
call target, so the two sides' immediates differ even though both call
the same recorded target. Compare the recorded reloc kind and target
instead. Also error out when base and diff JITs are the same module.
Copilot AI review requested due to automatic review settings July 16, 2026 19:33
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 16, 2026
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@jakobbotsch PTAL
fyi @dotnet/jit-contrib

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.
Some pipeline(s) encountered errors during trigger evaluation.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates SuperPMI’s asm-diffing and setup validation to reduce false-positive diffs on ARM32 and to prevent running with baseline/diff JITs that resolve to the same loaded module (which can corrupt shared global JIT state).

Changes:

  • Add a startup check that errors out when baseline and diff JITs resolve to the same loaded module.
  • Add JitInstance::getModule() accessor to surface the loaded module handle for that check.
  • Adjust ARM32 offset comparison to treat certain relocation sites as semantically equivalent by consulting recorded relocation metadata rather than patched immediates.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/tools/superpmi/superpmi/superpmi.cpp Adds validation to reject baseline/diff JITs that map to the same loaded module.
src/coreclr/tools/superpmi/superpmi/neardiffer.cpp Adds an ARM32 relocation-aware equivalence check to avoid spurious asm diffs from patched BL immediates.
src/coreclr/tools/superpmi/superpmi/jitinstance.h Exposes the loaded JIT module handle via a new accessor.

Comment on lines +579 to +584
if ((reloc1 != nullptr) && (reloc2 != nullptr) && (reloc1->fRelocType == reloc2->fRelocType) &&
((uint64_t)reloc1->target + (int32_t)reloc1->addlDelta ==
(uint64_t)reloc2->target + (int32_t)reloc2->addlDelta))
{
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

superpmi-asmdiffs-checked-release: ASM diffs found in libraries.crossgen2.linux.arm.checked.mch

2 participants