[PATCH] D13718: [SimplifyCFG] Extend SimplifyResume to handle phi of trivial landing pad.

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 15 16:54:52 PDT 2015


reames added inline comments.

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:2930
@@ +2929,3 @@
+      auto *IncomingBB = PhiLPInst->getIncomingBlock(i);
+      auto *IncomingLP = PhiLPInst->getIncomingValue(i);
+
----------------
Call this IncomingValue since it's not necessarily a landing pad yet.  

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:2956
@@ +2955,3 @@
+    if (auto *Phi = dyn_cast<PHINode>(RI->getValue())) {
+      // Blocks those would be deleted should also be removed
+      // from the phi node.
----------------
Blocks that will be deleted...

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:2958
@@ +2957,3 @@
+      // from the phi node.
+      Phi->removeIncomingValue(TrivialBB);
+    }
----------------
Using BasicBlock::removePredecessor is the idiomatic way to do this.

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:2969
@@ -2921,2 +2968,3 @@
   }
 
+  return TrivialUnwindBlocks.size() != 0;
----------------
I think that if you're not careful here, you mind end up with a block with a zero entry PHI and no predecessors.  You should probably delete that one too.


http://reviews.llvm.org/D13718





More information about the llvm-commits mailing list