dotnet / dotnet/linker

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

Open
#1,868 8 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.