Skip to content

Support removal of unreachable switch blocks #2888

@vitek-karas

Description

@vitek-karas

Linker currently supports removal of unreachable if blocks (branches). For example:

int AlwaysZero { get => 0; }

void Test()
{
    if (AlwaysZero == 0)
    {
        // This will be kept
    }
    else 
    {
        // This entire block will be removed as it can't be reached
    }
}

It doesn't support the same for blocks/branches in switch instructions. So for example:

int AlwaysZero { get => 0; }

void Test()
{
    switch (AlwaysZero)
    case 0:
        // This will be kept
    case 1:
    case 2:
        // This could be removed, but currently isn't
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions