From 3fb4367b57dace6d1418633aa46d719f4008eeb4 Mon Sep 17 00:00:00 2001 From: Peizhao Ou Date: Wed, 23 May 2018 00:42:53 -0700 Subject: [PATCH] Fixes RMW load part tainting outer loop dominating issue --- lib/CodeGen/CodeGenPrepare.cpp | 2 +- lib/CodeGen/TaintRelaxedAtomicsUtils.cpp | 11 ++++------- lib/CodeGen/TaintRelaxedAtomicsUtils.h | 8 ++++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/CodeGen/CodeGenPrepare.cpp b/lib/CodeGen/CodeGenPrepare.cpp index 878e2827147..3ae7a1afe28 100644 --- a/lib/CodeGen/CodeGenPrepare.cpp +++ b/lib/CodeGen/CodeGenPrepare.cpp @@ -365,7 +365,7 @@ bool CodeGenPrepare::runOnFunction(Function &F) { if (EndBB == LoopBB) { BI->getSuccessor(0); } - TaintAtBlockBeginning(&*I, EndBB, DT); + TaintAtBlockBeginning(&*I, EndBB); } } EverMadeChange |= diff --git a/lib/CodeGen/TaintRelaxedAtomicsUtils.cpp b/lib/CodeGen/TaintRelaxedAtomicsUtils.cpp index 3b1f8039384..76f0dd4d02c 100644 --- a/lib/CodeGen/TaintRelaxedAtomicsUtils.cpp +++ b/lib/CodeGen/TaintRelaxedAtomicsUtils.cpp @@ -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 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'. diff --git a/lib/CodeGen/TaintRelaxedAtomicsUtils.h b/lib/CodeGen/TaintRelaxedAtomicsUtils.h index 1536fd3d880..bcc043119cd 100644 --- a/lib/CodeGen/TaintRelaxedAtomicsUtils.h +++ b/lib/CodeGen/TaintRelaxedAtomicsUtils.h @@ -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 -- 2.34.1