diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2018-10-15 10:42:50 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2018-10-15 10:42:50 +0000 |
commit | 89e105a4f96cb21ce021cb89a46e86df1017293e (patch) | |
tree | 5713eeaf91ffe79161845ed076f9fd8626139a23 /polly | |
parent | 9e1bb841973751095dbbdbd1b114f6eb63543ab3 (diff) |
[TI removal] Make `getTerminator()` return a generic `Instruction`.
This removes the primary remaining API producing `TerminatorInst` which
will reduce the rate at which code is introduced trying to use it and
generally make it much easier to remove the remaining APIs across the
codebase.
Also clean up some of the stragglers that the previous mechanical update
of variables missed.
Users of LLVM and out-of-tree code generally will need to update any
explicit variable types to handle this. Replacing `TerminatorInst` with
`Instruction` (or `auto`) almost always works. Most of these edits were
made in prior commits using the perl one-liner:
```
perl -i -ple 's/TerminatorInst(\b.* = .*getTerminator\(\))/Instruction\1/g'
```
This also my break some rare use cases where people overload for both
`Instruction` and `TerminatorInst`, but these should be easily fixed by
removing the `TerminatorInst` overload.
Diffstat (limited to 'polly')
-rw-r--r-- | polly/include/polly/Support/ScopHelper.h | 2 | ||||
-rw-r--r-- | polly/lib/Analysis/ScopDetection.cpp | 4 | ||||
-rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 10 | ||||
-rw-r--r-- | polly/lib/CodeGen/BlockGenerators.cpp | 2 | ||||
-rw-r--r-- | polly/lib/Support/ScopHelper.cpp | 2 |
5 files changed, 10 insertions, 10 deletions
diff --git a/polly/include/polly/Support/ScopHelper.h b/polly/include/polly/Support/ScopHelper.h index b7455e786b3..4fec7710d01 100644 --- a/polly/include/polly/Support/ScopHelper.h +++ b/polly/include/polly/Support/ScopHelper.h @@ -382,7 +382,7 @@ bool isErrorBlock(llvm::BasicBlock &BB, const llvm::Region &R, /// @param TI The terminator to get the condition from. /// /// @return The condition of @p TI and nullptr if none could be extracted. -llvm::Value *getConditionFromTerminator(llvm::TerminatorInst *TI); +llvm::Value *getConditionFromTerminator(llvm::Instruction *TI); /// Check if @p LInst can be hoisted in @p R. /// diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 480589e1f22..9502f324fc9 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -657,7 +657,7 @@ bool ScopDetection::isValidCFG(BasicBlock &BB, bool IsLoopBranch, DetectionContext &Context) const { Region &CurRegion = Context.CurRegion; - TerminatorInst *TI = BB.getTerminator(); + Instruction *TI = BB.getTerminator(); if (AllowUnreachable && isa<UnreachableInst>(TI)) return true; @@ -1756,7 +1756,7 @@ bool ScopDetection::isReducibleRegion(Region &R, DebugLoc &DbgLoc) const { DFSStack.pop(); // Loop to iterate over the successors of current BB. - const TerminatorInst *TInst = CurrBB->getTerminator(); + const Instruction *TInst = CurrBB->getTerminator(); unsigned NSucc = TInst->getNumSuccessors(); for (unsigned I = AdjacentBlockIndex; I < NSucc; ++I, ++AdjacentBlockIndex) { diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index 9e8ee9116a9..896a1b6b461 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -1502,7 +1502,7 @@ buildUnsignedConditionSets(Scop &S, BasicBlock *BB, Value *Condition, /// context under which @p Condition is true/false will be returned as the /// new elements of @p ConditionSets. bool buildConditionSets(Scop &S, BasicBlock *BB, Value *Condition, - TerminatorInst *TI, Loop *L, __isl_keep isl_set *Domain, + Instruction *TI, Loop *L, __isl_keep isl_set *Domain, DenseMap<BasicBlock *, isl::set> &InvalidDomainMap, SmallVectorImpl<__isl_give isl_set *> &ConditionSets) { ScalarEvolution &SE = *S.getSE(); @@ -1642,7 +1642,7 @@ bool buildConditionSets(Scop &S, BasicBlock *BB, Value *Condition, /// This will fill @p ConditionSets with the conditions under which control /// will be moved from @p TI to its successors. Hence, @p ConditionSets will /// have as many elements as @p TI has successors. -bool buildConditionSets(Scop &S, BasicBlock *BB, TerminatorInst *TI, Loop *L, +bool buildConditionSets(Scop &S, BasicBlock *BB, Instruction *TI, Loop *L, __isl_keep isl_set *Domain, DenseMap<BasicBlock *, isl::set> &InvalidDomainMap, SmallVectorImpl<__isl_give isl_set *> &ConditionSets) { @@ -2393,7 +2393,7 @@ static inline BasicBlock *getRegionNodeBasicBlock(RegionNode *RN) { /// Return the @p idx'th block that is executed after @p RN. static inline BasicBlock * -getRegionNodeSuccessor(RegionNode *RN, TerminatorInst *TI, unsigned idx) { +getRegionNodeSuccessor(RegionNode *RN, Instruction *TI, unsigned idx) { if (RN->isSubRegion()) { assert(idx == 0); return RN->getNodeAs<Region>()->getExit(); @@ -2743,7 +2743,7 @@ bool Scop::buildDomainsWithBranchConstraints( HasErrorBlock = true; BasicBlock *BB = getRegionNodeBasicBlock(RN); - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); if (isa<UnreachableInst>(TI)) continue; @@ -2982,7 +2982,7 @@ bool Scop::addLoopBoundsToHeaderDomain( isl::set BackedgeCondition = nullptr; - TerminatorInst *TI = LatchBB->getTerminator(); + Instruction *TI = LatchBB->getTerminator(); BranchInst *BI = dyn_cast<BranchInst>(TI); assert(BI && "Only branch instructions allowed in loop latches"); diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index 3a5867bb1c2..2248f158c79 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -1566,7 +1566,7 @@ void RegionGenerator::copyStmt(ScopStmt &Stmt, LoopToScevMapT <S, BasicBlock *BBCopyStart = StartBlockMap[BB]; BasicBlock *BBCopyEnd = EndBlockMap[BB]; - TerminatorInst *TI = BB->getTerminator(); + Instruction *TI = BB->getTerminator(); if (isa<UnreachableInst>(TI)) { while (!BBCopyEnd->empty()) BBCopyEnd->begin()->eraseFromParent(); diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp index 8d392300bb3..fedb7b06d84 100644 --- a/polly/lib/Support/ScopHelper.cpp +++ b/polly/lib/Support/ScopHelper.cpp @@ -440,7 +440,7 @@ bool polly::isErrorBlock(BasicBlock &BB, const Region &R, LoopInfo &LI, return false; } -Value *polly::getConditionFromTerminator(TerminatorInst *TI) { +Value *polly::getConditionFromTerminator(Instruction *TI) { if (BranchInst *BR = dyn_cast<BranchInst>(TI)) { if (BR->isUnconditional()) return ConstantInt::getTrue(Type::getInt1Ty(TI->getContext())); |