binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

[NFC] Avoid repeated work in DeadArgumentElimination scanning

Open kripken opened this issue 6 months ago • 1 comments

This pass may do multiple iterations, and before this PR it scanned the entire module each time. That is simpler than tracking stale data, but it can be quite slow. This PR adds staleness tracking, which makes it over 3x faster (and this can be one of our slowest passes in some cases, so this is significant).

To achieve this:

  • Add a staleness marker on function info.
  • Rewrite how we track unseen calls. Previously we used atomics in a clever way, now we just accumulate the data in a simple way (easier for staleness tracking).
  • Add staleness invalidation in the proper places.
  • Add a param to localizeCallsTo to allow us to learn when a function is changed.

This kind of staleness analysis is usually not worthwhile, but given the 3x plus speedup it seems justified. I fuzzed it directly, and also any staleness bug can lead to validation errors, so normal fuzzing also gives us good coverage here.

kripken avatar Aug 22 '24 20:08 kripken