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

Fix DEBUG/non-DEBUG SuperPMI asm diffs #76470

Merged

Conversation

BruceForstall
Copy link
Member

Recorded SPMI method contexts include configuration environment variables such as COMPlus_JITMinOpts that are replayed. However, when doing asmdiffs replays to compare a Release to a Checked compiler (non-DEBUG to DEBUG), there may be codegen-altering configuration variables such as JitStress that are only read and interpreted by the DEBUG compiler. This leads to asm diffs.

Introduce a -ignoreStoredConfig argument to superpmi.exe, and use it in superpmi.py when doing Checked/Release asm diffs, that pretends there are no stored config variables. This assumes that the stored config variables only alter JIT behavior but that they JIT will succeed with or without them. This is also slightly more than necessary: if there is a config variable that the Release compiler knows about, we won't use that, either. However, we have no easy way (currently) to distinguish which variables are DEBUG and which are both DEBUG and non-DEBUG available.

Contributes to #76347

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 30, 2022
@ghost ghost assigned BruceForstall Sep 30, 2022
@ghost
Copy link

ghost commented Sep 30, 2022

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

Issue Details

Recorded SPMI method contexts include configuration environment variables such as COMPlus_JITMinOpts that are replayed. However, when doing asmdiffs replays to compare a Release to a Checked compiler (non-DEBUG to DEBUG), there may be codegen-altering configuration variables such as JitStress that are only read and interpreted by the DEBUG compiler. This leads to asm diffs.

Introduce a -ignoreStoredConfig argument to superpmi.exe, and use it in superpmi.py when doing Checked/Release asm diffs, that pretends there are no stored config variables. This assumes that the stored config variables only alter JIT behavior but that they JIT will succeed with or without them. This is also slightly more than necessary: if there is a config variable that the Release compiler knows about, we won't use that, either. However, we have no easy way (currently) to distinguish which variables are DEBUG and which are both DEBUG and non-DEBUG available.

Contributes to #76347

Author: BruceForstall
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

Recorded SPMI method contexts include configuration environment variables
such as `COMPlus_JITMinOpts` that are replayed. However, when doing
asmdiffs replays to compare a Release to a Checked compiler (non-DEBUG
to DEBUG), there may be codegen-altering configuration variables
such as JitStress that are only read and interpreted by the DEBUG
compiler. This leads to asm diffs.

Introduce a `-ignoreStoredConfig` argument to superpmi.exe, and use it
in superpmi.py when doing Checked/Release asm diffs, that pretends there
are no stored config variables. This assumes that the stored config variables
only alter JIT behavior but that they JIT will succeed with or without them.
This is also slightly more than necessary: if there is a config variable
that the Release compiler knows about, we won't use that, either. However,
we have no easy way (currently) to distinguish which variables are DEBUG
and which are both DEBUG and non-DEBUG available.

Contributes to dotnet#76347
@BruceForstall BruceForstall force-pushed the AddSuperpmiIgnoreStoredConfig branch from 22b38d2 to 99ebea0 Compare September 30, 2022 22:06
@BruceForstall
Copy link
Member Author

@kunalspathak @jakobbotsch @dotnet/jit-contrib PTAL

# If one of the JITs is Release, ignore all the stored configuration variables.
# This isn't necessary if both are Release builds (and, in fact, it can clear variables
# that both Release compilers can interpret). However, we rarely or never compare
# two Release compilers, so this is safest.
Copy link
Member

Choose a reason for hiding this comment

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

I was thinking of moving asmdiffs to run on Release instead of Checked.

Copy link
Member Author

Choose a reason for hiding this comment

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

When doing so, you'll need to audit usage of diff_with_release. It was introduced for use with Checked/Release diffs (so is not completely accurately named) and also before Release builds had any JitDisasm support (JitDiffableDasm still isn't in Release), so I think it kind of mixes concepts a bit.

@@ -6903,6 +6904,9 @@ void MethodContext::dmpGetIntConfigValue(const Agnostic_ConfigIntInfo& key, int

int MethodContext::repGetIntConfigValue(const WCHAR* name, int defaultValue)
{
if (ignoreStoredConfig)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (ignoreStoredConfig)
if (ignoreStoredConfig || (GetIntConfigValue == nullptr))
return defaultValue;

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually prefer keeping these cases as separate statements.

@@ -6955,6 +6959,9 @@ void MethodContext::dmpGetStringConfigValue(DWORD nameIndex, DWORD resultIndex)

const WCHAR* MethodContext::repGetStringConfigValue(const WCHAR* name)
{
if (ignoreStoredConfig)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (ignoreStoredConfig)
if (ignoreStoredConfig || (GetStringConfigValue == nullptr))
return nullptr;

@BruceForstall BruceForstall merged commit aea856f into dotnet:main Oct 1, 2022
@BruceForstall BruceForstall deleted the AddSuperpmiIgnoreStoredConfig branch October 1, 2022 03:26
@ghost ghost locked as resolved and limited conversation to collaborators Oct 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.

3 participants