summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-30 00:46:41 +0000
committerChris Lattner <sabre@nondot.org>2003-10-30 00:46:41 +0000
commit686767f3f6d5bf0ca1ac79e524115a4960144a98 (patch)
tree0ce03e0af01fe0eeb9d0d6df5368fdaf6cb7959e /llvm/lib/Transforms/Scalar/InstructionCombining.cpp
parent3cffc5645168a9f3bb0da37b5dffb3a124a89f69 (diff)
downloadbcm5719-llvm-686767f3f6d5bf0ca1ac79e524115a4960144a98.tar.gz
bcm5719-llvm-686767f3f6d5bf0ca1ac79e524115a4960144a98.zip
Fix bug: 2003-10-29-CallSiteResolve.ll & PR70
llvm-svn: 9600
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 91c549d495e..bc1a81967f4 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1739,7 +1739,17 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
if (Caller->getType() != NV->getType() && !Caller->use_empty()) {
if (NV->getType() != Type::VoidTy) {
NV = NC = new CastInst(NC, Caller->getType(), "tmp");
- InsertNewInstBefore(NC, *Caller);
+
+ // If this is an invoke instruction, we should insert it after the first
+ // non-phi, instruction in the normal successor block.
+ if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
+ BasicBlock::iterator I = II->getNormalDest()->begin();
+ while (isa<PHINode>(I)) ++I;
+ InsertNewInstBefore(NC, *I);
+ } else {
+ // Otherwise, it's a call, just insert cast right after the call instr
+ InsertNewInstBefore(NC, *Caller);
+ }
AddUsesToWorkList(*Caller);
} else {
NV = Constant::getNullValue(Caller->getType());
OpenPOWER on IntegriCloud