[PATCH] D33787: [IR] BasicBlock updatePHIs function for updating predecessors

Daniel Berlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 10:30:04 PDT 2017


dberlin added inline comments.


================
Comment at: lib/IR/BasicBlock.cpp:464
+    int incoming = PHI.getBasicBlockIndex(IncomingOld);
+    if (incoming >= 0) {
+      if (oldPredecessor) {
----------------
It should be an assert that the old predecessor existed in the phi


================
Comment at: lib/IR/BasicBlock.cpp:468
+        // need to insert another value with the same incoming value.
+        PHI.addIncoming(PHI.getIncomingValue(incoming), IncomingNew);
+      } else {
----------------
This will put the phi arguments out of order with the predecessors, which is smoethign we would like to avoid.


================
Comment at: lib/IR/BasicBlock.cpp:470
+      } else {
+        PHI.setIncomingBlock(incoming, IncomingNew);
+      }
----------------
I looked at the code for this function, and i don't see why it would fail.
Can you explain?



https://reviews.llvm.org/D33787





More information about the llvm-commits mailing list