Adds cast to 64-bit integers and set fake conditional branch insert point to proper...
authorPeizhao Ou <peizhaoo@uci.edu>
Wed, 7 Mar 2018 20:21:46 +0000 (12:21 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Wed, 7 Mar 2018 20:21:46 +0000 (12:21 -0800)
lib/CodeGen/CodeGenPrepare.cpp

index 5f22c14..5b1f8a0 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);
   }