Skip to content

Commit

Permalink
Fix spurious SuperPMI asm diffs (#86132)
Browse files Browse the repository at this point in the history
Under ELT profiler stress, we encode the un-relocated address
of the `DummyProfilerELTStub` function in the JIT codebase into
the generated code. This can lead to spurious diffs if the address
is different between base and diff JITs (which is likely).

To avoid this, under SuperPMI replay (which we only know in DEBUG
builds currently), use a fixed constant for this address. The code
isn't executed during SuperPMI replay, so it doesn't need to be a
valid code address.
  • Loading branch information
BruceForstall authored May 12, 2023
1 parent 937e25a commit 3bd3832
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,25 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
// TBD: Exclude PInvoke stubs
if (opts.compJitELTHookEnabled)
{
compProfilerMethHnd = (void*)DummyProfilerELTStub;
#if defined(DEBUG) // We currently only know if we're running under SuperPMI in DEBUG
// We don't want to get spurious SuperPMI asm diffs because profile stress kicks in and we use
// the address of `DummyProfilerELTStub` in the JIT binary, without relocation. So just use
// a fixed address in this case. It's SuperPMI replay, so the generated code won't be run.
if (RunningSuperPmiReplay())
{
#ifdef HOST_64BIT
static_assert_no_msg(sizeof(void*) == 8);
compProfilerMethHnd = (void*)0x0BADF00DBEADCAFE;
#else
static_assert_no_msg(sizeof(void*) == 4);
compProfilerMethHnd = (void*)0x0BADF00D;
#endif
}
else
#endif // DEBUG
{
compProfilerMethHnd = (void*)DummyProfilerELTStub;
}
compProfilerMethHndIndirected = false;
}

Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9919,6 +9919,14 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

} info;

#if defined(DEBUG)
// Are we running a replay under SuperPMI?
bool RunningSuperPmiReplay() const
{
return info.compMethodSuperPMIIndex != -1;
}
#endif // DEBUG

ReturnTypeDesc compRetTypeDesc; // ABI return type descriptor for the method

//------------------------------------------------------------------------
Expand Down

0 comments on commit 3bd3832

Please sign in to comment.