-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 in crossgen2 #146
Conversation
In some casesi that are only expressible in IL, devirtualization is choosing a wrong virtual method. This causes a failure of the JIT\Regression\JitBlue\GitHub_19222 test. The test uses the following class hierarchy: class A { public virtual void f() {} } class B : A { public override void f() {} } class C : B { public new void f() {} } class D : C { public new void f() {} } Then there is a local of type C to which we assign a reference to D. After that the following virtual call is made: callvirt instance int32 modopt([mscorlib]System.Runtime.CompilerServices.IsLong) A::f() Devirtualization will choose C.f to call instead of the D.f. This change disables devirtualization in such cases. Old crossgen does the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for fixing this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix to use the slot defining method check instead of IsNewSlot and such. The technique used is incorrect if the impl method is a non-newslot method that overrides a newslot .override of the original decl method.
src/coreclr/src/tools/crossgen2/Common/Compiler/DevirtualizationManager.cs
Outdated
Show resolved
Hide resolved
@davidwrighton I've fixed it based on your feedback, can you please take a look again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
In some casesi that are only expressible in IL, devirtualization is
choosing a wrong virtual method. This causes a failure of the
JIT\Regression\JitBlue\GitHub_19222 test.
The test uses the following class hierarchy:
Then there is a local of type C to which we assign a reference to D.
After that the following virtual call is made:
Devirtualization will choose C.f to call instead of the D.f.
This change disables devirtualization in such cases. Old crossgen does
the same thing.