[llvm] r340699 - [IR] Sink `isExceptional` predicate to `Instruction`, rename it to
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 26 01:56:43 PDT 2018
Author: chandlerc
Date: Sun Aug 26 01:56:42 2018
New Revision: 340699
URL: http://llvm.org/viewvc/llvm-project?rev=340699&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/Analysis/SparsePropagation.h
llvm/trunk/include/llvm/IR/InstrTypes.h
llvm/trunk/include/llvm/IR/Instruction.h
llvm/trunk/lib/IR/BasicBlock.cpp
llvm/trunk/lib/Transforms/Coroutines/CoroElide.cpp
llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
llvm/trunk/lib/Transforms/Scalar/Sink.cpp
llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Modified: llvm/trunk/include/llvm/Analysis/SparsePropagation.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/SparsePropagation.h?rev=340699&r1=340698&r2=340699&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/SparsePropagation.h (original)
+++ llvm/trunk/include/llvm/Analysis/SparsePropagation.h Sun Aug 26 01:56:42 2018
@@ -330,7 +330,7 @@ void SparseSolver<LatticeKey, LatticeVal
return;
}
- if (TI.isExceptional()) {
+ if (TI.isExceptionalTerminator()) {
Succs.assign(Succs.size(), true);
return;
}
Modified: llvm/trunk/include/llvm/IR/InstrTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/InstrTypes.h?rev=340699&r1=340698&r2=340699&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/InstrTypes.h (original)
+++ llvm/trunk/include/llvm/IR/InstrTypes.h Sun Aug 26 01:56:42 2018
@@ -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;
- }
- }
};
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/include/llvm/IR/Instruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instruction.h?rev=340699&r1=340698&r2=340699&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instruction.h (original)
+++ llvm/trunk/include/llvm/IR/Instruction.h Sun Aug 26 01:56:42 2018
@@ -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.
//===--------------------------------------------------------------------===//
Modified: llvm/trunk/lib/IR/BasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/BasicBlock.cpp?rev=340699&r1=340698&r2=340699&view=diff
==============================================================================
--- llvm/trunk/lib/IR/BasicBlock.cpp (original)
+++ llvm/trunk/lib/IR/BasicBlock.cpp Sun Aug 26 01:56:42 2018
@@ -384,7 +384,7 @@ bool BasicBlock::isLegalToHoistInto() co
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
Modified: llvm/trunk/lib/Transforms/Coroutines/CoroElide.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/CoroElide.cpp?rev=340699&r1=340698&r2=340699&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/CoroElide.cpp (original)
+++ llvm/trunk/lib/Transforms/Coroutines/CoroElide.cpp Sun Aug 26 01:56:42 2018
@@ -157,7 +157,7 @@ bool Lowerer::shouldElide(Function *F, D
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);
}
Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=340699&r1=340698&r2=340699&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sun Aug 26 01:56:42 2018
@@ -988,7 +988,7 @@ bool JumpThreadingPass::ProcessBlock(Bas
// 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))
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=340699&r1=340698&r2=340699&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Sun Aug 26 01:56:42 2018
@@ -675,7 +675,7 @@ void SCCPSolver::getFeasibleSuccessors(T
}
// Unwinding instructions successors are always executable.
- if (TI.isExceptional()) {
+ if (TI.isExceptionalTerminator()) {
Succs.assign(TI.getNumSuccessors(), true);
return;
}
Modified: llvm/trunk/lib/Transforms/Scalar/Sink.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Sink.cpp?rev=340699&r1=340698&r2=340699&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Sink.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Sink.cpp Sun Aug 26 01:56:42 2018
@@ -104,7 +104,7 @@ static bool IsAcceptableTarget(Instructi
// 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
Modified: llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp?rev=340699&r1=340698&r2=340699&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Sun Aug 26 01:56:42 2018
@@ -136,7 +136,7 @@ bool llvm::MergeBlockIntoPredecessor(Bas
// 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.
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=340699&r1=340698&r2=340699&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Sun Aug 26 01:56:42 2018
@@ -4637,7 +4637,7 @@ GetCaseResults(SwitchInst *SI, ConstantI
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);
More information about the llvm-commits
mailing list