[llvm] r340701 - [IR] Replace `isa<TerminatorInst>` with `isTerminator()`.
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 26 02:51:23 PDT 2018
Author: chandlerc
Date: Sun Aug 26 02:51:22 2018
New Revision: 340701
URL: http://llvm.org/viewvc/llvm-project?rev=340701&view=rev
Log:
[IR] Replace `isa<TerminatorInst>` with `isTerminator()`.
This is a bit awkward in a handful of places where we didn't even have
an instruction and now we have to see if we can build one. But on the
whole, this seems like a win and at worst a reasonable cost for removing
`TerminatorInst`.
All of this is part of the removal of `TerminatorInst` from the
`Instruction` type hierarchy.
Modified:
llvm/trunk/docs/CodingStandards.rst
llvm/trunk/include/llvm/IR/CFG.h
llvm/trunk/lib/Analysis/CFLGraph.h
llvm/trunk/lib/Analysis/DemandedBits.cpp
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
llvm/trunk/lib/FuzzMutate/RandomIRBuilder.cpp
llvm/trunk/lib/IR/Instruction.cpp
llvm/trunk/lib/Transforms/Coroutines/CoroFrame.cpp
llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/trunk/lib/Transforms/IPO/PruneEH.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
llvm/trunk/lib/Transforms/Scalar/Sink.cpp
llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp
llvm/trunk/lib/Transforms/Utils/Evaluator.cpp
llvm/trunk/lib/Transforms/Utils/Local.cpp
llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp
llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/trunk/tools/bugpoint/CrashDebugger.cpp
llvm/trunk/unittests/Transforms/Utils/Local.cpp
Modified: llvm/trunk/docs/CodingStandards.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CodingStandards.rst?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/docs/CodingStandards.rst (original)
+++ llvm/trunk/docs/CodingStandards.rst Sun Aug 26 02:51:22 2018
@@ -955,7 +955,7 @@ exit from a function, consider this "bad
.. 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
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
Modified: llvm/trunk/include/llvm/IR/CFG.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/CFG.h?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/CFG.h (original)
+++ llvm/trunk/include/llvm/IR/CFG.h Sun Aug 26 02:51:22 2018
@@ -49,8 +49,13 @@ class PredIterator : public std::iterato
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:
Modified: llvm/trunk/lib/Analysis/CFLGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CFLGraph.h?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CFLGraph.h (original)
+++ llvm/trunk/lib/Analysis/CFLGraph.h Sun Aug 26 02:51:22 2018
@@ -594,7 +594,7 @@ template <typename CFLAA> class CFLGraph
// 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) &&
Modified: llvm/trunk/lib/Analysis/DemandedBits.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DemandedBits.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DemandedBits.cpp (original)
+++ llvm/trunk/lib/Analysis/DemandedBits.cpp Sun Aug 26 02:51:22 2018
@@ -78,8 +78,8 @@ void DemandedBitsWrapperPass::print(raw_
}
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(
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Sun Aug 26 02:51:22 2018
@@ -5165,7 +5165,7 @@ static bool replaceAndRecursivelySimplif
// 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 replaceAndRecursivelySimplif
// 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();
}
Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Sun Aug 26 02:51:22 2018
@@ -1572,7 +1572,7 @@ void MemoryDependenceResults::removeInst
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) {
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Sun Aug 26 02:51:22 2018
@@ -5444,7 +5444,7 @@ bool LLParser::ParseBasicBlock(PerFuncti
// Set the name on the instruction.
if (PFS.SetInstName(NameID, NameStr, NameLoc, Inst)) return true;
- } while (!isa<TerminatorInst>(Inst));
+ } while (!Inst->isTerminator());
return false;
}
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Sun Aug 26 02:51:22 2018
@@ -4620,7 +4620,7 @@ Error BitcodeReader::parseFunctionBody(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;
}
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Sun Aug 26 02:51:22 2018
@@ -1577,7 +1577,7 @@ bool FastISel::selectInstruction(const 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 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);
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Sun Aug 26 02:51:22 2018
@@ -1054,7 +1054,7 @@ SDValue SelectionDAGBuilder::getControlR
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 In
}
}
- if (!isa<TerminatorInst>(&I) && !HasTailCall &&
+ if (!I.isTerminator() && !HasTailCall &&
!isStatepoint(&I)) // statepoints handle their exports internally
CopyToExportRegsIfNeeded(&I);
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Aug 26 02:51:22 2018
@@ -1171,7 +1171,7 @@ bool SelectionDAGISel::PrepareEHLandingP
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::SelectAllBasicBlo
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
Modified: llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/WinEHPrepare.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/WinEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/WinEHPrepare.cpp Sun Aug 26 02:51:22 2018
@@ -1074,7 +1074,7 @@ AllocaInst *WinEHPrepare::insertPHILoads
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;
Modified: llvm/trunk/lib/FuzzMutate/RandomIRBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/FuzzMutate/RandomIRBuilder.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/FuzzMutate/RandomIRBuilder.cpp (original)
+++ llvm/trunk/lib/FuzzMutate/RandomIRBuilder.cpp Sun Aug 26 02:51:22 2018
@@ -136,7 +136,7 @@ Value *RandomIRBuilder::findPointer(Basi
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())) {
Modified: llvm/trunk/lib/IR/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instruction.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instruction.cpp (original)
+++ llvm/trunk/lib/IR/Instruction.cpp Sun Aug 26 02:51:22 2018
@@ -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 {
Modified: llvm/trunk/lib/Transforms/Coroutines/CoroFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/CoroFrame.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/CoroFrame.cpp (original)
+++ llvm/trunk/lib/Transforms/Coroutines/CoroFrame.cpp Sun Aug 26 02:51:22 2018
@@ -546,7 +546,8 @@ static Instruction *insertSpills(SpillIn
} 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();
}
Modified: llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp Sun Aug 26 02:51:22 2018
@@ -459,7 +459,7 @@ static bool simplifyTerminatorLeadingToR
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());
Modified: llvm/trunk/lib/Transforms/IPO/PruneEH.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PruneEH.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PruneEH.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PruneEH.cpp Sun Aug 26 02:51:22 2018
@@ -255,7 +255,7 @@ static void DeleteBasicBlock(BasicBlock
}
if (TokenInst) {
- if (!isa<TerminatorInst>(TokenInst))
+ if (!TokenInst->isTerminator())
changeToUnreachable(TokenInst->getNextNode(), /*UseLLVMTrap=*/false);
} else {
// Get the list of successors of this block.
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp Sun Aug 26 02:51:22 2018
@@ -222,8 +222,11 @@ Instruction *InstCombiner::FoldIntegerTy
// 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;
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Sun Aug 26 02:51:22 2018
@@ -2902,7 +2902,7 @@ static bool TryToSinkInstruction(Instruc
// 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.
Modified: llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp Sun Aug 26 02:51:22 2018
@@ -925,7 +925,7 @@ bool DataFlowSanitizer::runOnModule(Modu
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)
Modified: llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ADCE.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ADCE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ADCE.cpp Sun Aug 26 02:51:22 2018
@@ -331,7 +331,7 @@ bool AggressiveDeadCodeElimination::isAl
return false;
return true;
}
- if (!isa<TerminatorInst>(I))
+ if (!I.isTerminator())
return false;
if (RemoveControlFlowFlag && (isa<BranchInst>(I) || isa<SwitchInst>(I)))
return false;
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Sun Aug 26 02:51:22 2018
@@ -1933,7 +1933,7 @@ bool GVN::processInstruction(Instruction
// 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(Inst
}
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))
Modified: llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp Sun Aug 26 02:51:22 2018
@@ -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))
Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sun Aug 26 02:51:22 2018
@@ -1978,7 +1978,7 @@ bool JumpThreadingPass::ThreadEdge(Basic
// 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);
Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Sun Aug 26 02:51:22 2018
@@ -398,7 +398,7 @@ Instruction *MemCpyOptPass::tryMergingIn
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:
Modified: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Sun Aug 26 02:51:22 2018
@@ -2925,7 +2925,7 @@ void NewGVN::initializeCongruenceClasses
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;
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Sun Aug 26 02:51:22 2018
@@ -1784,7 +1784,7 @@ static bool runSCCP(Function &F, const D
// 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)) {
Modified: llvm/trunk/lib/Transforms/Scalar/Sink.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Sink.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Sink.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Sink.cpp Sun Aug 26 02:51:22 2018
@@ -72,7 +72,7 @@ static bool isSafeToMove(Instruction *In
return false;
}
- if (isa<TerminatorInst>(Inst) || isa<PHINode>(Inst) || Inst->isEHPad() ||
+ if (Inst->isTerminator() || isa<PHINode>(Inst) || Inst->isEHPad() ||
Inst->mayThrow())
return false;
Modified: llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp Sun Aug 26 02:51:22 2018
@@ -90,7 +90,7 @@ AllocaInst *llvm::DemoteRegToStack(Instr
// 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.
Modified: llvm/trunk/lib/Transforms/Utils/Evaluator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Evaluator.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Evaluator.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Evaluator.cpp Sun Aug 26 02:51:22 2018
@@ -578,7 +578,7 @@ bool Evaluator::EvaluateBlock(BasicBlock
<< "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)) {
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Sun Aug 26 02:51:22 2018
@@ -354,7 +354,7 @@ bool llvm::isInstructionTriviallyDead(In
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
Modified: llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp Sun Aug 26 02:51:22 2018
@@ -326,7 +326,7 @@ bool LoopRotate::rotateLoop(Loop *L, boo
// 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;
Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Sun Aug 26 02:51:22 2018
@@ -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)) {
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Sun Aug 26 02:51:22 2018
@@ -1270,7 +1270,7 @@ static bool HoistThenElseCodeToIf(Branch
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
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
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 mergeConditionalStoreToAddre
isa<StoreInst>(I))
++N;
// Free instructions.
- else if (isa<TerminatorInst>(I) || IsaBitcastOfPointerType(I))
+ else if (I.isTerminator() || IsaBitcastOfPointerType(I))
continue;
else
return false;
Modified: llvm/trunk/tools/bugpoint/CrashDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/CrashDebugger.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/CrashDebugger.cpp (original)
+++ llvm/trunk/tools/bugpoint/CrashDebugger.cpp Sun Aug 26 02:51:22 2018
@@ -703,7 +703,7 @@ bool ReduceCrashingInstructions::TestIns
// 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::TestIns
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,
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 =
Modified: llvm/trunk/unittests/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Utils/Local.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/unittests/Transforms/Utils/Local.cpp Sun Aug 26 02:51:22 2018
@@ -552,7 +552,7 @@ struct SalvageDebugInfoTest : ::testing:
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");
More information about the llvm-commits
mailing list