From edb12a838a22f212d7bee970ff637192f7ea8576 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 15 Oct 2018 10:04:59 +0000 Subject: [PATCH] [TI removal] Make variables declared as `TerminatorInst` and initialized by `getTerminator()` calls instead be declared as `Instruction`. This is the biggest remaining chunk of the usage of `getTerminator()` that insists on the narrow type and so is an easy batch of updates. Several files saw more extensive updates where this would cascade to requiring API updates within the file to use `Instruction` instead of `TerminatorInst`. All of these were trivial in nature (pervasively using `Instruction` instead just worked). llvm-svn: 344502 --- llvm/lib/Analysis/BranchProbabilityInfo.cpp | 10 +-- llvm/lib/Analysis/CFG.cpp | 2 +- llvm/lib/Analysis/EHPersonalities.cpp | 2 +- llvm/lib/Analysis/InlineCost.cpp | 2 +- llvm/lib/Analysis/LoopInfo.cpp | 4 +- llvm/lib/Analysis/MemorySSAUpdater.cpp | 2 +- llvm/lib/Analysis/ScalarEvolution.cpp | 2 +- llvm/lib/CodeGen/Analysis.cpp | 2 +- llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 2 +- .../SelectionDAG/SelectionDAGBuilder.cpp | 2 +- .../CodeGen/SelectionDAG/SelectionDAGISel.cpp | 2 +- llvm/lib/CodeGen/WinEHPrepare.cpp | 4 +- llvm/lib/IR/BasicBlock.cpp | 4 +- llvm/lib/IR/Dominators.cpp | 2 +- llvm/lib/IR/SafepointIRVerifier.cpp | 2 +- llvm/lib/IR/Verifier.cpp | 2 +- .../Target/AMDGPU/SIAnnotateControlFlow.cpp | 2 +- llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.cpp | 2 +- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp | 2 +- .../WebAssemblyLowerEmscriptenEHSjLj.cpp | 2 +- llvm/lib/Target/X86/X86WinEHState.cpp | 2 +- llvm/lib/Transforms/IPO/HotColdSplitting.cpp | 2 +- llvm/lib/Transforms/IPO/LoopExtractor.cpp | 4 +- llvm/lib/Transforms/IPO/PartialInlining.cpp | 2 +- llvm/lib/Transforms/IPO/PruneEH.cpp | 2 +- llvm/lib/Transforms/IPO/SampleProfile.cpp | 2 +- .../InstCombine/InstCombineCalls.cpp | 2 +- .../Transforms/InstCombine/InstCombinePHI.cpp | 4 +- .../InstCombine/InstructionCombining.cpp | 4 +- llvm/lib/Transforms/Instrumentation/CFGMST.h | 2 +- .../Instrumentation/GCOVProfiling.cpp | 6 +- .../Instrumentation/PGOInstrumentation.cpp | 8 +- llvm/lib/Transforms/Scalar/ADCE.cpp | 8 +- .../Transforms/Scalar/CallSiteSplitting.cpp | 2 +- .../Scalar/DeadStoreElimination.cpp | 2 +- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp | 2 +- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | 21 +++-- .../lib/Transforms/Scalar/PlaceSafepoints.cpp | 6 +- .../Scalar/RewriteStatepointsForGC.cpp | 12 +-- llvm/lib/Transforms/Scalar/SCCP.cpp | 2 +- llvm/lib/Transforms/Scalar/SROA.cpp | 4 +- .../Transforms/Scalar/SimpleLoopUnswitch.cpp | 2 +- llvm/lib/Transforms/Scalar/StructurizeCFG.cpp | 2 +- .../Scalar/TailRecursionElimination.cpp | 2 +- .../Transforms/Utils/BreakCriticalEdges.cpp | 2 +- llvm/lib/Transforms/Utils/CloneFunction.cpp | 4 +- llvm/lib/Transforms/Utils/CodeExtractor.cpp | 8 +- .../lib/Transforms/Utils/EscapeEnumerator.cpp | 2 +- llvm/lib/Transforms/Utils/FlattenCFG.cpp | 6 +- .../Transforms/Utils/FunctionComparator.cpp | 6 +- llvm/lib/Transforms/Utils/InlineFunction.cpp | 2 +- llvm/lib/Transforms/Utils/Local.cpp | 6 +- .../Transforms/Utils/LoopRotationUtils.cpp | 2 +- llvm/lib/Transforms/Utils/LoopSimplify.cpp | 4 +- llvm/lib/Transforms/Utils/LoopUnroll.cpp | 2 +- .../lib/Transforms/Utils/LoopUnrollAndJam.cpp | 2 +- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 80 +++++++++---------- .../Transforms/Vectorize/VPlanHCFGBuilder.cpp | 2 +- 58 files changed, 143 insertions(+), 144 deletions(-) diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index 54a657073f0f..7f544b27fe9d 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -135,7 +135,7 @@ static const uint32_t IH_NONTAKEN_WEIGHT = 1; /// Add \p BB to PostDominatedByUnreachable set if applicable. void BranchProbabilityInfo::updatePostDominatedByUnreachable(const BasicBlock *BB) { - const TerminatorInst *TI = BB->getTerminator(); + const Instruction *TI = BB->getTerminator(); if (TI->getNumSuccessors() == 0) { if (isa(TI) || // If this block is terminated by a call to @@ -167,7 +167,7 @@ BranchProbabilityInfo::updatePostDominatedByUnreachable(const BasicBlock *BB) { void BranchProbabilityInfo::updatePostDominatedByColdCall(const BasicBlock *BB) { assert(!PostDominatedByColdCall.count(BB)); - const TerminatorInst *TI = BB->getTerminator(); + const Instruction *TI = BB->getTerminator(); if (TI->getNumSuccessors() == 0) return; @@ -202,7 +202,7 @@ BranchProbabilityInfo::updatePostDominatedByColdCall(const BasicBlock *BB) { /// Predict that a successor which leads necessarily to an /// unreachable-terminated block as extremely unlikely. bool BranchProbabilityInfo::calcUnreachableHeuristics(const BasicBlock *BB) { - const TerminatorInst *TI = BB->getTerminator(); + const Instruction *TI = BB->getTerminator(); (void) TI; assert(TI->getNumSuccessors() > 1 && "expected more than one successor!"); assert(!isa(TI) && @@ -246,7 +246,7 @@ bool BranchProbabilityInfo::calcUnreachableHeuristics(const BasicBlock *BB) { // heuristic. The probability of the edge coming to unreachable block is // set to min of metadata and unreachable heuristic. bool BranchProbabilityInfo::calcMetadataWeights(const BasicBlock *BB) { - const TerminatorInst *TI = BB->getTerminator(); + const Instruction *TI = BB->getTerminator(); assert(TI->getNumSuccessors() > 1 && "expected more than one successor!"); if (!(isa(TI) || isa(TI) || isa(TI))) return false; @@ -348,7 +348,7 @@ bool BranchProbabilityInfo::calcMetadataWeights(const BasicBlock *BB) { /// Return true if we could compute the weights for cold edges. /// Return false, otherwise. bool BranchProbabilityInfo::calcColdCallHeuristics(const BasicBlock *BB) { - const TerminatorInst *TI = BB->getTerminator(); + const Instruction *TI = BB->getTerminator(); (void) TI; assert(TI->getNumSuccessors() > 1 && "expected more than one successor!"); assert(!isa(TI) && diff --git a/llvm/lib/Analysis/CFG.cpp b/llvm/lib/Analysis/CFG.cpp index aaea59954297..aa880a62b754 100644 --- a/llvm/lib/Analysis/CFG.cpp +++ b/llvm/lib/Analysis/CFG.cpp @@ -71,7 +71,7 @@ void llvm::FindFunctionBackedges(const Function &F, /// successor. unsigned llvm::GetSuccessorNumber(const BasicBlock *BB, const BasicBlock *Succ) { - const TerminatorInst *Term = BB->getTerminator(); + const Instruction *Term = BB->getTerminator(); #ifndef NDEBUG unsigned e = Term->getNumSuccessors(); #endif diff --git a/llvm/lib/Analysis/EHPersonalities.cpp b/llvm/lib/Analysis/EHPersonalities.cpp index 2d35a3fa9118..0df73aeebbdc 100644 --- a/llvm/lib/Analysis/EHPersonalities.cpp +++ b/llvm/lib/Analysis/EHPersonalities.cpp @@ -120,7 +120,7 @@ DenseMap llvm::colorEHFunclets(Function &F) { << "\'.\n"); BasicBlock *SuccColor = Color; - TerminatorInst *Terminator = Visiting->getTerminator(); + Instruction *Terminator = Visiting->getTerminator(); if (auto *CatchRet = dyn_cast(Terminator)) { Value *ParentPad = CatchRet->getCatchSwitchParentPad(); if (isa(ParentPad)) diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index fb032e0404cb..1b5150a0d188 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -1831,7 +1831,7 @@ InlineResult CallAnalyzer::analyzeCall(CallSite CS) { if (!IR) return IR; - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); // Add in the live successors by first checking whether we have terminator // that may be simplified based on the values simplified by this call. diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 99ff25a3fd37..4b174b66d1e1 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -219,7 +219,7 @@ MDNode *Loop::getLoopID() const { SmallVector LatchesBlocks; getLoopLatches(LatchesBlocks); for (BasicBlock *BB : LatchesBlocks) { - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); MDNode *MD = TI->getMetadata(LLVMContext::MD_loop); if (!MD) @@ -250,7 +250,7 @@ void Loop::setLoopID(MDNode *LoopID) const { "The loop should have no single latch at this point"); BasicBlock *H = getHeader(); for (BasicBlock *BB : this->blocks()) { - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); for (BasicBlock *Successor : successors(TI)) { if (Successor == H) TI->setMetadata(LLVMContext::MD_loop, LoopID); diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp index 51a5733a3efd..880dc2f27852 100644 --- a/llvm/lib/Analysis/MemorySSAUpdater.cpp +++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp @@ -1104,7 +1104,7 @@ void MemorySSAUpdater::removeBlocks( const SmallPtrSetImpl &DeadBlocks) { // First delete all uses of BB in MemoryPhis. for (BasicBlock *BB : DeadBlocks) { - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); assert(TI && "Basic block expected to have a terminator instruction"); for (BasicBlock *Succ : successors(TI)) if (!DeadBlocks.count(Succ)) diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 193020ed92fc..4a30447f6471 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -7078,7 +7078,7 @@ ScalarEvolution::computeExitLimit(const Loop *L, BasicBlock *ExitingBlock, return getCouldNotCompute(); bool IsOnlyExit = (L->getExitingBlock() != nullptr); - TerminatorInst *Term = ExitingBlock->getTerminator(); + Instruction *Term = ExitingBlock->getTerminator(); if (BranchInst *BI = dyn_cast(Term)) { assert(BI->isConditional() && "If unconditional, it can't be in loop!"); bool ExitIfTrue = !L->contains(BI->getSuccessor(0)); diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp index b769e92590f0..aae04a573af8 100644 --- a/llvm/lib/CodeGen/Analysis.cpp +++ b/llvm/lib/CodeGen/Analysis.cpp @@ -471,7 +471,7 @@ static bool nextRealType(SmallVectorImpl &SubTypes, bool llvm::isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM) { const Instruction *I = CS.getInstruction(); const BasicBlock *ExitBB = I->getParent(); - const TerminatorInst *Term = ExitBB->getTerminator(); + const Instruction *Term = ExitBB->getTerminator(); const ReturnInst *Ret = dyn_cast(Term); // The block must end in a return statement or unreachable. diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index ad416017470d..542cc10371e3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -2223,7 +2223,7 @@ unsigned FastISel::fastEmitZExtFromI1(MVT VT, unsigned Op0, bool Op0IsKill) { /// might result in multiple MBB's for one BB. As such, the start of the /// BB might correspond to a different MBB than the end. bool FastISel::handlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) { - const TerminatorInst *TI = LLVMBB->getTerminator(); + const Instruction *TI = LLVMBB->getTerminator(); SmallPtrSet SuccsHandled; FuncInfo.OrigNumPHINodesToUpdate = FuncInfo.PHINodesToUpdate.size(); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index f7866665bcba..1a99ef734f13 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -9249,7 +9249,7 @@ void SelectionDAGISel::LowerArguments(const Function &F) { /// the end. void SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) { - const TerminatorInst *TI = LLVMBB->getTerminator(); + const Instruction *TI = LLVMBB->getTerminator(); SmallPtrSet SuccsHandled; diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index feb57eeafe7d..2b4a590f19f2 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -451,7 +451,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { if (!succ_empty(&BB)) continue; - const TerminatorInst *Term = BB.getTerminator(); + const Instruction *Term = BB.getTerminator(); if (isa(Term) || isa(Term)) continue; diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp index a3243235854f..6a15240fa6e0 100644 --- a/llvm/lib/CodeGen/WinEHPrepare.cpp +++ b/llvm/lib/CodeGen/WinEHPrepare.cpp @@ -218,7 +218,7 @@ static void calculateStateNumbersForInvokes(const Function *Fn, // to. If the unwind edge came from an invoke, return null. static const BasicBlock *getEHPadFromPredecessor(const BasicBlock *BB, Value *ParentPad) { - const TerminatorInst *TI = BB->getTerminator(); + const Instruction *TI = BB->getTerminator(); if (isa(TI)) return nullptr; if (auto *CatchSwitch = dyn_cast(TI)) { @@ -977,7 +977,7 @@ void WinEHPrepare::removeImplausibleInstructions(Function &F) { break; } - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); // CatchPadInst and CleanupPadInst can't transfer control to a ReturnInst. bool IsUnreachableRet = isa(TI) && FuncletPad; // The token consumed by a CatchReturnInst must match the funclet token. diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp index d04af9261e3c..03fb5ccaffc3 100644 --- a/llvm/lib/IR/BasicBlock.cpp +++ b/llvm/lib/IR/BasicBlock.cpp @@ -437,7 +437,7 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) { } void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *New) { - TerminatorInst *TI = getTerminator(); + Instruction *TI = getTerminator(); if (!TI) // Cope with being called on a BasicBlock that doesn't have a terminator // yet. Clang's CodeGenFunction::EmitReturnBlock() likes to do this. @@ -468,7 +468,7 @@ const LandingPadInst *BasicBlock::getLandingPadInst() const { } Optional BasicBlock::getIrrLoopHeaderWeight() const { - const TerminatorInst *TI = getTerminator(); + const Instruction *TI = getTerminator(); if (MDNode *MDIrrLoopHeader = TI->getMetadata(LLVMContext::MD_irr_loop)) { MDString *MDName = cast(MDIrrLoopHeader->getOperand(0)); diff --git a/llvm/lib/IR/Dominators.cpp b/llvm/lib/IR/Dominators.cpp index c78f220439af..cf9f5759ba53 100644 --- a/llvm/lib/IR/Dominators.cpp +++ b/llvm/lib/IR/Dominators.cpp @@ -41,7 +41,7 @@ static constexpr bool ExpensiveChecksEnabled = false; #endif bool BasicBlockEdge::isSingleEdge() const { - const TerminatorInst *TI = Start->getTerminator(); + const Instruction *TI = Start->getTerminator(); unsigned NumEdgesToEnd = 0; for (unsigned int i = 0, n = TI->getNumSuccessors(); i < n; ++i) { if (TI->getSuccessor(i) == End) diff --git a/llvm/lib/IR/SafepointIRVerifier.cpp b/llvm/lib/IR/SafepointIRVerifier.cpp index 7af48f5301f7..d2102138d799 100644 --- a/llvm/lib/IR/SafepointIRVerifier.cpp +++ b/llvm/lib/IR/SafepointIRVerifier.cpp @@ -134,7 +134,7 @@ public: // Top-down walk of the dominator tree ReversePostOrderTraversal RPOT(&F); for (const BasicBlock *BB : RPOT) { - const TerminatorInst *TI = BB->getTerminator(); + const Instruction *TI = BB->getTerminator(); assert(TI && "blocks must be well formed"); // For conditional branches, we can perform simple conditional propagation on diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 8304ec6e8f4a..d96555ca5f9a 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3450,7 +3450,7 @@ void Verifier::visitEHPadPredecessors(Instruction &I) { Instruction *ToPad = &I; Value *ToPadParent = getParentPad(ToPad); for (BasicBlock *PredBB : predecessors(BB)) { - TerminatorInst *TI = PredBB->getTerminator(); + Instruction *TI = PredBB->getTerminator(); Value *FromPad; if (auto *II = dyn_cast(TI)) { Assert(II->getUnwindDest() == BB && II->getNormalDest() != BB, diff --git a/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp b/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp index c52313f84ef0..8248dbe1b0fd 100644 --- a/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp +++ b/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp @@ -288,7 +288,7 @@ Value *SIAnnotateControlFlow::handleLoopCondition( } } - TerminatorInst *Insert = From->getTerminator(); + Instruction *Insert = From->getTerminator(); Value *PhiArg = CallInst::Create(Break, Broken, "", Insert); NewPhi->setIncomingValue(i, PhiArg); } diff --git a/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.cpp b/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.cpp index bed52293197d..bf922eb8a195 100644 --- a/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.cpp @@ -41,7 +41,7 @@ public: bool NVPTXAllocaHoisting::runOnFunction(Function &function) { bool functionModified = false; Function::iterator I = function.begin(); - TerminatorInst *firstTerminatorInst = (I++)->getTerminator(); + Instruction *firstTerminatorInst = (I++)->getTerminator(); for (Function::iterator E = function.end(); I != E; ++I) { for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE;) { diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index 5ec7b1028841..8861de6f0d89 100644 --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -490,7 +490,7 @@ static unsigned getBranchHint(unsigned PCC, FunctionLoweringInfo *FuncInfo, if (!FuncInfo->BPI) return PPC::BR_NO_HINT; const BasicBlock *BB = FuncInfo->MBB->getBasicBlock(); - const TerminatorInst *BBTerm = BB->getTerminator(); + const Instruction *BBTerm = BB->getTerminator(); if (BBTerm->getNumSuccessors() != 2) return PPC::BR_NO_HINT; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp index b5a88129c6b7..f0d24075801f 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp @@ -1030,7 +1030,7 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runSjLjOnFunction(Function &F) { // Free setjmpTable buffer before each return instruction for (BasicBlock &BB : F) { - TerminatorInst *TI = BB.getTerminator(); + Instruction *TI = BB.getTerminator(); if (isa(TI)) CallInst::CreateFree(SetjmpTable, TI); } diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp b/llvm/lib/Target/X86/X86WinEHState.cpp index dde9c734f492..c11e7e365a10 100644 --- a/llvm/lib/Target/X86/X86WinEHState.cpp +++ b/llvm/lib/Target/X86/X86WinEHState.cpp @@ -369,7 +369,7 @@ void WinEHStatePass::emitExceptionRegistrationRecord(Function *F) { // Insert an unlink before all returns. for (BasicBlock &BB : *F) { - TerminatorInst *T = BB.getTerminator(); + Instruction *T = BB.getTerminator(); if (!isa(T)) continue; Builder.SetInsertPoint(T); diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp index 810fdf418a28..9d2634f1bc97 100644 --- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp +++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp @@ -104,7 +104,7 @@ static bool isSingleEntrySingleExit(BasicBlock *Entry, const BasicBlock *Exit, bool blockEndsInUnreachable(const BasicBlock &BB) { if (BB.empty()) return true; - const TerminatorInst *I = BB.getTerminator(); + const Instruction *I = BB.getTerminator(); if (isa(I) || isa(I)) return true; // Unreachable blocks do not have any successor. diff --git a/llvm/lib/Transforms/IPO/LoopExtractor.cpp b/llvm/lib/Transforms/IPO/LoopExtractor.cpp index 8c86f7cb806a..733235d45a09 100644 --- a/llvm/lib/Transforms/IPO/LoopExtractor.cpp +++ b/llvm/lib/Transforms/IPO/LoopExtractor.cpp @@ -104,8 +104,8 @@ bool LoopExtractor::runOnLoop(Loop *L, LPPassManager &LPM) { bool ShouldExtractLoop = false; // Extract the loop if the entry block doesn't branch to the loop header. - TerminatorInst *EntryTI = - L->getHeader()->getParent()->getEntryBlock().getTerminator(); + Instruction *EntryTI = + L->getHeader()->getParent()->getEntryBlock().getTerminator(); if (!isa(EntryTI) || !cast(EntryTI)->isUnconditional() || EntryTI->getSuccessor(0) != L->getHeader()) { diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp index 709222dbec00..11c4bbc437c1 100644 --- a/llvm/lib/Transforms/IPO/PartialInlining.cpp +++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp @@ -556,7 +556,7 @@ PartialInlinerImpl::computeOutliningInfo(Function *F) { }; auto IsReturnBlock = [](BasicBlock *BB) { - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); return isa(TI); }; diff --git a/llvm/lib/Transforms/IPO/PruneEH.cpp b/llvm/lib/Transforms/IPO/PruneEH.cpp index 2caee2942213..ae586c017471 100644 --- a/llvm/lib/Transforms/IPO/PruneEH.cpp +++ b/llvm/lib/Transforms/IPO/PruneEH.cpp @@ -107,7 +107,7 @@ static bool runImpl(CallGraphSCC &SCC, CallGraph &CG) { continue; for (const BasicBlock &BB : *F) { - const TerminatorInst *TI = BB.getTerminator(); + const Instruction *TI = BB.getTerminator(); if (CheckUnwind && TI->mayThrow()) { SCCMightUnwind = true; } else if (CheckReturn && isa(TI)) { diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp index 4a69a0c28068..a78e0d459c89 100644 --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -1297,7 +1297,7 @@ void SampleProfileLoader::propagateWeights(Function &F) { } } } - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); if (TI->getNumSuccessors() == 1) continue; if (!isa(TI) && !isa(TI)) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 714c61768840..6d2ac2274de7 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -3732,7 +3732,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { // Scan down this block to see if there is another stack restore in the // same block without an intervening call/alloca. BasicBlock::iterator BI(II); - TerminatorInst *TI = II->getParent()->getTerminator(); + Instruction *TI = II->getParent()->getTerminator(); bool CannotRemove = false; for (++BI; &*BI != TI; ++BI) { if (isa(BI)) { diff --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp index 0289abe472e8..94745094c15c 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp @@ -652,7 +652,7 @@ Instruction *InstCombiner::FoldPHIArgLoadIntoPHI(PHINode &PN) { Instruction *InstCombiner::FoldPHIArgZextsIntoPHI(PHINode &Phi) { // We cannot create a new instruction after the PHI if the terminator is an // EHPad because there is no valid insertion point. - if (TerminatorInst *TI = Phi.getParent()->getTerminator()) + if (Instruction *TI = Phi.getParent()->getTerminator()) if (TI->isEHPad()) return nullptr; @@ -726,7 +726,7 @@ Instruction *InstCombiner::FoldPHIArgZextsIntoPHI(PHINode &Phi) { Instruction *InstCombiner::FoldPHIArgOpIntoPHI(PHINode &PN) { // We cannot create a new instruction after the PHI if the terminator is an // EHPad because there is no valid insertion point. - if (TerminatorInst *TI = PN.getParent()->getTerminator()) + if (Instruction *TI = PN.getParent()->getTerminator()) if (TI->isEHPad()) return nullptr; diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 00ffe9e2dc22..ae7d08149c64 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2347,7 +2347,7 @@ tryToMoveFreeBeforeNullTest(CallInst &FI) { return nullptr; // Validate the rest of constraint #1 by matching on the pred branch. - TerminatorInst *TI = PredBB->getTerminator(); + Instruction *TI = PredBB->getTerminator(); BasicBlock *TrueBB, *FalseBB; ICmpInst::Predicate Pred; if (!match(TI, m_Br(m_ICmp(Pred, m_Specific(Op), m_Zero()), TrueBB, FalseBB))) @@ -3285,7 +3285,7 @@ static bool AddReachableCodeToWorklist(BasicBlock *BB, const DataLayout &DL, // Recursively visit successors. If this is a branch or switch on a // constant, only visit the reachable successor. - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); if (BranchInst *BI = dyn_cast(TI)) { if (BI->isConditional() && isa(BI->getCondition())) { bool CondVal = cast(BI->getCondition())->getZExtValue(); diff --git a/llvm/lib/Transforms/Instrumentation/CFGMST.h b/llvm/lib/Transforms/Instrumentation/CFGMST.h index cc9b149d0b6a..e178ef386e68 100644 --- a/llvm/lib/Transforms/Instrumentation/CFGMST.h +++ b/llvm/lib/Transforms/Instrumentation/CFGMST.h @@ -119,7 +119,7 @@ public: static const uint32_t CriticalEdgeMultiplier = 1000; for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); uint64_t BBWeight = (BFI != nullptr ? BFI->getBlockFreq(&*BB).getFrequency() : 2); uint64_t Weight = 2; diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp index a060dd535139..ee546a9a8289 100644 --- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -578,7 +578,7 @@ void GCOVProfiler::emitProfileNotes() { for (auto &BB : F) { GCOVBlock &Block = Func.getBlock(&BB); - TerminatorInst *TI = BB.getTerminator(); + Instruction *TI = BB.getTerminator(); if (int successors = TI->getNumSuccessors()) { for (int i = 0; i != successors; ++i) { Block.addEdge(Func.getBlock(TI->getSuccessor(i))); @@ -646,7 +646,7 @@ bool GCOVProfiler::emitProfileArcs() { DenseMap, unsigned> EdgeToCounter; unsigned Edges = 0; for (auto &BB : F) { - TerminatorInst *TI = BB.getTerminator(); + Instruction *TI = BB.getTerminator(); if (isa(TI)) { EdgeToCounter[{&BB, nullptr}] = Edges++; } else { @@ -690,7 +690,7 @@ bool GCOVProfiler::emitProfileArcs() { Count = Builder.CreateAdd(Count, Builder.getInt64(1)); Builder.CreateStore(Count, Phi); - TerminatorInst *TI = BB.getTerminator(); + Instruction *TI = BB.getTerminator(); if (isa(TI)) { auto It = EdgeToCounter.find({&BB, nullptr}); assert(It != EdgeToCounter.end()); diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index ac851f660d92..4790c9e5cfed 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -586,7 +586,7 @@ void FuncPGOInstrumentation::computeCFGHash() { std::vector Indexes; JamCRC JC; for (auto &BB : F) { - const TerminatorInst *TI = BB.getTerminator(); + const Instruction *TI = BB.getTerminator(); for (unsigned I = 0, E = TI->getNumSuccessors(); I != E; ++I) { BasicBlock *Succ = TI->getSuccessor(I); auto BI = findBBInfo(Succ); @@ -698,7 +698,7 @@ BasicBlock *FuncPGOInstrumentation::getInstrBB(Edge *E) { // Instrument the SrcBB if it has a single successor, // otherwise, the DestBB if this is not a critical edge. - TerminatorInst *TI = SrcBB->getTerminator(); + Instruction *TI = SrcBB->getTerminator(); if (TI->getNumSuccessors() <= 1) return SrcBB; if (!E->IsCritical) @@ -1167,7 +1167,7 @@ void PGOUseFunc::setBranchWeights() { // Generate MD_prof metadata for every branch instruction. LLVM_DEBUG(dbgs() << "\nSetting branch weights.\n"); for (auto &BB : F) { - TerminatorInst *TI = BB.getTerminator(); + Instruction *TI = BB.getTerminator(); if (TI->getNumSuccessors() < 2) continue; if (!(isa(TI) || isa(TI) || @@ -1213,7 +1213,7 @@ void PGOUseFunc::annotateIrrLoopHeaderWeights() { // to become an irreducible loop header after the indirectbr tail // duplication. if (BFI->isIrrLoopHeader(&BB) || isIndirectBrTarget(&BB)) { - TerminatorInst *TI = BB.getTerminator(); + Instruction *TI = BB.getTerminator(); const UseBBInfo &BBCountInfo = getBBInfo(&BB); setIrrLoopHeaderMetadata(M, TI, BBCountInfo.CountValue); } diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp index 883d2e17350d..b0602d96798c 100644 --- a/llvm/lib/Transforms/Scalar/ADCE.cpp +++ b/llvm/lib/Transforms/Scalar/ADCE.cpp @@ -103,7 +103,7 @@ struct BlockInfoType { BasicBlock *BB = nullptr; /// Cache of BB->getTerminator(). - TerminatorInst *Terminator = nullptr; + Instruction *Terminator = nullptr; /// Post-order numbering of reverse control flow graph. unsigned PostOrder; @@ -206,7 +206,7 @@ bool AggressiveDeadCodeElimination::performDeadCodeElimination() { return removeDeadInstructions(); } -static bool isUnconditionalBranch(TerminatorInst *Term) { +static bool isUnconditionalBranch(Instruction *Term) { auto *BR = dyn_cast(Term); return BR && BR->isUnconditional(); } @@ -277,7 +277,7 @@ void AggressiveDeadCodeElimination::initialize() { // treat all edges to a block already seen as loop back edges // and mark the branch live it if there is a back edge. for (auto *BB: depth_first_ext(&F.getEntryBlock(), State)) { - TerminatorInst *Term = BB->getTerminator(); + Instruction *Term = BB->getTerminator(); if (isLive(Term)) continue; @@ -643,7 +643,7 @@ void AggressiveDeadCodeElimination::computeReversePostOrder() { void AggressiveDeadCodeElimination::makeUnconditional(BasicBlock *BB, BasicBlock *Target) { - TerminatorInst *PredTerm = BB->getTerminator(); + Instruction *PredTerm = BB->getTerminator(); // Collect the live debug info scopes attached to this instruction. if (const DILocation *DL = PredTerm->getDebugLoc()) collectLiveScopes(*DL); diff --git a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp index 54385155cd2d..e82682e08ab9 100644 --- a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp +++ b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp @@ -248,7 +248,7 @@ static void copyMustTailReturn(BasicBlock *SplitBB, Instruction *CI, ReturnInst* RI = dyn_cast(&*II); assert(RI && "`musttail` call must be followed by `ret` instruction"); - TerminatorInst *TI = SplitBB->getTerminator(); + Instruction *TI = SplitBB->getTerminator(); Value *V = NewCI; if (BCI) V = cloneInstForMustTail(BCI, TI, V); diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index 545b0060c139..69112f3cee27 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -643,7 +643,7 @@ static void findUnconditionalPreds(SmallVectorImpl &Blocks, for (pred_iterator I = pred_begin(BB), E = pred_end(BB); I != E; ++I) { BasicBlock *Pred = *I; if (Pred == BB) continue; - TerminatorInst *PredTI = Pred->getTerminator(); + Instruction *PredTI = Pred->getTerminator(); if (PredTI->getNumSuccessors() != 1) continue; diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index d980cde49b64..34d2b2a8b27d 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -540,7 +540,7 @@ static Optional analyzeLoopUnrollCost( } } - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); // Add in the live successors by first checking whether we have terminator // that may be simplified based on the values simplified by this call. diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp index f67bff7fe93d..13e6bd137547 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -246,11 +246,11 @@ namespace { bool TryTrivialLoopUnswitch(bool &Changed); bool UnswitchIfProfitable(Value *LoopCond, Constant *Val, - TerminatorInst *TI = nullptr); + Instruction *TI = nullptr); void UnswitchTrivialCondition(Loop *L, Value *Cond, Constant *Val, - BasicBlock *ExitBlock, TerminatorInst *TI); + BasicBlock *ExitBlock, Instruction *TI); void UnswitchNontrivialCondition(Value *LIC, Constant *OnVal, Loop *L, - TerminatorInst *TI); + Instruction *TI); void RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC, Constant *Val, bool isEqual); @@ -258,8 +258,7 @@ namespace { void EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val, BasicBlock *TrueDest, BasicBlock *FalseDest, - BranchInst *OldBranch, - TerminatorInst *TI); + BranchInst *OldBranch, Instruction *TI); void SimplifyCode(std::vector &Worklist, Loop *L); @@ -713,7 +712,7 @@ bool LoopUnswitch::processCurrentLoop() { // loop. for (Loop::block_iterator I = currentLoop->block_begin(), E = currentLoop->block_end(); I != E; ++I) { - TerminatorInst *TI = (*I)->getTerminator(); + Instruction *TI = (*I)->getTerminator(); // Unswitching on a potentially uninitialized predicate is not // MSan-friendly. Limit this to the cases when the original predicate is @@ -876,7 +875,7 @@ static BasicBlock *isTrivialLoopExitBlock(Loop *L, BasicBlock *BB) { /// simplify the loop. If we decide that this is profitable, /// unswitch the loop, reprocess the pieces, then return true. bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val, - TerminatorInst *TI) { + Instruction *TI) { // Check to see if it would be profitable to unswitch current loop. if (!BranchesInfo.CostAllowsUnswitching()) { LLVM_DEBUG(dbgs() << "NOT unswitching loop %" @@ -931,7 +930,7 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val, BasicBlock *TrueDest, BasicBlock *FalseDest, BranchInst *OldBranch, - TerminatorInst *TI) { + Instruction *TI) { assert(OldBranch->isUnconditional() && "Preheader is not split correctly"); assert(TrueDest != FalseDest && "Branch targets should be different"); // Insert a conditional branch on LIC to the two preheaders. The original @@ -996,7 +995,7 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val, /// outside of the loop and updating loop info. void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond, Constant *Val, BasicBlock *ExitBlock, - TerminatorInst *TI) { + Instruction *TI) { LLVM_DEBUG(dbgs() << "loop-unswitch: Trivial-Unswitch loop %" << loopHeader->getName() << " [" << L->getBlocks().size() << " blocks] in Function " @@ -1054,7 +1053,7 @@ void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond, Constant *Val, /// condition. bool LoopUnswitch::TryTrivialLoopUnswitch(bool &Changed) { BasicBlock *CurrentBB = currentLoop->getHeader(); - TerminatorInst *CurrentTerm = CurrentBB->getTerminator(); + Instruction *CurrentTerm = CurrentBB->getTerminator(); LLVMContext &Context = CurrentBB->getContext(); // If loop header has only one reachable successor (currently via an @@ -1227,7 +1226,7 @@ void LoopUnswitch::SplitExitEdges(Loop *L, /// Split it into loop versions and test the condition outside of either loop. /// Return the loops created as Out1/Out2. void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val, - Loop *L, TerminatorInst *TI) { + Loop *L, Instruction *TI) { Function *F = loopHeader->getParent(); LLVM_DEBUG(dbgs() << "loop-unswitch: Unswitching loop %" << loopHeader->getName() << " [" << L->getBlocks().size() diff --git a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp index 7f9aad248836..fd2eb85fd7bf 100644 --- a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp +++ b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp @@ -105,7 +105,7 @@ struct PlaceBackedgeSafepointsImpl : public FunctionPass { /// The output of the pass - gives a list of each backedge (described by /// pointing at the branch) which need a poll inserted. - std::vector PollLocations; + std::vector PollLocations; /// True unless we're running spp-no-calls in which case we need to disable /// the call-dependent placement opts. @@ -348,7 +348,7 @@ bool PlaceBackedgeSafepointsImpl::runOnLoop(Loop *L) { // Safepoint insertion would involve creating a new basic block (as the // target of the current backedge) which does the safepoint (of all live // variables) and branches to the true header - TerminatorInst *Term = Pred->getTerminator(); + Instruction *Term = Pred->getTerminator(); LLVM_DEBUG(dbgs() << "[LSP] terminator instruction: " << *Term); @@ -535,7 +535,7 @@ bool PlaceSafepoints::runOnFunction(Function &F) { // Insert a poll at each point the analysis pass identified // The poll location must be the terminator of a loop latch block. - for (TerminatorInst *Term : PollLocations) { + for (Instruction *Term : PollLocations) { // We are inserting a poll, the function is modified Modified = true; diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 5e23a8a3dcd2..cf2ce03049af 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1851,13 +1851,13 @@ static void relocationViaAlloca( StoreInst *Store = new StoreInst(Def, Alloca); if (Instruction *Inst = dyn_cast(Def)) { if (InvokeInst *Invoke = dyn_cast(Inst)) { - // InvokeInst is a TerminatorInst so the store need to be inserted - // into its normal destination block. + // InvokeInst is a terminator so the store need to be inserted into its + // normal destination block. BasicBlock *NormalDest = Invoke->getNormalDest(); Store->insertBefore(NormalDest->getFirstNonPHI()); } else { assert(!Inst->isTerminator() && - "The only TerminatorInst that can produce a value is " + "The only terminator that can produce a value is " "InvokeInst which is handled above."); Store->insertAfter(Inst); } @@ -2584,7 +2584,7 @@ bool RewriteStatepointsForGC::runOnFunction(Function &F, DominatorTree &DT, // increase the liveset of any statepoint we move over. This is profitable // as long as all statepoints are in rare blocks. If we had in-register // lowering for live values this would be a much safer transform. - auto getConditionInst = [](TerminatorInst *TI) -> Instruction* { + auto getConditionInst = [](Instruction *TI) -> Instruction * { if (auto *BI = dyn_cast(TI)) if (BI->isConditional()) return dyn_cast(BI->getCondition()); @@ -2592,7 +2592,7 @@ bool RewriteStatepointsForGC::runOnFunction(Function &F, DominatorTree &DT, return nullptr; }; for (BasicBlock &BB : F) { - TerminatorInst *TI = BB.getTerminator(); + Instruction *TI = BB.getTerminator(); if (auto *Cond = getConditionInst(TI)) // TODO: Handle more than just ICmps here. We should be able to move // most instructions without side effects or memory access. @@ -2675,7 +2675,7 @@ static SetVector computeKillSet(BasicBlock *BB) { /// Check that the items in 'Live' dominate 'TI'. This is used as a basic /// sanity check for the liveness computation. static void checkBasicSSA(DominatorTree &DT, SetVector &Live, - TerminatorInst *TI, bool TermOkay = false) { + Instruction *TI, bool TermOkay = false) { for (Value *V : Live) { if (auto *I = dyn_cast(V)) { // The terminator can be a member of the LiveOut set. LLVM's definition diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index 7196bc82edcc..11e5549c332e 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -1614,7 +1614,7 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) { // Check to see if we have a branch or switch on an undefined value. If so // we force the branch to go one way or the other to make the successor // values live. It doesn't really matter which way we force it. - TerminatorInst *TI = BB.getTerminator(); + Instruction *TI = BB.getTerminator(); if (auto *BI = dyn_cast(TI)) { if (!BI->isConditional()) continue; if (!getValueState(BI->getCondition()).isUnknown()) diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index 6e991409bf07..0f43ee6bbd7f 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -1211,7 +1211,7 @@ static bool isSafePHIToSpeculate(PHINode &PN) { // predecessor blocks. The only thing to watch out for is that we can't put // a possibly trapping load in the predecessor if it is a critical edge. for (unsigned Idx = 0, Num = PN.getNumIncomingValues(); Idx != Num; ++Idx) { - TerminatorInst *TI = PN.getIncomingBlock(Idx)->getTerminator(); + Instruction *TI = PN.getIncomingBlock(Idx)->getTerminator(); Value *InVal = PN.getIncomingValue(Idx); // If the value is produced by the terminator of the predecessor (an @@ -1275,7 +1275,7 @@ static void speculatePHINodeLoads(PHINode &PN) { continue; } - TerminatorInst *TI = Pred->getTerminator(); + Instruction *TI = Pred->getTerminator(); IRBuilderTy PredBuilder(TI); LoadInst *Load = PredBuilder.CreateLoad( diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index 17035f469dae..6c4773aa92ea 100644 --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -783,7 +783,7 @@ static bool unswitchAllTrivialConditions(Loop &L, DominatorTree &DT, [](Instruction &I) { return I.mayHaveSideEffects(); })) return Changed; - TerminatorInst *CurrentTerm = CurrentBB->getTerminator(); + Instruction *CurrentTerm = CurrentBB->getTerminator(); if (auto *SI = dyn_cast(CurrentTerm)) { // Don't bother trying to unswitch past a switch with a constant diff --git a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp index f58f79f8b144..2bfd99274111 100644 --- a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp +++ b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp @@ -636,7 +636,7 @@ void StructurizeCFG::setPhiValues() { /// Remove phi values from all successors and then remove the terminator. void StructurizeCFG::killTerminator(BasicBlock *BB) { - TerminatorInst *Term = BB->getTerminator(); + Instruction *Term = BB->getTerminator(); if (!Term) return; diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp index 6a77a2d414f8..0f6db21f73b6 100644 --- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -702,7 +702,7 @@ static bool foldReturnAndProcessPred( SmallVector UncondBranchPreds; for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { BasicBlock *Pred = *PI; - TerminatorInst *PTI = Pred->getTerminator(); + Instruction *PTI = Pred->getTerminator(); if (BranchInst *BI = dyn_cast(PTI)) if (BI->isUnconditional()) UncondBranchPreds.push_back(BI); diff --git a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp index c3d67087ae7e..fafc9aaba5c9 100644 --- a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -318,7 +318,7 @@ findIBRPredecessor(BasicBlock *BB, SmallVectorImpl &OtherPreds) { BasicBlock *IBB = nullptr; for (unsigned Pred = 0, E = PN->getNumIncomingValues(); Pred != E; ++Pred) { BasicBlock *PredBB = PN->getIncomingBlock(Pred); - TerminatorInst *PredTerm = PredBB->getTerminator(); + Instruction *PredTerm = PredBB->getTerminator(); switch (PredTerm->getOpcode()) { case Instruction::IndirectBr: if (IBB) diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index a9257a8c6702..000af808945a 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -365,7 +365,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB, } // Finally, clone over the terminator. - const TerminatorInst *OldTI = BB->getTerminator(); + const Instruction *OldTI = BB->getTerminator(); bool TerminatorDone = false; if (const BranchInst *BI = dyn_cast(OldTI)) { if (BI->isConditional()) { @@ -414,7 +414,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB, CodeInfo->OperandBundleCallSites.push_back(NewInst); // Recursively clone any reachable successor blocks. - const TerminatorInst *TI = BB->getTerminator(); + const Instruction *TI = BB->getTerminator(); for (const BasicBlock *Succ : successors(TI)) ToClone.push_back(Succ); } diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index 7f26c53ecf3e..0e9e3219033a 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -566,7 +566,7 @@ void CodeExtractor::severSplitPHINodes(BasicBlock *&Header) { // changing them to branch to NewBB instead. for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) if (Blocks.count(PN->getIncomingBlock(i))) { - TerminatorInst *TI = PN->getIncomingBlock(i)->getTerminator(); + Instruction *TI = PN->getIncomingBlock(i)->getTerminator(); TI->replaceUsesOfWith(OldPred, NewBB); } @@ -778,7 +778,7 @@ Function *CodeExtractor::constructFunction(const ValueSet &inputs, Value *Idx[2]; Idx[0] = Constant::getNullValue(Type::getInt32Ty(header->getContext())); Idx[1] = ConstantInt::get(Type::getInt32Ty(header->getContext()), i); - TerminatorInst *TI = newFunction->begin()->getTerminator(); + Instruction *TI = newFunction->begin()->getTerminator(); GetElementPtrInst *GEP = GetElementPtrInst::Create( StructTy, &*AI, Idx, "gep_" + inputs[i]->getName(), TI); RewriteVal = new LoadInst(GEP, "loadgep_" + inputs[i]->getName(), TI); @@ -972,7 +972,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, unsigned switchVal = 0; for (BasicBlock *Block : Blocks) { - TerminatorInst *TI = Block->getTerminator(); + Instruction *TI = Block->getTerminator(); for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) if (!Blocks.count(TI->getSuccessor(i))) { BasicBlock *OldTarget = TI->getSuccessor(i); @@ -1078,7 +1078,7 @@ void CodeExtractor::calculateNewCallTerminatorWeights( using BlockNode = BlockFrequencyInfoImplBase::BlockNode; // Update the branch weights for the exit block. - TerminatorInst *TI = CodeReplacer->getTerminator(); + Instruction *TI = CodeReplacer->getTerminator(); SmallVector BranchWeights(TI->getNumSuccessors(), 0); // Block Frequency distribution with dummy node. diff --git a/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp b/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp index c9c96fbe5da0..762a374c135c 100644 --- a/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp +++ b/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp @@ -37,7 +37,7 @@ IRBuilder<> *EscapeEnumerator::Next() { // Branches and invokes do not escape, only unwind, resume, and return // do. - TerminatorInst *TI = CurBB->getTerminator(); + Instruction *TI = CurBB->getTerminator(); if (!isa(TI) && !isa(TI)) continue; diff --git a/llvm/lib/Transforms/Utils/FlattenCFG.cpp b/llvm/lib/Transforms/Utils/FlattenCFG.cpp index 3c6c9c9a5df4..d9778f4a1fb7 100644 --- a/llvm/lib/Transforms/Utils/FlattenCFG.cpp +++ b/llvm/lib/Transforms/Utils/FlattenCFG.cpp @@ -232,7 +232,7 @@ bool FlattenCFGOpt::FlattenParallelAndOr(BasicBlock *BB, IRBuilder<> &Builder) { if (!FirstCondBlock || !LastCondBlock || (FirstCondBlock == LastCondBlock)) return false; - TerminatorInst *TBB = LastCondBlock->getTerminator(); + Instruction *TBB = LastCondBlock->getTerminator(); BasicBlock *PS1 = TBB->getSuccessor(0); BasicBlock *PS2 = TBB->getSuccessor(1); BranchInst *PBI1 = dyn_cast(PS1->getTerminator()); @@ -325,7 +325,7 @@ bool FlattenCFGOpt::FlattenParallelAndOr(BasicBlock *BB, IRBuilder<> &Builder) { bool FlattenCFGOpt::CompareIfRegionBlock(BasicBlock *Head1, BasicBlock *Head2, BasicBlock *Block1, BasicBlock *Block2) { - TerminatorInst *PTI2 = Head2->getTerminator(); + Instruction *PTI2 = Head2->getTerminator(); Instruction *PBI2 = &Head2->front(); bool eq1 = (Block1 == Head1); @@ -421,7 +421,7 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { if ((IfTrue2 != SecondEntryBlock) && (IfFalse2 != SecondEntryBlock)) return false; - TerminatorInst *PTI2 = SecondEntryBlock->getTerminator(); + Instruction *PTI2 = SecondEntryBlock->getTerminator(); Instruction *PBI2 = &SecondEntryBlock->front(); if (!CompareIfRegionBlock(FirstEntryBlock, SecondEntryBlock, IfTrue1, diff --git a/llvm/lib/Transforms/Utils/FunctionComparator.cpp b/llvm/lib/Transforms/Utils/FunctionComparator.cpp index 69203f9f2485..ef991d715fd3 100644 --- a/llvm/lib/Transforms/Utils/FunctionComparator.cpp +++ b/llvm/lib/Transforms/Utils/FunctionComparator.cpp @@ -867,8 +867,8 @@ int FunctionComparator::compare() { if (int Res = cmpBasicBlocks(BBL, BBR)) return Res; - const TerminatorInst *TermL = BBL->getTerminator(); - const TerminatorInst *TermR = BBR->getTerminator(); + const Instruction *TermL = BBL->getTerminator(); + const Instruction *TermR = BBR->getTerminator(); assert(TermL->getNumSuccessors() == TermR->getNumSuccessors()); for (unsigned i = 0, e = TermL->getNumSuccessors(); i != e; ++i) { @@ -938,7 +938,7 @@ FunctionComparator::FunctionHash FunctionComparator::functionHash(Function &F) { for (auto &Inst : *BB) { H.add(Inst.getOpcode()); } - const TerminatorInst *Term = BB->getTerminator(); + const Instruction *Term = BB->getTerminator(); for (unsigned i = 0, e = Term->getNumSuccessors(); i != e; ++i) { if (!VisitedBBs.insert(Term->getSuccessor(i)).second) continue; diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index f8226f529ee6..bda2ee2d8a3f 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -2247,7 +2247,7 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI, // Change the branch that used to go to AfterCallBB to branch to the first // basic block of the inlined function. // - TerminatorInst *Br = OrigBB->getTerminator(); + Instruction *Br = OrigBB->getTerminator(); assert(Br && Br->getOpcode() == Instruction::Br && "splitBasicBlock broken!"); Br->setOperand(0, &*FirstNewBlock); diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 879145cea6b2..04db1c8c4c78 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -105,7 +105,7 @@ STATISTIC(NumRemoved, "Number of unreachable basic blocks removed"); bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions, const TargetLibraryInfo *TLI, DomTreeUpdater *DTU) { - TerminatorInst *T = BB->getTerminator(); + Instruction *T = BB->getTerminator(); IRBuilder<> Builder(T); // Branch - See if we are conditional jumping on constant @@ -2101,7 +2101,7 @@ static bool markAliveBlocks(Function &F, } } - TerminatorInst *Terminator = BB->getTerminator(); + Instruction *Terminator = BB->getTerminator(); if (auto *II = dyn_cast(Terminator)) { // Turn invokes that call 'nounwind' functions into ordinary calls. Value *Callee = II->getCalledValue(); @@ -2176,7 +2176,7 @@ static bool markAliveBlocks(Function &F, } void llvm::removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU) { - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); if (auto *II = dyn_cast(TI)) { changeToCall(II, DTU); diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp index a6320d8dbf4e..73f67f3219df 100644 --- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp @@ -299,7 +299,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { // For the rest of the instructions, either hoist to the OrigPreheader if // possible or create a clone in the OldPreHeader if not. - TerminatorInst *LoopEntryBranch = OrigPreheader->getTerminator(); + Instruction *LoopEntryBranch = OrigPreheader->getTerminator(); // Record all debug intrinsics preceding LoopEntryBranch to avoid duplication. using DbgIntrinsicHash = diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index fc59cafa3315..380f4fca54d9 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -435,7 +435,7 @@ static BasicBlock *insertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader, unsigned LoopMDKind = BEBlock->getContext().getMDKindID("llvm.loop"); MDNode *LoopMD = nullptr; for (unsigned i = 0, e = BackedgeBlocks.size(); i != e; ++i) { - TerminatorInst *TI = BackedgeBlocks[i]->getTerminator(); + Instruction *TI = BackedgeBlocks[i]->getTerminator(); if (!LoopMD) LoopMD = TI->getMetadata(LoopMDKind); TI->setMetadata(LoopMDKind, nullptr); @@ -488,7 +488,7 @@ ReprocessLoop: << P->getName() << "\n"); // Zap the dead pred's terminator and replace it with unreachable. - TerminatorInst *TI = P->getTerminator(); + Instruction *TI = P->getTerminator(); changeToUnreachable(TI, /*UseLLVMTrap=*/false, PreserveLCSSA); Changed = true; } diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp index a8ec75c0bafb..877e0e4dcf90 100644 --- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp @@ -781,7 +781,7 @@ LoopUnrollResult llvm::UnrollLoop( // there is no such latch. NewIDom = Latches.back(); for (BasicBlock *IterLatch : Latches) { - TerminatorInst *Term = IterLatch->getTerminator(); + Instruction *Term = IterLatch->getTerminator(); if (isa(Term) && cast(Term)->isConditional()) { NewIDom = IterLatch; break; diff --git a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp index 1ce2f8444896..c17a64f01877 100644 --- a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp @@ -72,7 +72,7 @@ static bool partitionOuterLoopBlocks(Loop *L, Loop *SubLoop, for (BasicBlock *BB : ForeBlocks) { if (BB == SubLoopPreHeader) continue; - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) if (!ForeBlocks.count(TI->getSuccessor(i))) return false; diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index ebbcf8002545..8dad6176c511 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -175,13 +175,13 @@ class SimplifyCFGOpt { const SimplifyCFGOptions &Options; bool Resimplify; - Value *isValueEqualityComparison(TerminatorInst *TI); + Value *isValueEqualityComparison(Instruction *TI); BasicBlock *GetValueEqualityComparisonCases( - TerminatorInst *TI, std::vector &Cases); - bool SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI, + Instruction *TI, std::vector &Cases); + bool SimplifyEqualityComparisonWithOnlyPredecessor(Instruction *TI, BasicBlock *Pred, IRBuilder<> &Builder); - bool FoldValueComparisonIntoPredecessors(TerminatorInst *TI, + bool FoldValueComparisonIntoPredecessors(Instruction *TI, IRBuilder<> &Builder); bool SimplifyReturn(ReturnInst *RI, IRBuilder<> &Builder); @@ -219,7 +219,7 @@ public: /// Return true if it is safe to merge these two /// terminator instructions together. static bool -SafeToMergeTerminators(TerminatorInst *SI1, TerminatorInst *SI2, +SafeToMergeTerminators(Instruction *SI1, Instruction *SI2, SmallSetVector *FailBlocks = nullptr) { if (SI1 == SI2) return false; // Can't merge with self! @@ -670,7 +670,7 @@ private: } // end anonymous namespace -static void EraseTerminatorInstAndDCECond(TerminatorInst *TI) { +static void EraseTerminatorAndDCECond(Instruction *TI) { Instruction *Cond = nullptr; if (SwitchInst *SI = dyn_cast(TI)) { Cond = dyn_cast(SI->getCondition()); @@ -688,7 +688,7 @@ static void EraseTerminatorInstAndDCECond(TerminatorInst *TI) { /// Return true if the specified terminator checks /// to see if a value is equal to constant integer value. -Value *SimplifyCFGOpt::isValueEqualityComparison(TerminatorInst *TI) { +Value *SimplifyCFGOpt::isValueEqualityComparison(Instruction *TI) { Value *CV = nullptr; if (SwitchInst *SI = dyn_cast(TI)) { // Do not permit merging of large switch instructions into their @@ -716,7 +716,7 @@ Value *SimplifyCFGOpt::isValueEqualityComparison(TerminatorInst *TI) { /// Given a value comparison instruction, /// decode all of the 'cases' that it represents and return the 'default' block. BasicBlock *SimplifyCFGOpt::GetValueEqualityComparisonCases( - TerminatorInst *TI, std::vector &Cases) { + Instruction *TI, std::vector &Cases) { if (SwitchInst *SI = dyn_cast(TI)) { Cases.reserve(SI->getNumCases()); for (auto Case : SI->cases()) @@ -806,7 +806,7 @@ static void setBranchWeights(Instruction *I, uint32_t TrueWeight, /// determines the outcome of this comparison. If so, simplify TI. This does a /// very limited form of jump threading. bool SimplifyCFGOpt::SimplifyEqualityComparisonWithOnlyPredecessor( - TerminatorInst *TI, BasicBlock *Pred, IRBuilder<> &Builder) { + Instruction *TI, BasicBlock *Pred, IRBuilder<> &Builder) { Value *PredVal = isValueEqualityComparison(Pred->getTerminator()); if (!PredVal) return false; // Not a value comparison in predecessor. @@ -854,7 +854,7 @@ bool SimplifyCFGOpt::SimplifyEqualityComparisonWithOnlyPredecessor( << "Through successor TI: " << *TI << "Leaving: " << *NI << "\n"); - EraseTerminatorInstAndDCECond(TI); + EraseTerminatorAndDCECond(TI); return true; } @@ -936,7 +936,7 @@ bool SimplifyCFGOpt::SimplifyEqualityComparisonWithOnlyPredecessor( << "Through successor TI: " << *TI << "Leaving: " << *NI << "\n"); - EraseTerminatorInstAndDCECond(TI); + EraseTerminatorAndDCECond(TI); return true; } @@ -971,10 +971,10 @@ static inline bool HasBranchWeights(const Instruction *I) { return false; } -/// Get Weights of a given TerminatorInst, the default weight is at the front +/// Get Weights of a given terminator, the default weight is at the front /// of the vector. If TI is a conditional eq, we need to swap the branch-weight /// metadata. -static void GetBranchWeights(TerminatorInst *TI, +static void GetBranchWeights(Instruction *TI, SmallVectorImpl &Weights) { MDNode *MD = TI->getMetadata(LLVMContext::MD_prof); assert(MD); @@ -1008,7 +1008,7 @@ static void FitWeights(MutableArrayRef Weights) { /// (either a switch or a branch on "X == c"). /// See if any of the predecessors of the terminator block are value comparisons /// on the same value. If so, and if safe to do so, fold them together. -bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(TerminatorInst *TI, +bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(Instruction *TI, IRBuilder<> &Builder) { BasicBlock *BB = TI->getParent(); Value *CV = isValueEqualityComparison(TI); // CondVal @@ -1020,7 +1020,7 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(TerminatorInst *TI, BasicBlock *Pred = Preds.pop_back_val(); // See if the predecessor is a comparison with the same value. - TerminatorInst *PTI = Pred->getTerminator(); + Instruction *PTI = Pred->getTerminator(); Value *PCV = isValueEqualityComparison(PTI); // PredCondVal if (PCV == CV && TI != PTI) { @@ -1197,7 +1197,7 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(TerminatorInst *TI, setBranchWeights(NewSI, MDWeights); } - EraseTerminatorInstAndDCECond(PTI); + EraseTerminatorAndDCECond(PTI); // Okay, last check. If BB is still a successor of PSI, then we must // have an infinite loop case. If so, add an infinitely looping block @@ -1413,7 +1413,7 @@ HoistTerminator: for (BasicBlock *Succ : successors(BB1)) AddPredecessorToBlock(Succ, BIParent, BB1); - EraseTerminatorInstAndDCECond(BI); + EraseTerminatorAndDCECond(BI); return true; } @@ -2247,7 +2247,7 @@ static bool FoldCondBranchOnPHI(BranchInst *BI, const DataLayout &DL, // Loop over all of the edges from PredBB to BB, changing them to branch // to EdgeBB instead. - TerminatorInst *PredBBTI = PredBB->getTerminator(); + Instruction *PredBBTI = PredBB->getTerminator(); for (unsigned i = 0, e = PredBBTI->getNumSuccessors(); i != e; ++i) if (PredBBTI->getSuccessor(i) == BB) { BB->removePredecessor(PredBB); @@ -2408,7 +2408,7 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI, // At this point, IfBlock1 and IfBlock2 are both empty, so our if statement // has been flattened. Change DomBlock to jump directly to our new block to // avoid other simplifycfg's kicking in on the diamond. - TerminatorInst *OldTI = DomBlock->getTerminator(); + Instruction *OldTI = DomBlock->getTerminator(); Builder.SetInsertPoint(OldTI); Builder.CreateBr(BB); OldTI->eraseFromParent(); @@ -2442,7 +2442,7 @@ static bool SimplifyCondBranchToTwoReturns(BranchInst *BI, TrueSucc->removePredecessor(BI->getParent()); FalseSucc->removePredecessor(BI->getParent()); Builder.CreateRetVoid(); - EraseTerminatorInstAndDCECond(BI); + EraseTerminatorAndDCECond(BI); return true; } @@ -2498,7 +2498,7 @@ static bool SimplifyCondBranchToTwoReturns(BranchInst *BI, << "\n " << *BI << "NewRet = " << *RI << "TRUEBLOCK: " << *TrueSucc << "FALSEBLOCK: " << *FalseSucc); - EraseTerminatorInstAndDCECond(BI); + EraseTerminatorAndDCECond(BI); return true; } @@ -2822,7 +2822,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, unsigned BonusInstThreshold) { } // Change PBI from Conditional to Unconditional. BranchInst *New_PBI = BranchInst::Create(TrueDest, PBI); - EraseTerminatorInstAndDCECond(PBI); + EraseTerminatorAndDCECond(PBI); PBI = New_PBI; } @@ -3417,7 +3417,7 @@ static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI, // Takes care of updating the successors and removing the old terminator. // Also makes sure not to introduce new successors by assuming that edges to // non-successor TrueBBs and FalseBBs aren't reachable. -static bool SimplifyTerminatorOnSelect(TerminatorInst *OldTerm, Value *Cond, +static bool SimplifyTerminatorOnSelect(Instruction *OldTerm, Value *Cond, BasicBlock *TrueBB, BasicBlock *FalseBB, uint32_t TrueWeight, uint32_t FalseWeight) { @@ -3472,7 +3472,7 @@ static bool SimplifyTerminatorOnSelect(TerminatorInst *OldTerm, Value *Cond, Builder.CreateBr(FalseBB); } - EraseTerminatorInstAndDCECond(OldTerm); + EraseTerminatorAndDCECond(OldTerm); return true; } @@ -3715,7 +3715,7 @@ static bool SimplifyBranchOnICmpChain(BranchInst *BI, IRBuilder<> &Builder, BasicBlock *NewBB = BB->splitBasicBlock(BI->getIterator(), "switch.early.test"); // Remove the uncond branch added to the old block. - TerminatorInst *OldTI = BB->getTerminator(); + Instruction *OldTI = BB->getTerminator(); Builder.SetInsertPoint(OldTI); if (TrueWhenEqual) @@ -3759,7 +3759,7 @@ static bool SimplifyBranchOnICmpChain(BranchInst *BI, IRBuilder<> &Builder, } // Erase the old branch instruction. - EraseTerminatorInstAndDCECond(BI); + EraseTerminatorAndDCECond(BI); LLVM_DEBUG(dbgs() << " ** 'icmp' chain result is:\n" << *BB << '\n'); return true; @@ -4007,7 +4007,7 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI) { if (UnwindDest == nullptr) { removeUnwindEdge(PredBB); } else { - TerminatorInst *TI = PredBB->getTerminator(); + Instruction *TI = PredBB->getTerminator(); TI->replaceUsesOfWith(BB, UnwindDest); } } @@ -4076,7 +4076,7 @@ bool SimplifyCFGOpt::SimplifyReturn(ReturnInst *RI, IRBuilder<> &Builder) { SmallVector CondBranchPreds; for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { BasicBlock *P = *PI; - TerminatorInst *PTI = P->getTerminator(); + Instruction *PTI = P->getTerminator(); if (BranchInst *BI = dyn_cast(PTI)) { if (BI->isUnconditional()) UncondBranchPreds.push_back(P); @@ -4181,7 +4181,7 @@ bool SimplifyCFGOpt::SimplifyUnreachable(UnreachableInst *UI) { SmallVector Preds(pred_begin(BB), pred_end(BB)); for (unsigned i = 0, e = Preds.size(); i != e; ++i) { - TerminatorInst *TI = Preds[i]->getTerminator(); + Instruction *TI = Preds[i]->getTerminator(); IRBuilder<> Builder(TI); if (auto *BI = dyn_cast(TI)) { if (BI->isUnconditional()) { @@ -4193,10 +4193,10 @@ bool SimplifyCFGOpt::SimplifyUnreachable(UnreachableInst *UI) { } else { if (BI->getSuccessor(0) == BB) { Builder.CreateBr(BI->getSuccessor(1)); - EraseTerminatorInstAndDCECond(BI); + EraseTerminatorAndDCECond(BI); } else if (BI->getSuccessor(1) == BB) { Builder.CreateBr(BI->getSuccessor(0)); - EraseTerminatorInstAndDCECond(BI); + EraseTerminatorAndDCECond(BI); Changed = true; } } @@ -4438,7 +4438,7 @@ static bool eliminateDeadSwitchCases(SwitchInst *SI, AssumptionCache *AC, SplitBlock(&*NewDefault, &NewDefault->front()); auto *OldTI = NewDefault->getTerminator(); new UnreachableInst(SI->getContext(), OldTI); - EraseTerminatorInstAndDCECond(OldTI); + EraseTerminatorAndDCECond(OldTI); return true; } @@ -4649,12 +4649,12 @@ GetCaseResults(SwitchInst *SI, ConstantInt *CaseVal, BasicBlock *CaseDest, SmallDenseMap ConstantPool; ConstantPool.insert(std::make_pair(SI->getCondition(), CaseVal)); for (Instruction &I :CaseDest->instructionsWithoutDebug()) { - if (TerminatorInst *T = dyn_cast(&I)) { + if (I.isTerminator()) { // If the terminator is a simple branch, continue to the next block. - if (T->getNumSuccessors() != 1 || T->isExceptionalTerminator()) + if (I.getNumSuccessors() != 1 || I.isExceptionalTerminator()) return false; Pred = CaseDest; - CaseDest = T->getSuccessor(0); + CaseDest = I.getSuccessor(0); } else if (Constant *C = ConstantFold(&I, DL, ConstantPool)) { // Instruction is side-effect free and constant. @@ -5663,14 +5663,14 @@ bool SimplifyCFGOpt::SimplifyIndirectBr(IndirectBrInst *IBI) { if (IBI->getNumDestinations() == 0) { // If the indirectbr has no successors, change it to unreachable. new UnreachableInst(IBI->getContext(), IBI); - EraseTerminatorInstAndDCECond(IBI); + EraseTerminatorAndDCECond(IBI); return true; } if (IBI->getNumDestinations() == 1) { // If the indirectbr has one successor, change it to a direct branch. BranchInst::Create(IBI->getDestination(0), IBI); - EraseTerminatorInstAndDCECond(IBI); + EraseTerminatorAndDCECond(IBI); return true; } @@ -5892,7 +5892,7 @@ bool SimplifyCFGOpt::SimplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) { } else { // If Successor #1 has multiple preds, we may be able to conditionally // execute Successor #0 if it branches to Successor #1. - TerminatorInst *Succ0TI = BI->getSuccessor(0)->getTerminator(); + Instruction *Succ0TI = BI->getSuccessor(0)->getTerminator(); if (Succ0TI->getNumSuccessors() == 1 && Succ0TI->getSuccessor(0) == BI->getSuccessor(1)) if (SpeculativelyExecuteBB(BI, BI->getSuccessor(0), TTI)) @@ -5901,7 +5901,7 @@ bool SimplifyCFGOpt::SimplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) { } else if (BI->getSuccessor(1)->getSinglePredecessor()) { // If Successor #0 has multiple preds, we may be able to conditionally // execute Successor #1 if it branches to Successor #0. - TerminatorInst *Succ1TI = BI->getSuccessor(1)->getTerminator(); + Instruction *Succ1TI = BI->getSuccessor(1)->getTerminator(); if (Succ1TI->getNumSuccessors() == 1 && Succ1TI->getSuccessor(0) == BI->getSuccessor(0)) if (SpeculativelyExecuteBB(BI, BI->getSuccessor(1), TTI)) @@ -5991,7 +5991,7 @@ static bool removeUndefIntroducingPredecessor(BasicBlock *BB) { for (PHINode &PHI : BB->phis()) for (unsigned i = 0, e = PHI.getNumIncomingValues(); i != e; ++i) if (passingValueIsAlwaysUndefined(PHI.getIncomingValue(i), &PHI)) { - TerminatorInst *T = PHI.getIncomingBlock(i)->getTerminator(); + Instruction *T = PHI.getIncomingBlock(i)->getTerminator(); IRBuilder<> Builder(T); if (BranchInst *BI = dyn_cast(T)) { BB->removePredecessor(PHI.getIncomingBlock(i)); diff --git a/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp b/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp index b6307acb9474..0f42694e193b 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp @@ -268,7 +268,7 @@ VPRegionBlock *PlainCFGBuilder::buildPlainCFG() { // Set VPBB successors. We create empty VPBBs for successors if they don't // exist already. Recipes will be created when the successor is visited // during the RPO traversal. - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); assert(TI && "Terminator expected."); unsigned NumSuccs = TI->getNumSuccessors(); -- GitLab