Skip to content

Consider analyzing call sites to methods to determine if portions of the callee can be trimmed #1868

@stephentoub

Description

@stephentoub

I've seen this in a few cases in corelib. For example, methods that take a StringComparison and then have six cases in a switch, one for each of Ordinal, OrdinalIgnoreCase, InvariantCulture, InvariantCultureIgnoreCase, CurrentCulture, and CurrentCultureIgnoreCase. Each of those ends up having a different supporting implementation. But in a default Blazor wasm app, a given method generally only ended up having a couple of callers, often always with the same harcoded value, e.g. LastIndexOf(..., StringComparison.OrdinalIgnoreCase). The linker could in theory examine all call sites, and if all were const values (or could otherwise be determined via flow analysis), determine which code paths in the callee were and were not hittable, and then trim implementation accordingly. It's also likely a very expensive thing to do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions