summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-30 04:37:52 +0000
committerChris Lattner <sabre@nondot.org>2004-04-30 04:37:52 +0000
commit652064e3b8731de786b1a78b4a8b15360a48a7a5 (patch)
treea8e003a5b865b0e944a389f4f85c381283fbdaa8 /llvm/lib/Transforms
parent63c3b3c8d72e4dbf3379ef92416e1fe3ff8eec2d (diff)
downloadbcm5719-llvm-652064e3b8731de786b1a78b4a8b15360a48a7a5.tar.gz
bcm5719-llvm-652064e3b8731de786b1a78b4a8b15360a48a7a5.zip
Fix a major pessimization in the instcombiner. If an allocation instruction
is only used by a cast, and the casted type is the same size as the original allocation, it would eliminate the cast by folding it into the allocation. Unfortunately, it was placing the new allocation instruction right before the cast, which could pull (for example) alloca instructions into the body of a function. This turns statically allocatable allocas into expensive dynamically allocated allocas, which is bad bad bad. This fixes the problem by placing the new allocation instruction at the same place the old one was, duh. :) llvm-svn: 13289
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 92b7f1a39bc..18de1269e9d 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2035,7 +2035,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
New = new MallocInst(CastElTy, Amt, Name);
else
New = new AllocaInst(CastElTy, Amt, Name);
- InsertNewInstBefore(New, CI);
+ InsertNewInstBefore(New, *AI);
return ReplaceInstUsesWith(CI, New);
}
}
OpenPOWER on IntegriCloud