[CaptureTracking] Only check reachability for capture candidates
Reachability queries are very expensive, and currently performed for each instruction we look at, even though most of them will not lead to a capture and are thus ultimately irrelevant. It is more efficient to walk a few unnecessary instructions than to perform unnecessary reachability queries. Theoretically, this may produce worse results, because the additional instructions considered may cause us to hit the use count limit earlier. In practice, this does not appear to be a problem, e.g. on test-suite O3 we report only one more captured-before with this change, with no resulting codegen differences. This makes PointerMayBeCapturedBefore() significantly cheaper in practice, hopefully allowing it to be used in more places.
Loading
Please sign in to comment