From edc7ba5cabb73ad0375a10e60b187b6cd41ccf31 Mon Sep 17 00:00:00 2001 From: Peizhao Ou Date: Wed, 7 Mar 2018 12:21:46 -0800 Subject: [PATCH] Adds cast to 64-bit integers and set fake conditional branch insert point to proper phi position --- lib/CodeGen/CodeGenPrepare.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/CodeGen/CodeGenPrepare.cpp b/lib/CodeGen/CodeGenPrepare.cpp index 5f22c14f90f..5b1f8a064be 100644 --- a/lib/CodeGen/CodeGenPrepare.cpp +++ b/lib/CodeGen/CodeGenPrepare.cpp @@ -791,19 +791,20 @@ void TaintRelaxedLoads(Instruction* UsageInst, Instruction* InsertPoint) { auto* BB = UsageInst->getParent(); if (InsertPoint == nullptr) { InsertPoint = UsageInst->getNextNode(); - while (dyn_cast(InsertPoint)) { - InsertPoint = InsertPoint->getNextNode(); - } + } + // Insert instructions after PHI nodes. + while (dyn_cast(InsertPoint)) { + InsertPoint = InsertPoint->getNextNode(); } // First thing is to cast 'UsageInst' to an integer type if necessary. Value* AndTarget = nullptr; - if (IntegerType::classof(UsageInst->getType())) { + Type* TargetIntegerType = + IntegerType::get(UsageInst->getContext(), + BB->getModule()->getDataLayout().getPointerSizeInBits()); + if (UsageInst->getType() == TargetIntegerType) { AndTarget = UsageInst; } else { - Type* TargetIntegerType = IntegerType::get( - UsageInst->getContext(), - BB->getModule()->getDataLayout().getPointerSizeInBits()); - IRBuilder Builder(UsageInst->getNextNode()); + IRBuilder Builder(InsertPoint); AndTarget = createCast(Builder, UsageInst, TargetIntegerType); } -- 2.34.1