diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-01 18:04:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-01 18:04:58 +0000 |
commit | 830f3f205d8a77acbf8838fe78c2c733ca924d9c (patch) | |
tree | 62e96b0c20202fd59c3bb5a5bfa4afb5ee2f3a28 /lib/Transforms | |
parent | 3cb8509b680209c79632d7445709452f28213057 (diff) | |
download | external_llvm-830f3f205d8a77acbf8838fe78c2c733ca924d9c.zip external_llvm-830f3f205d8a77acbf8838fe78c2c733ca924d9c.tar.gz external_llvm-830f3f205d8a77acbf8838fe78c2c733ca924d9c.tar.bz2 |
fix rdar://7590304, an infinite loop in instcombine. In the invoke
case, instcombine can't zap the invoke for fear of changing the CFG.
However, we have to do something to prevent the next iteration of
instcombine from inserting another store -> undef before the invoke
thereby getting into infinite iteration between dead store elim and
store insertion.
Just zap the callee to null, which will prevent the next iteration
from doing anything.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94985 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineCalls.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index 47c37c4..9c420c8 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -703,8 +703,13 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) { // This allows ValueHandlers and custom metadata to adjust itself. if (!OldCall->getType()->isVoidTy()) OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType())); - if (isa<CallInst>(OldCall)) // Not worth removing an invoke here. + if (isa<CallInst>(OldCall)) return EraseInstFromFunction(*OldCall); + + // We cannot remove an invoke, because it would change the CFG, just + // change the callee to a null pointer. + cast<InvokeInst>(OldCall)->setOperand(0, + Constant::getNullValue(CalleeF->getType())); return 0; } |