Revert "Revert "Strip metadata when speculatively hoisting instructions (r252604)"
[oota-llvm.git] / lib / Transforms / Utils / SimplifyCFG.cpp
index e0c598f92e2b6d043cb5a75bd9d52c2f727704ca..ff81e7d5acfd969a477128502c0ba18476912872 100644 (file)
@@ -1618,6 +1618,11 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB,
     SpeculatedStore->setOperand(0, S);
   }
 
+  // Metadata can be dependent on the condition we are hoisting above.
+  // Conservatively strip all metadata on the instruction.
+  for (auto &I: *ThenBB)
+    I.dropUnknownNonDebugMetadata();
+
   // Hoist the instructions.
   BB->getInstList().splice(BI->getIterator(), ThenBB->getInstList(),
                            ThenBB->begin(), std::prev(ThenBB->end()));