-
Subzero: Prune unreachable nodes after constructing the Cfg. · 69d3f9c6Jim Stichnoth authored
The gcc torture test suite has examples where there is a function call (to a routine that throws an exception or aborts or something), followed by an "unreachable" instruction, followed by more code that may e.g. return a value to the caller. In these examples, the code following the unreachable is itself unreachable. Problems arise when the unreachable code references a variable defined in the reachable code. This triggers a liveness consistency error because the use of the variable has no reaching definition. It's a bit surprising that LLVM actually allows this, but it does so we need to deal with it. The solution is, after initial CFG construction, do a traversal starting from the entry node and then delete any undiscovered nodes. There is code in Subzero that assumes Cfg::Nodes[i]->Number == i, so the nodes need to be renumbered after pruning. The alternative was to set Nodes[i]=nullptr and not change the node number, but that would mean peppering the code base with CfgNode null checks. BUG= none R=jvoung@chromium.org Review URL: https://codereview.chromium.org/1027933002
69d3f9c6
×