aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/IndVarSimplify.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-25 17:42:10 +0000
committerDan Gohman <gohman@apple.com>2009-08-25 17:42:10 +0000
commit208278cfa708aa6e5fcca6d1b92ee780beb72a8c (patch)
treed812d214bfb03590f07bf1b62066c62707577fe6 /lib/Transforms/Scalar/IndVarSimplify.cpp
parent36ed6c0368d77188063d1594e54c52df1438ae87 (diff)
downloadexternal_llvm-208278cfa708aa6e5fcca6d1b92ee780beb72a8c.zip
external_llvm-208278cfa708aa6e5fcca6d1b92ee780beb72a8c.tar.gz
external_llvm-208278cfa708aa6e5fcca6d1b92ee780beb72a8c.tar.bz2
Special-case static allocas in IndVarSimplify's loop invariant
sinking code, since they are special. If the loop preheader happens to be the entry block of a function, don't sink static allocas out of it. This fixes PR4775. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80010 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r--lib/Transforms/Scalar/IndVarSimplify.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index 790a4fc..ceca452 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -553,6 +553,11 @@ void IndVarSimplify::SinkUnusedInvariants(Loop *L) {
// dominates the exit block.
if (I->mayHaveSideEffects() || I->mayReadFromMemory())
continue;
+ // Don't sink static AllocaInsts out of the entry block, which would
+ // turn them into dynamic allocas!
+ if (AllocaInst *AI = dyn_cast<AllocaInst>(I))
+ if (AI->isStaticAlloca())
+ continue;
// Determine if there is a use in or before the loop (direct or
// otherwise).
bool UsedInLoop = false;