summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2019-04-17 17:37:58 +0000
committerPhilip Reames <listmail@philipreames.com>2019-04-17 17:37:58 +0000
commit88679717ce44dc31dcb87dc5f0206e9e3348001a (patch)
treed65ff3fed9038e0df58437fb270692ccc7d04f7d /llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
parent203958100289f8273bf4bce1a7239cba9e707264 (diff)
downloadbcm5719-llvm-88679717ce44dc31dcb87dc5f0206e9e3348001a.tar.gz
bcm5719-llvm-88679717ce44dc31dcb87dc5f0206e9e3348001a.zip
[InstCombine] Factor out unreachable inst idiom creation [NFC]
In InstCombine, we use an idiom of "store i1 true, i1 undef" to indicate we've found a path which we've proven unreachable. We can't actually insert the unreachable instruction since that would require changing the CFG. We leave that to simplifycfg later. This just factors out that idiom creation so we don't duplicate the same mostly undocument idiom creation in multiple places. llvm-svn: 358600
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index dfdf677a797..5ae56215944 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -4324,9 +4324,7 @@ Instruction *InstCombiner::visitCallBase(CallBase &Call) {
// variety of reasons (e.g. it may be written in assembly).
!CalleeF->isDeclaration()) {
Instruction *OldCall = &Call;
- new StoreInst(ConstantInt::getTrue(Callee->getContext()),
- UndefValue::get(Type::getInt1PtrTy(Callee->getContext())),
- OldCall);
+ CreateNonTerminatorUnreachable(OldCall);
// If OldCall does not return void then replaceAllUsesWith undef.
// This allows ValueHandlers and custom metadata to adjust itself.
if (!OldCall->getType()->isVoidTy())
@@ -4356,13 +4354,8 @@ Instruction *InstCombiner::visitCallBase(CallBase &Call) {
return nullptr;
}
- // This instruction is not reachable, just remove it. We insert a store to
- // undef so that we know that this code is not reachable, despite the fact
- // that we can't modify the CFG here.
- new StoreInst(ConstantInt::getTrue(Callee->getContext()),
- UndefValue::get(Type::getInt1PtrTy(Callee->getContext())),
- &Call);
-
+ // This instruction is not reachable, just remove it.
+ CreateNonTerminatorUnreachable(&Call);
return eraseInstFromFunction(Call);
}
OpenPOWER on IntegriCloud