summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/docs/CodingStandards.rst4
-rw-r--r--llvm/include/llvm/IR/CFG.h7
-rw-r--r--llvm/lib/Analysis/CFLGraph.h2
-rw-r--r--llvm/lib/Analysis/DemandedBits.cpp4
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp4
-rw-r--r--llvm/lib/Analysis/MemoryDependenceAnalysis.cpp2
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp2
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp2
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/FastISel.cpp4
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp4
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp4
-rw-r--r--llvm/lib/CodeGen/WinEHPrepare.cpp5
-rw-r--r--llvm/lib/FuzzMutate/RandomIRBuilder.cpp2
-rw-r--r--llvm/lib/IR/Instruction.cpp2
-rw-r--r--llvm/lib/Transforms/Coroutines/CoroFrame.cpp3
-rw-r--r--llvm/lib/Transforms/Coroutines/CoroSplit.cpp2
-rw-r--r--llvm/lib/Transforms/IPO/PruneEH.cpp2
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp7
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/ADCE.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/GVN.cpp4
-rw-r--r--llvm/lib/Transforms/Scalar/GVNHoist.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/NewGVN.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/DemoteRegToStack.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/Evaluator.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/LoopRotationUtils.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp10
-rw-r--r--llvm/tools/bugpoint/CrashDebugger.cpp6
-rw-r--r--llvm/unittests/Transforms/Utils/Local.cpp2
36 files changed, 59 insertions, 53 deletions
diff --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst
index 6ed7a95c9f0..92cad91a08e 100644
--- a/llvm/docs/CodingStandards.rst
+++ b/llvm/docs/CodingStandards.rst
@@ -955,7 +955,7 @@ exit from a function, consider this "bad" code:
.. code-block:: c++
Value *doSomething(Instruction *I) {
- if (!isa<TerminatorInst>(I) &&
+ if (!I->isTerminator() &&
I->hasOneUse() && doOtherThing(I)) {
... some long code ....
}
@@ -980,7 +980,7 @@ It is much preferred to format the code like this:
Value *doSomething(Instruction *I) {
// Terminators never need 'something' done to them because ...
- if (isa<TerminatorInst>(I))
+ if (I->isTerminator())
return 0;
// We conservatively avoid transforming instructions with multiple uses
diff --git a/llvm/include/llvm/IR/CFG.h b/llvm/include/llvm/IR/CFG.h
index 653e59d50cf..fd384ef4949 100644
--- a/llvm/include/llvm/IR/CFG.h
+++ b/llvm/include/llvm/IR/CFG.h
@@ -49,8 +49,13 @@ class PredIterator : public std::iterator<std::forward_iterator_tag,
inline void advancePastNonTerminators() {
// Loop to ignore non-terminator uses (for example BlockAddresses).
- while (!It.atEnd() && !isa<TerminatorInst>(*It))
+ while (!It.atEnd()) {
+ if (auto *Inst = dyn_cast<Instruction>(*It))
+ if (Inst->isTerminator())
+ break;
+
++It;
+ }
}
public:
diff --git a/llvm/lib/Analysis/CFLGraph.h b/llvm/lib/Analysis/CFLGraph.h
index 86812009da7..12121d71743 100644
--- a/llvm/lib/Analysis/CFLGraph.h
+++ b/llvm/lib/Analysis/CFLGraph.h
@@ -594,7 +594,7 @@ template <typename CFLAA> class CFLGraphBuilder {
// Determines whether or not we an instruction is useless to us (e.g.
// FenceInst)
static bool hasUsefulEdges(Instruction *Inst) {
- bool IsNonInvokeRetTerminator = isa<TerminatorInst>(Inst) &&
+ bool IsNonInvokeRetTerminator = Inst->isTerminator() &&
!isa<InvokeInst>(Inst) &&
!isa<ReturnInst>(Inst);
return !isa<CmpInst>(Inst) && !isa<FenceInst>(Inst) &&
diff --git a/llvm/lib/Analysis/DemandedBits.cpp b/llvm/lib/Analysis/DemandedBits.cpp
index e7637cd8832..35af4be485f 100644
--- a/llvm/lib/Analysis/DemandedBits.cpp
+++ b/llvm/lib/Analysis/DemandedBits.cpp
@@ -78,8 +78,8 @@ void DemandedBitsWrapperPass::print(raw_ostream &OS, const Module *M) const {
}
static bool isAlwaysLive(Instruction *I) {
- return isa<TerminatorInst>(I) || isa<DbgInfoIntrinsic>(I) ||
- I->isEHPad() || I->mayHaveSideEffects();
+ return I->isTerminator() || isa<DbgInfoIntrinsic>(I) || I->isEHPad() ||
+ I->mayHaveSideEffects();
}
void DemandedBits::determineLiveOperandBits(
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 290d169df24..f14de66a62c 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5165,7 +5165,7 @@ static bool replaceAndRecursivelySimplifyImpl(Instruction *I, Value *SimpleV,
// Gracefully handle edge cases where the instruction is not wired into any
// parent block.
- if (I->getParent() && !I->isEHPad() && !isa<TerminatorInst>(I) &&
+ if (I->getParent() && !I->isEHPad() && !I->isTerminator() &&
!I->mayHaveSideEffects())
I->eraseFromParent();
} else {
@@ -5194,7 +5194,7 @@ static bool replaceAndRecursivelySimplifyImpl(Instruction *I, Value *SimpleV,
// Gracefully handle edge cases where the instruction is not wired into any
// parent block.
- if (I->getParent() && !I->isEHPad() && !isa<TerminatorInst>(I) &&
+ if (I->getParent() && !I->isEHPad() && !I->isTerminator() &&
!I->mayHaveSideEffects())
I->eraseFromParent();
}
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index feae53c54ec..a0e22ad980c 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -1572,7 +1572,7 @@ void MemoryDependenceResults::removeInstruction(Instruction *RemInst) {
ReverseDepMapType::iterator ReverseDepIt = ReverseLocalDeps.find(RemInst);
if (ReverseDepIt != ReverseLocalDeps.end()) {
// RemInst can't be the terminator if it has local stuff depending on it.
- assert(!ReverseDepIt->second.empty() && !isa<TerminatorInst>(RemInst) &&
+ assert(!ReverseDepIt->second.empty() && !RemInst->isTerminator() &&
"Nothing can locally depend on a terminator");
for (Instruction *InstDependingOnRemInst : ReverseDepIt->second) {
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index be44fd04324..a63228ddc03 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -5444,7 +5444,7 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) {
// Set the name on the instruction.
if (PFS.SetInstName(NameID, NameStr, NameLoc, Inst)) return true;
- } while (!isa<TerminatorInst>(Inst));
+ } while (!Inst->isTerminator());
return false;
}
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 48a95970733..11bc6db8ba1 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -4620,7 +4620,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
CurBB->getInstList().push_back(I);
// If this was a terminator instruction, move to the next block.
- if (isa<TerminatorInst>(I)) {
+ if (I->isTerminator()) {
++CurBBNo;
CurBB = CurBBNo < FunctionBBs.size() ? FunctionBBs[CurBBNo] : nullptr;
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
index 60af537b715..ad416017470 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -1577,7 +1577,7 @@ bool FastISel::selectInstruction(const Instruction *I) {
MachineInstr *SavedLastLocalValue = getLastLocalValue();
// Just before the terminator instruction, insert instructions to
// feed PHI nodes in successor blocks.
- if (isa<TerminatorInst>(I)) {
+ if (I->isTerminator()) {
if (!handlePHINodesInSuccessorBlocks(I->getParent())) {
// PHI node handling may have generated local value instructions,
// even though it failed to handle all PHI nodes.
@@ -1641,7 +1641,7 @@ bool FastISel::selectInstruction(const Instruction *I) {
DbgLoc = DebugLoc();
// Undo phi node updates, because they will be added again by SelectionDAG.
- if (isa<TerminatorInst>(I)) {
+ if (I->isTerminator()) {
// PHI node handling may have generated local value instructions.
// We remove them because SelectionDAGISel will generate them again.
removeDeadLocalValueCode(SavedLastLocalValue);
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 896aed04744..0c3a46dc80d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1054,7 +1054,7 @@ SDValue SelectionDAGBuilder::getControlRoot() {
void SelectionDAGBuilder::visit(const Instruction &I) {
// Set up outgoing PHI node register values before emitting the terminator.
- if (isa<TerminatorInst>(&I)) {
+ if (I.isTerminator()) {
HandlePHINodesInSuccessorBlocks(I.getParent());
}
@@ -1082,7 +1082,7 @@ void SelectionDAGBuilder::visit(const Instruction &I) {
}
}
- if (!isa<TerminatorInst>(&I) && !HasTailCall &&
+ if (!I.isTerminator() && !HasTailCall &&
!isStatepoint(&I)) // statepoints handle their exports internally
CopyToExportRegsIfNeeded(&I);
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 8df30fb0349..db4edb162cb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -1171,7 +1171,7 @@ bool SelectionDAGISel::PrepareEHLandingPad() {
static bool isFoldedOrDeadInstruction(const Instruction *I,
FunctionLoweringInfo *FuncInfo) {
return !I->mayWriteToMemory() && // Side-effecting instructions aren't folded.
- !isa<TerminatorInst>(I) && // Terminators aren't folded.
+ !I->isTerminator() && // Terminators aren't folded.
!isa<DbgInfoIntrinsic>(I) && // Debug instructions aren't folded.
!I->isEHPad() && // EH pad instructions aren't folded.
!FuncInfo->isExportedInst(I); // Exported instrs must be computed.
@@ -1688,7 +1688,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) {
Inst->getDebugLoc(), LLVMBB);
bool ShouldAbort = EnableFastISelAbort;
- if (isa<TerminatorInst>(Inst)) {
+ if (Inst->isTerminator()) {
// Use a different message for terminator misses.
R << "FastISel missed terminator";
// Don't abort for terminator unless the level is really high
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp
index 65d0a7a774f..a3243235854 100644
--- a/llvm/lib/CodeGen/WinEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -1074,7 +1074,7 @@ AllocaInst *WinEHPrepare::insertPHILoads(PHINode *PN, Function &F) {
AllocaInst *SpillSlot = nullptr;
Instruction *EHPad = PHIBlock->getFirstNonPHI();
- if (!isa<TerminatorInst>(EHPad)) {
+ if (!EHPad->isTerminator()) {
// If the EHPad isn't a terminator, then we can insert a load in this block
// that will dominate all uses.
SpillSlot = new AllocaInst(PN->getType(), DL->getAllocaAddrSpace(), nullptr,
@@ -1148,8 +1148,7 @@ void WinEHPrepare::insertPHIStore(
BasicBlock *PredBlock, Value *PredVal, AllocaInst *SpillSlot,
SmallVectorImpl<std::pair<BasicBlock *, Value *>> &Worklist) {
- if (PredBlock->isEHPad() &&
- isa<TerminatorInst>(PredBlock->getFirstNonPHI())) {
+ if (PredBlock->isEHPad() && PredBlock->getFirstNonPHI()->isTerminator()) {
// Pred is unsplittable, so we need to queue it on the worklist.
Worklist.push_back({PredBlock, PredVal});
return;
diff --git a/llvm/lib/FuzzMutate/RandomIRBuilder.cpp b/llvm/lib/FuzzMutate/RandomIRBuilder.cpp
index 9f5b7d608a1..33718453555 100644
--- a/llvm/lib/FuzzMutate/RandomIRBuilder.cpp
+++ b/llvm/lib/FuzzMutate/RandomIRBuilder.cpp
@@ -136,7 +136,7 @@ Value *RandomIRBuilder::findPointer(BasicBlock &BB,
auto IsMatchingPtr = [&Srcs, &Pred](Instruction *Inst) {
// Invoke instructions sometimes produce valid pointers but currently
// we can't insert loads or stores from them
- if (isa<TerminatorInst>(Inst))
+ if (Inst->isTerminator())
return false;
if (auto PtrTy = dyn_cast<PointerType>(Inst->getType())) {
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 5441d645b23..75e7413a47d 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -592,7 +592,7 @@ bool Instruction::mayThrow() const {
bool Instruction::isSafeToRemove() const {
return (!isa<CallInst>(this) || !this->mayHaveSideEffects()) &&
- !isa<TerminatorInst>(this);
+ !this->isTerminator();
}
const Instruction *Instruction::getNextNonDebugInstruction() const {
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index cf63b678b61..9d92806a92e 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -546,7 +546,8 @@ static Instruction *insertSpills(SpillInfo &Spills, coro::Shape &Shape) {
} else {
// For all other values, the spill is placed immediately after
// the definition.
- assert(!isa<TerminatorInst>(E.def()) && "unexpected terminator");
+ assert(!cast<Instruction>(E.def())->isTerminator() &&
+ "unexpected terminator");
InsertPt = cast<Instruction>(E.def())->getNextNode();
}
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 49acc5e93a3..2462ae4abd3 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -459,7 +459,7 @@ static bool simplifyTerminatorLeadingToRet(Instruction *InitialInst) {
DenseMap<Value *, Value *> ResolvedValues;
Instruction *I = InitialInst;
- while (isa<TerminatorInst>(I)) {
+ while (I->isTerminator()) {
if (isa<ReturnInst>(I)) {
if (I != InitialInst)
ReplaceInstWithInst(InitialInst, I->clone());
diff --git a/llvm/lib/Transforms/IPO/PruneEH.cpp b/llvm/lib/Transforms/IPO/PruneEH.cpp
index 2be654258aa..2caee294221 100644
--- a/llvm/lib/Transforms/IPO/PruneEH.cpp
+++ b/llvm/lib/Transforms/IPO/PruneEH.cpp
@@ -255,7 +255,7 @@ static void DeleteBasicBlock(BasicBlock *BB, CallGraph &CG) {
}
if (TokenInst) {
- if (!isa<TerminatorInst>(TokenInst))
+ if (!TokenInst->isTerminator())
changeToUnreachable(TokenInst->getNextNode(), /*UseLLVMTrap=*/false);
} else {
// Get the list of successors of this block.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
index 911ece347d3..0289abe472e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
@@ -222,8 +222,11 @@ Instruction *InstCombiner::FoldIntegerTypedPHI(PHINode &PN) {
// instruction, do not do it.
if (std::any_of(AvailablePtrVals.begin(), AvailablePtrVals.end(),
[&](Value *V) {
- return (V->getType() != IntToPtr->getType()) &&
- isa<TerminatorInst>(V);
+ if (V->getType() == IntToPtr->getType())
+ return false;
+
+ auto *Inst = dyn_cast<Instruction>(V);
+ return Inst && Inst->isTerminator();
}))
return nullptr;
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index d7d5b5cc637..99d3d478aaf 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2902,7 +2902,7 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) {
// Cannot move control-flow-involving, volatile loads, vaarg, etc.
if (isa<PHINode>(I) || I->isEHPad() || I->mayHaveSideEffects() ||
- isa<TerminatorInst>(I))
+ I->isTerminator())
return false;
// Do not sink alloca instructions out of the entry block.
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index 89b237c391e..ce06845c668 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -925,7 +925,7 @@ bool DataFlowSanitizer::runOnModule(Module &M) {
Instruction *Next = Inst->getNextNode();
// DFSanVisitor may delete Inst, so keep track of whether it was a
// terminator.
- bool IsTerminator = isa<TerminatorInst>(Inst);
+ bool IsTerminator = Inst->isTerminator();
if (!DFSF.SkipInsts.count(Inst))
DFSanVisitor(DFSF).visit(Inst);
if (IsTerminator)
diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp
index 61c4be854da..883d2e17350 100644
--- a/llvm/lib/Transforms/Scalar/ADCE.cpp
+++ b/llvm/lib/Transforms/Scalar/ADCE.cpp
@@ -331,7 +331,7 @@ bool AggressiveDeadCodeElimination::isAlwaysLive(Instruction &I) {
return false;
return true;
}
- if (!isa<TerminatorInst>(I))
+ if (!I.isTerminator())
return false;
if (RemoveControlFlowFlag && (isa<BranchInst>(I) || isa<SwitchInst>(I)))
return false;
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 61443e301d6..c48e766c797 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -1933,7 +1933,7 @@ bool GVN::processInstruction(Instruction *I) {
// Allocations are always uniquely numbered, so we can save time and memory
// by fast failing them.
- if (isa<AllocaInst>(I) || isa<TerminatorInst>(I) || isa<PHINode>(I)) {
+ if (isa<AllocaInst>(I) || I->isTerminator() || isa<PHINode>(I)) {
addToLeaderTable(Num, I, I->getParent());
return false;
}
@@ -2139,7 +2139,7 @@ bool GVN::performScalarPREInsertion(Instruction *Instr, BasicBlock *Pred,
}
bool GVN::performScalarPRE(Instruction *CurInst) {
- if (isa<AllocaInst>(CurInst) || isa<TerminatorInst>(CurInst) ||
+ if (isa<AllocaInst>(CurInst) || CurInst->isTerminator() ||
isa<PHINode>(CurInst) || CurInst->getType()->isVoidTy() ||
CurInst->mayReadFromMemory() || CurInst->mayHaveSideEffects() ||
isa<DbgInfoIntrinsic>(CurInst))
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
index 485cf72f990..ca19576e8b1 100644
--- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -1100,7 +1100,7 @@ private:
break;
// Do not value number terminator instructions.
- if (isa<TerminatorInst>(&I1))
+ if (I1.isTerminator())
break;
if (auto *Load = dyn_cast<LoadInst>(&I1))
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 4e6bc5cee04..39895dc6187 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -1978,7 +1978,7 @@ bool JumpThreadingPass::ThreadEdge(BasicBlock *BB,
// Clone the non-phi instructions of BB into NewBB, keeping track of the
// mapping and using it to remap operands in the cloned instructions.
- for (; !isa<TerminatorInst>(BI); ++BI) {
+ for (; !BI->isTerminator(); ++BI) {
Instruction *New = BI->clone();
New->setName(BI->getName());
NewBB->getInstList().push_back(New);
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 0e430eab6b2..6e858d61fef 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -398,7 +398,7 @@ Instruction *MemCpyOptPass::tryMergingIntoMemset(Instruction *StartInst,
MemsetRanges Ranges(DL);
BasicBlock::iterator BI(StartInst);
- for (++BI; !isa<TerminatorInst>(BI); ++BI) {
+ for (++BI; !BI->isTerminator(); ++BI) {
if (!isa<StoreInst>(BI) && !isa<MemSetInst>(BI)) {
// If the instruction is readnone, ignore it, otherwise bail out. We
// don't even allow readonly here because we don't want something like:
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 5c2da6c8d23..54fe5fd79d7 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -2925,7 +2925,7 @@ void NewGVN::initializeCongruenceClasses(Function &F) {
PHINodeUses.insert(UInst);
// Don't insert void terminators into the class. We don't value number
// them, and they just end up sitting in TOP.
- if (isa<TerminatorInst>(I) && I.getType()->isVoidTy())
+ if (I.isTerminator() && I.getType()->isVoidTy())
continue;
TOPClass->insert(&I);
ValueToClass[&I] = TOPClass;
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index 9ac10603459..adb70f3c257 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -1784,7 +1784,7 @@ static bool runSCCP(Function &F, const DataLayout &DL,
// constants if we have found them to be of constant values.
for (BasicBlock::iterator BI = BB.begin(), E = BB.end(); BI != E;) {
Instruction *Inst = &*BI++;
- if (Inst->getType()->isVoidTy() || isa<TerminatorInst>(Inst))
+ if (Inst->getType()->isVoidTy() || Inst->isTerminator())
continue;
if (tryToReplaceWithConstant(Solver, Inst)) {
diff --git a/llvm/lib/Transforms/Scalar/Sink.cpp b/llvm/lib/Transforms/Scalar/Sink.cpp
index b59d52f2ecf..d1cdfabb0cc 100644
--- a/llvm/lib/Transforms/Scalar/Sink.cpp
+++ b/llvm/lib/Transforms/Scalar/Sink.cpp
@@ -72,7 +72,7 @@ static bool isSafeToMove(Instruction *Inst, AliasAnalysis &AA,
return false;
}
- if (isa<TerminatorInst>(Inst) || isa<PHINode>(Inst) || Inst->isEHPad() ||
+ if (Inst->isTerminator() || isa<PHINode>(Inst) || Inst->isEHPad() ||
Inst->mayThrow())
return false;
diff --git a/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp b/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
index 56ff03c7f5e..975b363859a 100644
--- a/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
+++ b/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
@@ -90,7 +90,7 @@ AllocaInst *llvm::DemoteRegToStack(Instruction &I, bool VolatileLoads,
// careful if I is an invoke instruction, because we can't insert the store
// AFTER the terminator instruction.
BasicBlock::iterator InsertPt;
- if (!isa<TerminatorInst>(I)) {
+ if (!I.isTerminator()) {
InsertPt = ++I.getIterator();
for (; isa<PHINode>(InsertPt) || InsertPt->isEHPad(); ++InsertPt)
/* empty */; // Don't insert before PHI nodes or landingpad instrs.
diff --git a/llvm/lib/Transforms/Utils/Evaluator.cpp b/llvm/lib/Transforms/Utils/Evaluator.cpp
index 7fd9425efed..992c8b922f7 100644
--- a/llvm/lib/Transforms/Utils/Evaluator.cpp
+++ b/llvm/lib/Transforms/Utils/Evaluator.cpp
@@ -578,7 +578,7 @@ bool Evaluator::EvaluateBlock(BasicBlock::iterator CurInst,
<< "Successfully evaluated function. Result: 0\n\n");
}
}
- } else if (isa<TerminatorInst>(CurInst)) {
+ } else if (CurInst->isTerminator()) {
LLVM_DEBUG(dbgs() << "Found a terminator instruction.\n");
if (BranchInst *BI = dyn_cast<BranchInst>(CurInst)) {
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index e3be924de87..c65a0b7a436 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -354,7 +354,7 @@ bool llvm::isInstructionTriviallyDead(Instruction *I,
bool llvm::wouldInstructionBeTriviallyDead(Instruction *I,
const TargetLibraryInfo *TLI) {
- if (isa<TerminatorInst>(I))
+ if (I->isTerminator())
return false;
// We don't want the landingpad-like instructions removed by anything this
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
index e7319637319..a6320d8dbf4 100644
--- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -326,7 +326,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
// something that might trap, but isn't safe to hoist something that reads
// memory (without proving that the loop doesn't write).
if (L->hasLoopInvariantOperands(Inst) && !Inst->mayReadFromMemory() &&
- !Inst->mayWriteToMemory() && !isa<TerminatorInst>(Inst) &&
+ !Inst->mayWriteToMemory() && !Inst->isTerminator() &&
!isa<DbgInfoIntrinsic>(Inst) && !isa<AllocaInst>(Inst)) {
Inst->moveBefore(LoopEntryBranch);
continue;
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index afc2a863759..1e9193c04ff 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -951,7 +951,7 @@ NextIteration:
if (!Visited.insert(BB).second)
return;
- for (BasicBlock::iterator II = BB->begin(); !isa<TerminatorInst>(II);) {
+ for (BasicBlock::iterator II = BB->begin(); !II->isTerminator();) {
Instruction *I = &*II++; // get the instruction, increment iterator
if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index d0f7be228d2..0d5a522ace3 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1270,7 +1270,7 @@ static bool HoistThenElseCodeToIf(BranchInst *BI,
do {
// If we are hoisting the terminator instruction, don't move one (making a
// broken BB), instead clone it, and remove BI.
- if (isa<TerminatorInst>(I1))
+ if (I1->isTerminator())
goto HoistTerminator;
// If we're going to hoist a call, make sure that the two instructions we're
@@ -2336,8 +2336,7 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI,
IfBlock1 = nullptr;
} else {
DomBlock = *pred_begin(IfBlock1);
- for (BasicBlock::iterator I = IfBlock1->begin(); !isa<TerminatorInst>(I);
- ++I)
+ for (BasicBlock::iterator I = IfBlock1->begin(); !I->isTerminator(); ++I)
if (!AggressiveInsts.count(&*I) && !isa<DbgInfoIntrinsic>(I)) {
// This is not an aggressive instruction that we can promote.
// Because of this, we won't be able to get rid of the control flow, so
@@ -2350,8 +2349,7 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI,
IfBlock2 = nullptr;
} else {
DomBlock = *pred_begin(IfBlock2);
- for (BasicBlock::iterator I = IfBlock2->begin(); !isa<TerminatorInst>(I);
- ++I)
+ for (BasicBlock::iterator I = IfBlock2->begin(); !I->isTerminator(); ++I)
if (!AggressiveInsts.count(&*I) && !isa<DbgInfoIntrinsic>(I)) {
// This is not an aggressive instruction that we can promote.
// Because of this, we won't be able to get rid of the control flow, so
@@ -2922,7 +2920,7 @@ static bool mergeConditionalStoreToAddress(BasicBlock *PTB, BasicBlock *PFB,
isa<StoreInst>(I))
++N;
// Free instructions.
- else if (isa<TerminatorInst>(I) || IsaBitcastOfPointerType(I))
+ else if (I.isTerminator() || IsaBitcastOfPointerType(I))
continue;
else
return false;
diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index a5b31e1ab32..e973bfef4dc 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -703,7 +703,7 @@ bool ReduceCrashingInstructions::TestInsts(
// Convert list to set for fast lookup...
SmallPtrSet<Instruction *, 32> Instructions;
for (unsigned i = 0, e = Insts.size(); i != e; ++i) {
- assert(!isa<TerminatorInst>(Insts[i]));
+ assert(!Insts[i]->isTerminator());
Instructions.insert(cast<Instruction>(VMap[Insts[i]]));
}
@@ -717,7 +717,7 @@ bool ReduceCrashingInstructions::TestInsts(
for (Function::iterator FI = MI->begin(), FE = MI->end(); FI != FE; ++FI)
for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E;) {
Instruction *Inst = &*I++;
- if (!Instructions.count(Inst) && !isa<TerminatorInst>(Inst) &&
+ if (!Instructions.count(Inst) && !Inst->isTerminator() &&
!Inst->isEHPad() && !Inst->getType()->isTokenTy() &&
!Inst->isSwiftError()) {
if (!Inst->getType()->isVoidTy())
@@ -950,7 +950,7 @@ static Error ReduceInsts(BugDriver &BD, BugTester TestFn) {
for (const Function &F : BD.getProgram())
for (const BasicBlock &BB : F)
for (const Instruction &I : BB)
- if (!isa<TerminatorInst>(&I))
+ if (!I.isTerminator())
Insts.push_back(&I);
Expected<bool> Result =
diff --git a/llvm/unittests/Transforms/Utils/Local.cpp b/llvm/unittests/Transforms/Utils/Local.cpp
index bb36d013357..9dc920d0938 100644
--- a/llvm/unittests/Transforms/Utils/Local.cpp
+++ b/llvm/unittests/Transforms/Utils/Local.cpp
@@ -552,7 +552,7 @@ struct SalvageDebugInfoTest : ::testing::Test {
auto DI = dyn_cast<DbgValueInst>(&I);
if (!DI) {
// The function should only contain debug values and a terminator.
- ASSERT_TRUE(isa<TerminatorInst>(&I));
+ ASSERT_TRUE(I.isTerminator());
continue;
}
EXPECT_EQ(DI->getVariable()->getName(), "x");
OpenPOWER on IntegriCloud