aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar
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
commitc1526a9da1e2e79000ab856976133fbc2c4567f4 (patch)
treeb89421d42fad75dbb644951bcca2a5e8c78d88bb /lib/Transforms/Scalar
parent8c53472d0c872eeb401dfbcce857c91f80639b56 (diff)
downloadexternal_llvm-c1526a9da1e2e79000ab856976133fbc2c4567f4.zip
external_llvm-c1526a9da1e2e79000ab856976133fbc2c4567f4.tar.gz
external_llvm-c1526a9da1e2e79000ab856976133fbc2c4567f4.tar.bz2
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. :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13289 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 92b7f1a..18de126 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/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);
}
}