Sets insertion point of fake cond branch to the last phi node in the block
authorPeizhao Ou <peizhaoo@uci.edu>
Tue, 5 Dec 2017 01:09:40 +0000 (17:09 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Tue, 5 Dec 2017 01:09:40 +0000 (17:09 -0800)
lib/CodeGen/CodeGenPrepare.cpp
lib/IR/Verifier.cpp

index df49c8d6aaeee372e4c32ac38054fcfb8855313e..ac8fbbf9c762fd7582809a43c1025b867b7e4051 100644 (file)
@@ -790,6 +790,9 @@ void TaintRelaxedLoads(Instruction* UsageInst) {
   // condition.
   auto* BB = UsageInst->getParent();
   auto* InsertPoint = UsageInst->getNextNode();
+  while (dyn_cast<PHINode>(InsertPoint)) {
+    InsertPoint = InsertPoint->getNextNode();
+  }
   IRBuilder<true, NoFolder> Builder(InsertPoint);
   // First thing is to cast 'UsageInst' to an integer type if necessary.
   Value* AndTarget = nullptr;
index c8f99c5b4ccbe7143236c287772b1778816d7701..37b56f8efc769aa21cf0a96a2a13b9e899948714 100644 (file)
@@ -1974,6 +1974,10 @@ void Verifier::visitBasicBlock(BasicBlock &BB) {
              "PHI nodes must have at least one entry.  If the block is dead, "
              "the PHI should be removed!",
              PN);
+      if (PN->getNumIncomingValues() != Preds.size()) {
+        dbgs() << "Problematic function: \n" << *PN->getParent()->getParent() << "\n";
+        dbgs() << "Problematic block: \n" << *PN->getParent() << "\n";
+      }
       Assert(PN->getNumIncomingValues() == Preds.size(),
              "PHINode should have one entry for each predecessor of its "
              "parent basic block!",