-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Static field addresses are not deterministic when doing SPMI replay #53773
Comments
Debugging it some more, it looks like the root cause is this code: runtime/src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.cpp Lines 3592 to 3602 in 41af30c
SPMI tries to record values of static fields (all of them, even though only readonly ones are looked at by the Jit), so the This is necessary, since we must have the Jit look for the value now stored in the SPMI's map ( Looks like solving this might require extending the Jit-EE interface. |
I'll have to think about/debug this further. But typically what we would have to do is improve the recording side, in |
It seems like this is a problem in CSE for using the field address for any purpose that might cause diffs, not SuperPMI. E.g., it seems like multiple non-SuperPMI runs could also see asm diffs if the actual value of the address could affect codegen. So I don't think this is a SuperPMI problem. SuperPMI does generally return the same addresses to the JIT as during record, assuming the JIT won't deref them, but things like the target code buffer address obviously must be able to change. |
I think it is the case even without CSE using the field addresses, e.g. ARM64 can sometimes encode field addresses in fewer instructions depending on the specifics of their alignment/constant values. And of course there's a bunch of other things like static readonly fields that can affect the codegen depending on runtime specifics. I think the problem here is that the contract is poorly specified. JIT assumes it can deref pointers to fields, and to make that work SPMI needs to return something else than what it saw at runtime. But JIT is also using the field address for codegen purposes. I think we need a new JIT-EE method to query the data for a field to make this work reliably (as a bonus, it may potentially help R2R/NAOT too). |
Reproduction steps:
1. Construct a trivial app that accesses a static:
2. Do an SPMI collection for that app.
3. Add some
printf
logging for the static address' value tomorph.cpp
here (or use-jitoption JitDump=*
, but it did not work for me for some reason).4. Replay using
superpmi.exe
, twice, log the output to two files.5.
git diff
them.6. You should see something like the following:
This can cause spurious diffs, because CSE uses these values, as was seen in #53748. The commit I reproduced this on is 44f050a.
cc @BruceForstall
category:eng-sys
theme:super-pmi
skill-level:expert
cost:medium
impact:medium
The text was updated successfully, but these errors were encountered: