From: Peizhao Ou Date: Wed, 7 Mar 2018 21:31:50 +0000 (-0800) Subject: Ensures further conditional branch tainting instructions are added in the proper... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=d58b6475d64bc75065e31057f5a658d39e2c4dfa Ensures further conditional branch tainting instructions are added in the proper place --- diff --git a/lib/CodeGen/CodeGenPrepare.cpp b/lib/CodeGen/CodeGenPrepare.cpp index 5b1f8a064be..f9b3b2d8ca0 100644 --- a/lib/CodeGen/CodeGenPrepare.cpp +++ b/lib/CodeGen/CodeGenPrepare.cpp @@ -801,12 +801,6 @@ void TaintRelaxedLoads(Instruction* UsageInst, Instruction* InsertPoint) { Type* TargetIntegerType = IntegerType::get(UsageInst->getContext(), BB->getModule()->getDataLayout().getPointerSizeInBits()); - if (UsageInst->getType() == TargetIntegerType) { - AndTarget = UsageInst; - } else { - IRBuilder Builder(InsertPoint); - AndTarget = createCast(Builder, UsageInst, TargetIntegerType); - } // Check whether InsertPoint is a added fake conditional branch. BranchInst* BI = nullptr; @@ -831,6 +825,11 @@ void TaintRelaxedLoads(Instruction* UsageInst, Instruction* InsertPoint) { // Now we have a previously added fake cond branch. auto* Op00 = Op0->getOperand(0); IRBuilder Builder(CmpInst); + if (UsageInst->getType() == TargetIntegerType) { + AndTarget = UsageInst; + } else { + AndTarget = createCast(Builder, UsageInst, TargetIntegerType); + } AndTarget = Builder.CreateAnd(Op00, AndTarget); auto* AndZero = dyn_cast(Builder.CreateAnd( AndTarget, Constant::getNullValue(AndTarget->getType()))); @@ -842,6 +841,11 @@ void TaintRelaxedLoads(Instruction* UsageInst, Instruction* InsertPoint) { } IRBuilder Builder(InsertPoint); + if (UsageInst->getType() == TargetIntegerType) { + AndTarget = UsageInst; + } else { + AndTarget = createCast(Builder, UsageInst, TargetIntegerType); + } auto* AndZero = dyn_cast( Builder.CreateAnd(AndTarget, Constant::getNullValue(AndTarget->getType()))); auto* FakeCondition = dyn_cast(Builder.CreateICmp(