summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorIgor Laevsky <igmyrj@gmail.com>2015-11-10 14:10:31 +0000
committerIgor Laevsky <igmyrj@gmail.com>2015-11-10 14:10:31 +0000
commit01c3692a105d04b87173ce8e875c484fb294ee52 (patch)
tree2922e99024dc190b6c0b8e3dfceb8f1383e4d3a8 /llvm/lib/Transforms/Scalar
parent21aa762226a2a92097a1a35640a07dcf6d162894 (diff)
downloadbcm5719-llvm-01c3692a105d04b87173ce8e875c484fb294ee52.tar.gz
bcm5719-llvm-01c3692a105d04b87173ce8e875c484fb294ee52.zip
Strip metadata when speculatively hoisting instructions
This is fix for PR24059. When we are hoisting instruction above some condition it may turn out that metadata on this instruction was control dependant on the condition. This metadata becomes invalid and we need to drop it. This patch should cover most obvious places of speculative execution (which I have found by greping isSafeToSpeculativelyExecute). I think there are more cases but at least this change covers the severe ones. Differential Revision: http://reviews.llvm.org/D14398 llvm-svn: 252604
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index ba39afd4287..6d70cdc3ade 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -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;
OpenPOWER on IntegriCloud