summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2018-08-26 08:56:42 +0000
committerChandler Carruth <chandlerc@gmail.com>2018-08-26 08:56:42 +0000
commit698fbe7b59a77888f108fbfe37e17a1db0cace8c (patch)
treedbb7aba182f9903a5ae73514df768157d5a25c10
parent96fc1de77da3efd1ec1f5cbbb4936de4bac8105d (diff)
downloadbcm5719-llvm-698fbe7b59a77888f108fbfe37e17a1db0cace8c.tar.gz
bcm5719-llvm-698fbe7b59a77888f108fbfe37e17a1db0cace8c.zip
[IR] Sink `isExceptional` predicate to `Instruction`, rename it to
`isExceptionalTermiantor` and implement it for opcodes as well following the common pattern in `Instruction`. Part of removing `TerminatorInst` from the `Instruction` type hierarchy to make it easier to share logic and interfaces between instructions that are both terminators and not terminators. llvm-svn: 340699
-rw-r--r--llvm/include/llvm/Analysis/SparsePropagation.h2
-rw-r--r--llvm/include/llvm/IR/InstrTypes.h14
-rw-r--r--llvm/include/llvm/IR/Instruction.h17
-rw-r--r--llvm/lib/IR/BasicBlock.cpp2
-rw-r--r--llvm/lib/Transforms/Coroutines/CoroElide.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/SCCP.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/Sink.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/BasicBlockUtils.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp2
10 files changed, 25 insertions, 22 deletions
diff --git a/llvm/include/llvm/Analysis/SparsePropagation.h b/llvm/include/llvm/Analysis/SparsePropagation.h
index defcf96afb2..04e94f7cd52 100644
--- a/llvm/include/llvm/Analysis/SparsePropagation.h
+++ b/llvm/include/llvm/Analysis/SparsePropagation.h
@@ -330,7 +330,7 @@ void SparseSolver<LatticeKey, LatticeVal, KeyInfo>::getFeasibleSuccessors(
return;
}
- if (TI.isExceptional()) {
+ if (TI.isExceptionalTerminator()) {
Succs.assign(Succs.size(), true);
return;
}
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 0a5a6ad222a..95cdb70e4fd 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -71,20 +71,6 @@ public:
static bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
-
- // Returns true if this terminator relates to exception handling.
- bool isExceptional() const {
- switch (getOpcode()) {
- case Instruction::CatchSwitch:
- case Instruction::CatchRet:
- case Instruction::CleanupRet:
- case Instruction::Invoke:
- case Instruction::Resume:
- return true;
- default:
- return false;
- }
- }
};
//===----------------------------------------------------------------------===//
diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h
index bd5f6562759..2a75801c649 100644
--- a/llvm/include/llvm/IR/Instruction.h
+++ b/llvm/include/llvm/IR/Instruction.h
@@ -132,6 +132,9 @@ public:
bool isShift() { return isShift(getOpcode()); }
bool isCast() const { return isCast(getOpcode()); }
bool isFuncletPad() const { return isFuncletPad(getOpcode()); }
+ bool isExceptionalTerminator() const {
+ return isExceptionalTerminator(getOpcode());
+ }
static const char* getOpcodeName(unsigned OpCode);
@@ -182,6 +185,20 @@ public:
return OpCode >= FuncletPadOpsBegin && OpCode < FuncletPadOpsEnd;
}
+ /// Returns true if the OpCode is a terminator related to exception handling.
+ static inline bool isExceptionalTerminator(unsigned OpCode) {
+ switch (OpCode) {
+ case Instruction::CatchSwitch:
+ case Instruction::CatchRet:
+ case Instruction::CleanupRet:
+ case Instruction::Invoke:
+ case Instruction::Resume:
+ return true;
+ default:
+ return false;
+ }
+ }
+
//===--------------------------------------------------------------------===//
// Metadata manipulation.
//===--------------------------------------------------------------------===//
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 116729a57da..d04af9261e3 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -384,7 +384,7 @@ bool BasicBlock::isLegalToHoistInto() const {
assert(Term->getNumSuccessors() > 0);
// Instructions should not be hoisted across exception handling boundaries.
- return !Term->isExceptional();
+ return !Term->isExceptionalTerminator();
}
/// This splits a basic block into two at the specified
diff --git a/llvm/lib/Transforms/Coroutines/CoroElide.cpp b/llvm/lib/Transforms/Coroutines/CoroElide.cpp
index dfe05c4b2a5..58f952b54f3 100644
--- a/llvm/lib/Transforms/Coroutines/CoroElide.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroElide.cpp
@@ -157,7 +157,7 @@ bool Lowerer::shouldElide(Function *F, DominatorTree &DT) const {
SmallPtrSet<Instruction *, 8> Terminators;
for (BasicBlock &B : *F) {
auto *TI = B.getTerminator();
- if (TI->getNumSuccessors() == 0 && !TI->isExceptional() &&
+ if (TI->getNumSuccessors() == 0 && !TI->isExceptionalTerminator() &&
!isa<UnreachableInst>(TI))
Terminators.insert(TI);
}
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 45e73e98b4c..4e6bc5cee04 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -988,7 +988,7 @@ bool JumpThreadingPass::ProcessBlock(BasicBlock *BB) {
// predecessors of our predecessor block.
if (BasicBlock *SinglePred = BB->getSinglePredecessor()) {
const TerminatorInst *TI = SinglePred->getTerminator();
- if (!TI->isExceptional() && TI->getNumSuccessors() == 1 &&
+ if (!TI->isExceptionalTerminator() && TI->getNumSuccessors() == 1 &&
SinglePred != BB && !hasAddressTakenAndUsed(BB)) {
// If SinglePred was a loop header, BB becomes one.
if (LoopHeaders.erase(SinglePred))
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index 81ec692ae5d..9ac10603459 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -675,7 +675,7 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI,
}
// Unwinding instructions successors are always executable.
- if (TI.isExceptional()) {
+ if (TI.isExceptionalTerminator()) {
Succs.assign(TI.getNumSuccessors(), true);
return;
}
diff --git a/llvm/lib/Transforms/Scalar/Sink.cpp b/llvm/lib/Transforms/Scalar/Sink.cpp
index ca6b93e0b4a..b59d52f2ecf 100644
--- a/llvm/lib/Transforms/Scalar/Sink.cpp
+++ b/llvm/lib/Transforms/Scalar/Sink.cpp
@@ -104,7 +104,7 @@ static bool IsAcceptableTarget(Instruction *Inst, BasicBlock *SuccToSinkTo,
// It's never legal to sink an instruction into a block which terminates in an
// EH-pad.
- if (SuccToSinkTo->getTerminator()->isExceptional())
+ if (SuccToSinkTo->getTerminator()->isExceptionalTerminator())
return false;
// If the block has multiple predecessors, this would introduce computation
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index 279aef6fcbb..99914fcf81b 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -136,7 +136,7 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU,
// Don't break self-loops.
if (PredBB == BB) return false;
// Don't break unwinding instructions.
- if (PredBB->getTerminator()->isExceptional())
+ if (PredBB->getTerminator()->isExceptionalTerminator())
return false;
// Can't merge if there are multiple distinct successors.
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 06f7844e8bd..d0f7be228d2 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4637,7 +4637,7 @@ GetCaseResults(SwitchInst *SI, ConstantInt *CaseVal, BasicBlock *CaseDest,
for (Instruction &I :CaseDest->instructionsWithoutDebug()) {
if (TerminatorInst *T = dyn_cast<TerminatorInst>(&I)) {
// If the terminator is a simple branch, continue to the next block.
- if (T->getNumSuccessors() != 1 || T->isExceptional())
+ if (T->getNumSuccessors() != 1 || T->isExceptionalTerminator())
return false;
Pred = CaseDest;
CaseDest = T->getSuccessor(0);
OpenPOWER on IntegriCloud