aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/InstCombine/InstructionCombining.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-06-25 17:11:47 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-06-25 17:11:47 +0000
commit3769fe149bb47dfdaa8ac39b7a4c26cf98ec503e (patch)
tree3b6f81ade44460101257ea285f2fa1cafe3ea71e /lib/Transforms/InstCombine/InstructionCombining.cpp
parente8742d084c54e9cd230fa03d368f0fedac2106cb (diff)
downloadexternal_llvm-3769fe149bb47dfdaa8ac39b7a4c26cf98ec503e.zip
external_llvm-3769fe149bb47dfdaa8ac39b7a4c26cf98ec503e.tar.gz
external_llvm-3769fe149bb47dfdaa8ac39b7a4c26cf98ec503e.tar.bz2
improve optimization of invoke instructions:
- simplifycfg: invoke undef/null -> unreachable - instcombine: invoke new -> invoke expect(0, 0) (an arbitrary NOOP intrinsic; only done if the allocated memory is unused, of course) - verifier: allow invoke of intrinsics (to make the previous step work) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159146 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstructionCombining.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp
index 269ea15..07793ac 100644
--- a/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1169,7 +1169,14 @@ Instruction *InstCombiner::visitMalloc(Instruction &MI) {
}
if (InvokeInst *II = dyn_cast<InvokeInst>(&MI)) {
- BranchInst::Create(II->getNormalDest(), II->getParent());
+ // Replace invoke with a NOOP intrinsic to maintain the original CFG
+ Module *M = II->getParent()->getParent()->getParent();
+ IntegerType *Ty = IntegerType::get(II->getContext(), 8);
+ ConstantInt *CI = ConstantInt::get(Ty, 0);
+ Value *Args[] = {CI, CI};
+ Function *F = Intrinsic::getDeclaration(M, Intrinsic::expect, Ty);
+ InvokeInst::Create(F, II->getNormalDest(), II->getUnwindDest(), Args,
+ "dummy", II->getParent());
}
return EraseInstFromFunction(MI);
}