================
@@ -1250,9 +1250,22 @@ class FallthroughMapper : public
DynamicRecursiveASTVisitor {
while (!BlockQueue.empty()) {
const CFGBlock *P = BlockQueue.front();
BlockQueue.pop_front();
- for (const CFGBlock *B : P->succs()) {
+ // The code after an 'analyzer_noreturn' call isn't dead, since the call
+ // can return. The CFG keeps that code as the alternate successor of the
+ // exit edge, so follow it too.
+ bool FollowAlternate = P->hasOnlyAnalyzerNoReturnElement();
+ for (const CFGBlock::AdjacentBlock &Succ : P->succs()) {
+ const CFGBlock *B = Succ.getReachableBlock();
if (B && ReachableBlocks.insert(B).second)
BlockQueue.push_back(B);
+ if (!FollowAlternate)
+ continue;
+ const CFGBlock *Alt = Succ.getPossiblyUnreachableBlock();
+ assert(B && Alt != B &&
+ "noreturn edge should have a reachable block and a distinct "
+ "alternate");
+ if (Alt && ReachableBlocks.insert(Alt).second)
+ BlockQueue.push_back(Alt);
----------------
ahatanak wrote:
I added the assert as a sanity check that we don't queue the same block twice,
but `ReachableBlocks.insert(Alt).second` already handles that. I removed the
assert in 716398d7d85eded93b8a5b712b3475665c193ed2.
For the record, `B` is non-null if `P` is a block whose only noreturn call is
an `analyzer_noreturn`. Block `P` is created by `createNoReturnBlock()`, which
calls `addSuccessor(B, &cfg->getExit(), Succ)`, and the reachable block of the
edge is the exit block.
https://github.com/llvm/llvm-project/pull/242121
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits