summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-14 01:11:07 +0000
committerChris Lattner <sabre@nondot.org>2003-10-14 01:11:07 +0000
commitf775f95369ba7d88a5cb8b6f1900241699d79351 (patch)
treeff8a645361ce189fd05a770d723a050491643a6f /lib/Transforms
parentebb3acc31d555347b7bacd10edb84319c714b454 (diff)
downloadllvm-f775f95369ba7d88a5cb8b6f1900241699d79351.tar.gz
llvm-f775f95369ba7d88a5cb8b6f1900241699d79351.tar.bz2
llvm-f775f95369ba7d88a5cb8b6f1900241699d79351.tar.xz
Do not move variable sized allocations to the top of the caller, which might
break dominance relationships, and is otherwise bad. This fixes bug: Inline/2003-10-13-AllocaDominanceProblem.ll. This also fixes miscompilation of 3 176.gcc source files (reload1.c, global.c, flow.c) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9109 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index 01ffb253e4..592babc1f9 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -175,13 +175,11 @@ bool InlineFunction(CallSite CS) {
for (BasicBlock::iterator I = LastBlock->begin(), E = LastBlock->end();
I != E; )
- if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
- ++I; // Move to the next instruction
- LastBlock->getInstList().remove(AI);
- Caller->front().getInstList().insert(InsertPoint, AI);
- } else {
- ++I;
- }
+ if (AllocaInst *AI = dyn_cast<AllocaInst>(I++))
+ if (isa<Constant>(AI->getArraySize())) {
+ LastBlock->getInstList().remove(AI);
+ Caller->front().getInstList().insert(InsertPoint, AI);
+ }
}
// If we just inlined a call due to an invoke instruction, scan the inlined