Skip to content

Invalid IL produced by unreachable code blocks optimization #86304

Description

@MichalStrehovsky

IL Linker tries to remove unreachable basic blocks from exception filter blocks, but may strip the endfilter instruction in the process, making the IL invalid.

Ran into this in the CoreCLR Pri0 test suite because Native AOT also imported this bug. The CoreCLR test is in IL but it can be reached with C# - this is the simplest way to reach it (pardon the nonsensical code, didn't want to think about this much):

try
{
    throw new Exception();
}
catch when (IntPtr.Size == 8 ? throw new Exception() : true)
{
    Console.WriteLine("Hey");
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Tools-ILLink.NET linker development as well as trimming analyzers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions