[polly] r344504 - [TI removal] Make `getTerminator()` return a generic `Instruction`.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 15 03:42:50 PDT 2018


Author: chandlerc
Date: Mon Oct 15 03:42:50 2018
New Revision: 344504

URL: http://llvm.org/viewvc/llvm-project?rev=344504&view=rev
Log:
[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.

Modified:
    polly/trunk/include/polly/Support/ScopHelper.h
    polly/trunk/lib/Analysis/ScopDetection.cpp
    polly/trunk/lib/Analysis/ScopInfo.cpp
    polly/trunk/lib/CodeGen/BlockGenerators.cpp
    polly/trunk/lib/Support/ScopHelper.cpp

Modified: polly/trunk/include/polly/Support/ScopHelper.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Support/ScopHelper.h?rev=344504&r1=344503&r2=344504&view=diff
==============================================================================
--- polly/trunk/include/polly/Support/ScopHelper.h (original)
+++ polly/trunk/include/polly/Support/ScopHelper.h Mon Oct 15 03:42:50 2018
@@ -382,7 +382,7 @@ bool isErrorBlock(llvm::BasicBlock &BB,
 /// @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.
 ///

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=344504&r1=344503&r2=344504&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Mon Oct 15 03:42:50 2018
@@ -657,7 +657,7 @@ bool ScopDetection::isValidCFG(BasicBloc
                                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(Re
     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) {

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=344504&r1=344503&r2=344504&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Mon Oct 15 03:42:50 2018
@@ -1502,7 +1502,7 @@ buildUnsignedConditionSets(Scop &S, Basi
 /// 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, BasicBl
 /// 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 *getRegionNodeB
 
 /// 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::buildDomainsWithBranchConstra
       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");
 

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=344504&r1=344503&r2=344504&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Mon Oct 15 03:42:50 2018
@@ -1566,7 +1566,7 @@ void RegionGenerator::copyStmt(ScopStmt
 
     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();

Modified: polly/trunk/lib/Support/ScopHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/ScopHelper.cpp?rev=344504&r1=344503&r2=344504&view=diff
==============================================================================
--- polly/trunk/lib/Support/ScopHelper.cpp (original)
+++ polly/trunk/lib/Support/ScopHelper.cpp Mon Oct 15 03:42:50 2018
@@ -440,7 +440,7 @@ bool polly::isErrorBlock(BasicBlock &BB,
   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()));




More information about the llvm-commits mailing list