Strip metadata when speculatively hoisting instructions
[oota-llvm.git] / lib / Transforms / Scalar / LICM.cpp
index ba39afd42872f04916b62e09b9619e2c26abeae7..6d70cdc3ade2d1a81cc54f0beef1c07882745f2b 100644 (file)
@@ -672,6 +672,10 @@ static bool hoist(Instruction &I, BasicBlock *Preheader) {
   // Move the new node to the Preheader, before its terminator.
   I.moveBefore(Preheader->getTerminator());
 
+  // Metadata can be dependent on the condition we are hoisting above.
+  // Conservatively strip all metadata on the instruction.
+  I.dropUnknownNonDebugMetadata();
+
   if (isa<LoadInst>(I)) ++NumMovedLoads;
   else if (isa<CallInst>(I)) ++NumMovedCalls;
   ++NumHoisted;