Skip to content

JIT incorrectly reorders constrained call 'this' indirections with other arguments #73615

Description

@jakobbotsch

Small example:

usingInlineIL;usingSystem;usingSystem.Runtime.CompilerServices;publicclassProgram{publicstaticvoidMain(){Foo(newC("A"));}[MethodImpl(MethodImplOptions.NoInlining)]privatestaticvoidFoo(Carg){IL.Emit.Ldarga(nameof(arg));IL.Emit.Ldarga(nameof(arg));IL.Emit.Call(newMethodRef(typeof(Program),nameof(Bar)));IL.Emit.Constrained<C>();IL.Emit.Callvirt(newMethodRef(typeof(C),nameof(arg.Baz)));}[MethodImpl(MethodImplOptions.NoInlining)]privatestaticintBar(refCo){o=newC("B");return0;}}publicrecordclassC(stringName){publicvoidBaz(intarg){Console.WriteLine(Name);}}

Expected: B
Actual: A

Seen in #73606 (comment)

category:correctness
theme:importer
skill-level:intermediate
cost:small
impact:small

Metadata

Metadata

Assignees

Labels

Priority:3Work that is nice to havearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbugin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions