-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
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 SuperPMIin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
If an interface/abstract class has no subclasses or they were trimmed out - all typechecks against that subclass should be folded, e.g.:
interface IMyInterface { }
class Program
{
static void Main()
{
Test(null);
}
[MethodImpl(MethodImplOptions.NoInlining)]
static void Test(object o)
{
if (o is IMyInterface) // there are no types implementing this interface
Console.WriteLine("MyInterface!");
}
}Current codegen with NativeAOT for Test:
; Assembly listing for method Program:Test(System.Object) (FullOpts)
sub rsp, 40
mov rdx, rcx
lea rcx, [(reloc 0x4000000000422e10)] ; IMyInterface
call CORINFO_HELP_ISINSTANCEOFINTERFACE
test rax, rax
je SHORT G_M3485_IG04
lea rcx, gword ptr [(reloc 0x4000000000422e28)] ; '"MyInterface!"'
call System.Console:WriteLine(System.String)
G_M3485_IG04:
nop
add rsp, 40
ret
; Total bytes of code 42Expected codegen:
; Assembly listing for method Program:Test(System.Object) (FullOpts)
ret
; Total bytes of code 1,cc @MichalStrehovsky. I presume for that we need to make 0 a meaningful result for getExactClasses API.
PaulusParssinen and hez2010
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 SuperPMIin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged