diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2016-06-05 22:13:52 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2016-06-05 22:13:52 +0000 |
commit | ee8950579959f8e86278296612915571596bae38 (patch) | |
tree | ffc0429eff30cbf63af799e5eafe3c9d4f1ba4c4 /llvm/lib/Transforms | |
parent | b7e861a488f8177f07cbf4bb1c0428e3a53667c9 (diff) | |
download | bcm5719-llvm-ee8950579959f8e86278296612915571596bae38.tar.gz bcm5719-llvm-ee8950579959f8e86278296612915571596bae38.zip |
LICM: Don't sink stores out of loops that may throw.
Summary:
This hasn't been caught before because it requires noalias or similarly
strong alias analysis to actually reproduce.
Fixes http://llvm.org/PR27952 .
Reviewers: hfinkel, sanjoy
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D20944
llvm-svn: 271858
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LICM.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index 3b197e4ac2c..13b5c141fcf 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -928,6 +928,16 @@ bool llvm::promoteLoopAccessesToScalars( const DataLayout &MDL = Preheader->getModule()->getDataLayout(); + if (SafetyInfo->MayThrow) { + // If a loop can throw, we have to insert a store along each unwind edge. + // That said, we can't actually make the unwind edge explicit. Therefore, + // we have to prove that the store is dead along the unwind edge. + // + // Currently, this code just special-cases alloca instructions. + if (!isa<AllocaInst>(GetUnderlyingObject(SomePtr, MDL))) + return false; + } + // Check that all of the pointers in the alias set have the same type. We // cannot (yet) promote a memory location that is loaded and stored in // different sizes. While we are at it, collect alignment and AA info. |