diff options
author | Igor Laevsky <igmyrj@gmail.com> | 2015-11-10 14:10:31 +0000 |
---|---|---|
committer | Igor Laevsky <igmyrj@gmail.com> | 2015-11-10 14:10:31 +0000 |
commit | 01c3692a105d04b87173ce8e875c484fb294ee52 (patch) | |
tree | 2922e99024dc190b6c0b8e3dfceb8f1383e4d3a8 /llvm/lib/Analysis/LoopInfo.cpp | |
parent | 21aa762226a2a92097a1a35640a07dcf6d162894 (diff) | |
download | llvm-01c3692a105d04b87173ce8e875c484fb294ee52.zip llvm-01c3692a105d04b87173ce8e875c484fb294ee52.tar.gz llvm-01c3692a105d04b87173ce8e875c484fb294ee52.tar.bz2 |
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/Analysis/LoopInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 9ee7236..e679b7a 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -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; } |