Vacuum: Do not turn unreachable into nop#8387
Conversation
tlively
left a comment
There was a problem hiding this comment.
LGTM whether we want to wait for some kind of propagation or not.
|
Actually we don't need any propagation 😄 Inlining does it. Added a test to verify. |
|
Fuzzer found this was wrong - The final fix in this PR is: if code might trap, do not turn it into a nop. That will avoid us turning an unreachable into a nop. It also means we keep around possibly-trapping code, as the new testcase in the last commits shows, but I am pretty sure other passes can handle those cases. |
tlively
left a comment
There was a problem hiding this comment.
I'm a little worried that other passes will not handle cleaning up possibly-trapping code. The usual pattern is that other passes depend on Vacuum to do their cleanups for them, not the other way around. Have you verified that this works out in practice?
An alternative approach would be to look for (unreachable) instructions specifically, and Vacuum anything else.
|
Yeah, I'm worried too, not landing this until we are more certain. Looking for |
|
I guess I was just thinking about the case where the entire function body has just been reduced to |
|
There is also a body that is nothing but |
|
I made this do an extra scan at the end for Unreachables. This situation is rare enough - code that has no effects but trapping - that I'm not worried about the speed of another linear pass. |
This allows propagation of unreachability to callers.
We do not propagate it yet though, so we may want to wait on landing this.