summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/InlineFunction.cpp
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
commitb4778c73c99f6e0fa3ee6b765568b3ca36f6baaf (patch)
tree30bbd3c0f55625a109adb930d980c3336cd4f28c /llvm/lib/Transforms/Utils/InlineFunction.cpp
parent84b5eb206c039de3ab0833b65ba88a452390a504 (diff)
downloadbcm5719-llvm-b4778c73c99f6e0fa3ee6b765568b3ca36f6baaf.tar.gz
bcm5719-llvm-b4778c73c99f6e0fa3ee6b765568b3ca36f6baaf.zip
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) llvm-svn: 9109
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 01ffb253e4b..592babc1f93 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud