Skip to content

TypeEqualitySealed test is failing with full trimming on #121874

@MichalStrehovsky

Description

@MichalStrehovsky

in pull request #121697, I'm seeing this line:

[MethodImpl(MethodImplOptions.NoInlining)]
public static object TestTernary8(SealedClass1 instance) => instance.GetType() == typeof(SealedClass2) ? "Fail" : "Ok";

Optimized to:

00007FF63D852FF0  lea         rax,[__Str_Ok (07FF63D88B278h)]  
00007FF63D852FF7  ret  

What is probably happening is that with trimming disabled, whole program analysis sees SealedClass2 as possible (because we reflection-rooted it), however after allowing trimming, it becomes impossible and we forget about the NRE side effect.

To repro, you can just copy paste the C# source into the Visual Studio repro project and add -O to the ILC command line. Delete the Xunit gunk and rename the Fact method to Main.

Cc @EgorBo

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions