Strip metadata when speculatively hoisting instructions
[oota-llvm.git] / lib / Analysis / LoopInfo.cpp
index 9ee72361c92a6bf9582f0edd27666d187b1c6566..e679b7ad7b86a17987ef0743e62e3670f9cf074f 100644 (file)
@@ -120,6 +120,13 @@ bool Loop::makeLoopInvariant(Instruction *I, bool &Changed,
 
   // Hoist.
   I->moveBefore(InsertPt);
+
+  // There is possibility of hoisting this instruction above some arbitrary
+  // condition. Any metadata defined on it can be control dependent on this
+  // condition. Conservatively strip it here so that we don't give any wrong
+  // information to the optimizer.
+  I->dropUnknownNonDebugMetadata();
+
   Changed = true;
   return true;
 }