OSDN Git Service

[SimplifyCFGPass] mergeEmptyReturnBlocks(): skip blocks scheduled for removal as...
authorRoman Lebedev <lebedev.ri@gmail.com>
Mon, 11 Jan 2021 21:35:15 +0000 (00:35 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Mon, 11 Jan 2021 23:09:47 +0000 (02:09 +0300)
Thus supporting lazy DomTreeUpdater mode,
where the domtree updates (and thus block removals)
aren't applied immediately, but are delayed
until last possible moment.

llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp

index 44b9ddd..9443319 100644 (file)
@@ -86,8 +86,9 @@ static bool mergeEmptyReturnBlocks(Function &F, DomTreeUpdater *DTU) {
   BasicBlock *RetBlock = nullptr;
 
   // Scan all the blocks in the function, looking for empty return blocks.
-  for (Function::iterator BBI = F.begin(), E = F.end(); BBI != E; ) {
-    BasicBlock &BB = *BBI++;
+  for (BasicBlock &BB : make_early_inc_range(F)) {
+    if (DTU && DTU->isBBPendingDeletion(&BB))
+      continue;
 
     // Only look at return blocks.
     ReturnInst *Ret = dyn_cast<ReturnInst>(BB.getTerminator());