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 devirtualization across genericness in the hierarchy #108442

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

MichalStrehovsky
Copy link
Member

This code was trying to answer question: "Was this method overriden by something else in a more derived class"? It was walking the base hierarchy in canonical form, but that was leading to methods not resolving at all. The fix is to walk the non-canonical hierarchy and canonicalize after we resolved everything.

I ran into this in #108379 that unlocked more whole program devirtualization and StringSearchValuesBase is in this shape. It is hittable without that optimization though, like the regression test shows.

Cc @dotnet/ilc-contrib

This code was trying to answer question: "Was this method overriden by something else in a more derived class"? It was walking the base hierarchy in canonical form, but that was leading to methods not resolving at all. The fix is to walk the non-canonical hierarchy and canonicalize after we resolved everything.

I ran into this in dotnet#108379 that unlocked more whole program devirtualization and `StringSearchValuesBase` is in this shape.
Copy link
Contributor

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

@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky MichalStrehovsky merged commit e6d9f74 into dotnet:main Oct 1, 2024
112 of 116 checks passed
@MichalStrehovsky MichalStrehovsky deleted the devirtgeneric branch October 1, 2024 22:11
@MichalStrehovsky
Copy link
Member Author

@dotnet/ilc-contrib anyone have opinion on backport? This is a .NET 9 regression that nobody ran into yet, but it's bad codegen (wrong method getting called).

@jkotas
Copy link
Member

jkotas commented Oct 2, 2024

I think silent bad codegen that is regression from last release meets the servicing bar. The targeted repro looks very simple, likely to be hit by somebody.

@agocke
Copy link
Member

agocke commented Oct 2, 2024

I agree, regression from .NET 8 makes it worth taking. I will bring it to tactics

@agocke
Copy link
Member

agocke commented Oct 2, 2024

/backport to release/9.0-staging

Copy link
Contributor

github-actions bot commented Oct 2, 2024

Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/11136710712

Copy link
Contributor

github-actions bot commented Oct 2, 2024

@agocke an error occurred while backporting to release/9.0-staging, please check the run log for details!

Error: The specified backport target branch release/9.0-staging wasn't found in the repo.

@agocke
Copy link
Member

agocke commented Oct 2, 2024

/backport to release/9.0

Copy link
Contributor

github-actions bot commented Oct 2, 2024

Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/11136775970

Copy link
Contributor

github-actions bot commented Oct 2, 2024

@agocke backporting to release/9.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix devirtualization across genericness in the hierarchy
Using index info to reconstruct a base tree...
M	src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs
CONFLICT (content): Merge conflict in src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Fix devirtualization across genericness in the hierarchy
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Copy link
Contributor

github-actions bot commented Oct 2, 2024

@agocke an error occurred while backporting to release/9.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

MichalStrehovsky added a commit to MichalStrehovsky/runtime that referenced this pull request Oct 2, 2024
This code was trying to answer question: "Was this method overriden by something else in a more derived class"? It was walking the base hierarchy in canonical form, but that was leading to methods not resolving at all. The fix is to walk the non-canonical hierarchy and canonicalize after we resolved everything.

I ran into this in dotnet#108379 that unlocked more whole program devirtualization and `StringSearchValuesBase` is in this shape.
@MichalStrehovsky
Copy link
Member Author

backporting to release/9.0 failed, the patch most likely resulted in conflicts:

Conflicts because of #108116. Not the first time random "fix typos"/"reformat code" caused extra busywork for nothing. Now I get to spend 10 minutes on something that should have been 10 seconds.

sirntar pushed a commit to sirntar/runtime that referenced this pull request Oct 3, 2024
This code was trying to answer question: "Was this method overriden by something else in a more derived class"? It was walking the base hierarchy in canonical form, but that was leading to methods not resolving at all. The fix is to walk the non-canonical hierarchy and canonicalize after we resolved everything.

I ran into this in dotnet#108379 that unlocked more whole program devirtualization and `StringSearchValuesBase` is in this shape.
jeffschwMSFT added a commit that referenced this pull request Oct 3, 2024
…108470)

This code was trying to answer question: "Was this method overriden by something else in a more derived class"? It was walking the base hierarchy in canonical form, but that was leading to methods not resolving at all. The fix is to walk the non-canonical hierarchy and canonicalize after we resolved everything.

I ran into this in #108379 that unlocked more whole program devirtualization and `StringSearchValuesBase` is in this shape.

Co-authored-by: Jeff Schwartz <jeffschw@microsoft.com>
lambdageek pushed a commit to lambdageek/runtime that referenced this pull request Oct 3, 2024
This code was trying to answer question: "Was this method overriden by something else in a more derived class"? It was walking the base hierarchy in canonical form, but that was leading to methods not resolving at all. The fix is to walk the non-canonical hierarchy and canonicalize after we resolved everything.

I ran into this in dotnet#108379 that unlocked more whole program devirtualization and `StringSearchValuesBase` is in this shape.
@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants