Adds cast to 64-bit integers and set fake conditional branch insert point to proper...
[oota-llvm.git] / lib / CodeGen / CodeGenPrepare.cpp
index 5f22c14f90fbb79e8f649e50a3d26f2032c46947..5b1f8a064befb5fd5bbebe9ac5f8bef8d1d747bf 100644 (file)
@@ -791,19 +791,20 @@ void TaintRelaxedLoads(Instruction* UsageInst, Instruction* InsertPoint) {
   auto* BB = UsageInst->getParent();
   if (InsertPoint == nullptr) {
     InsertPoint = UsageInst->getNextNode();
-    while (dyn_cast<PHINode>(InsertPoint)) {
-      InsertPoint = InsertPoint->getNextNode();
-    }
+  }
+  // Insert instructions after PHI nodes.
+  while (dyn_cast<PHINode>(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<true, NoFolder> Builder(UsageInst->getNextNode());
+    IRBuilder<true, NoFolder> Builder(InsertPoint);
     AndTarget = createCast(Builder, UsageInst, TargetIntegerType);
   }