Fixes RMW load part tainting outer loop dominating issue
authorPeizhao Ou <peizhaoo@uci.edu>
Wed, 23 May 2018 07:42:53 +0000 (00:42 -0700)
committerPeizhao Ou <peizhaoo@uci.edu>
Wed, 23 May 2018 07:42:53 +0000 (00:42 -0700)
lib/CodeGen/CodeGenPrepare.cpp
lib/CodeGen/TaintRelaxedAtomicsUtils.cpp
lib/CodeGen/TaintRelaxedAtomicsUtils.h

index 878e28271473d62d4f19919e0bbc305305e34cb0..3ae7a1afe28d95594bf21e6a103f4af70edab997 100644 (file)
@@ -365,7 +365,7 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
       if (EndBB == LoopBB) {
         BI->getSuccessor(0);
       }
-      TaintAtBlockBeginning(&*I, EndBB, DT);
+      TaintAtBlockBeginning(&*I, EndBB);
     }
   }
   EverMadeChange |=
index 3b1f803938469c13ab4f0df5cfe9c46380e12d42..76f0dd4d02cabe569a92dbe13178ce078115185f 100644 (file)
@@ -689,15 +689,12 @@ void TaintRelaxedLoads(Instruction* UsageInst, Instruction* InsertPoint) {
 }
 
 // Taints the 'Inst' (i.e., adds a fake conditional block that uses the 'Inst')
-// at the beginning of basic block 'BB'. Note that if 'Inst' does not dominate
-// 'BB', we need to add appropriate an PHI node and taint the PHI node. Returns
-// true if the code is changed, and false otherwise.
-void TaintAtBlockBeginning(Instruction* Inst, BasicBlock* BB, DominatorTree* DT) {
+// at the beginning of basic block 'BB'. Note that we need to add an appropriate
+// PHI node and taint the PHI node. Returns true if the code is changed, and
+// false otherwise.
+void TaintAtBlockBeginning(Instruction* Inst, BasicBlock* BB) {
   auto* CurBB = Inst->getParent();
   auto* FirstInst = BB->getFirstNonPHI();
-  if (DT->dominates(Inst, FirstInst)) {
-    return TaintRelaxedLoads(&*Inst, FirstInst);
-  }
   IRBuilder<true, NoFolder> Builder(FirstInst);
   auto* Phi = Builder.CreatePHI(Inst->getType(), 0, Inst->getName() + ".phi");
   // Multiple blocks going to BB. We should add a PHI node w.r.t. 'Inst'.
index 1536fd3d880fad5179228ff7588beee5ac08dec6..bcc043119cdea75d99751576b13947f5525d8f4d 100644 (file)
@@ -187,10 +187,10 @@ void AddFakeConditionalBranch(Instruction* SplitInst, Value* Condition);
 void TaintRelaxedLoads(Instruction* UsageInst, Instruction* InsertPoint);
 
 // Taints the 'Inst' (i.e., adds a fake conditional block that uses the 'Inst')
-// at the beginning of basic block 'BB'. Note that if 'Inst' does not dominate
-// 'BB', we need to add appropriate an PHI node and taint the PHI node. Returns
-// true if the code is changed, and false otherwise.
-void TaintAtBlockBeginning(Instruction* Inst, BasicBlock* BB, DominatorTree* DT);
+// at the beginning of basic block 'BB'. Note that we need to add an appropriate
+// PHI node and taint the PHI node. Returns true if the code is changed, and
+// false otherwise.
+void TaintAtBlockBeginning(Instruction* Inst, BasicBlock* BB);
 
 // XXX-comment: Finds the appropriate Value derived from an atomic load.
 // 'ChainedBB' contains all the blocks chained together with unconditional