forked from OSchip/llvm-project
[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
This commit is contained in:
parent
96fc1de77d
commit
698fbe7b59
|
@ -330,7 +330,7 @@ void SparseSolver<LatticeKey, LatticeVal, KeyInfo>::getFeasibleSuccessors(
|
|||
return;
|
||||
}
|
||||
|
||||
if (TI.isExceptional()) {
|
||||
if (TI.isExceptionalTerminator()) {
|
||||
Succs.assign(Succs.size(), true);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -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.
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue