-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone
Description
The following minimal repro is the reason why we regressed TE benchmarks in #90899
using System.Runtime.CompilerServices;
Test<MyStruct>(default);
[MethodImpl(MethodImplOptions.NoInlining)]
static void Test<T>(T t) => ((IMyInterface)t).DoWork();
public interface IMyInterface
{
void DoWork();
}
public struct MyStruct : IMyInterface
{
int a;
[MethodImpl(MethodImplOptions.NoInlining)]
public void DoWork() {}
}Tier0 codegen for Test:
; Assembly listing for method Program:<<Main>$>g__Test|0_0[MyStruct](MyStruct) (Tier0)
push rbp
sub rsp, 48
lea rbp, [rsp+0x30]
xor eax, eax
mov qword ptr [rbp-0x08], rax
mov qword ptr [rbp-0x10], rax
mov qword ptr [rbp+0x10], rcx
lea rdx, [rbp+0x10]
mov rcx, 0x7FFAFBFEE288 ; MyStruct
call CORINFO_HELP_BOX ;;;; <------------------------- allocation!
mov gword ptr [rbp-0x08], rax
mov rdx, gword ptr [rbp-0x08]
mov rcx, 0x7FFAFBFEE0B8 ; IMyInterface
call [CORINFO_HELP_CHKCASTINTERFACE]
mov gword ptr [rbp-0x10], rax
mov rcx, gword ptr [rbp-0x10]
mov r11, 0x7FFAFB4A0248
call [r11]IMyInterface:DoWork():this
nop
add rsp, 48
pop rbp
retTier1 codegen for it:
; Assembly listing for method Program:<<Main>$>g__Test|0_0[MyStruct](MyStruct) (FullOpts)
sub rsp, 40
mov dword ptr [rsp+0x20], ecx
lea rcx, [rsp+0x20]
call [MyStruct:DoWork():this]
nop
add rsp, 40
retPresumably, it needs:
- Don't share temps for boxed values in
impImportAndPushBox(so locals can have exact class info) impOptimizeCastClassOrIsInstshould not quit if opts are disabledimpDevirtualizeCallshould not quit if opts are disabled - and still should be able to optimize calls on unboxed entries
PaulusParssinen
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI