[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.

git-svn-id: https://llvm.org/svn/llvm-project/polly/trunk@344504 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/polly/Support/ScopHelper.h b/include/polly/Support/ScopHelper.h
index b7455e7..4fec771 100644
--- a/include/polly/Support/ScopHelper.h
+++ b/include/polly/Support/ScopHelper.h
@@ -382,7 +382,7 @@
 /// @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/lib/Analysis/ScopDetection.cpp b/lib/Analysis/ScopDetection.cpp
index 480589e..9502f32 100644
--- a/lib/Analysis/ScopDetection.cpp
+++ b/lib/Analysis/ScopDetection.cpp
@@ -657,7 +657,7 @@
                                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 @@
     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/lib/Analysis/ScopInfo.cpp b/lib/Analysis/ScopInfo.cpp
index 9e8ee91..896a1b6 100644
--- a/lib/Analysis/ScopInfo.cpp
+++ b/lib/Analysis/ScopInfo.cpp
@@ -1502,7 +1502,7 @@
 /// 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 @@
 /// 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 @@
 
 /// 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 @@
       HasErrorBlock = true;
 
     BasicBlock *BB = getRegionNodeBasicBlock(RN);
-    TerminatorInst *TI = BB->getTerminator();
+    Instruction *TI = BB->getTerminator();
 
     if (isa<UnreachableInst>(TI))
       continue;
@@ -2982,7 +2982,7 @@
 
     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/lib/CodeGen/BlockGenerators.cpp b/lib/CodeGen/BlockGenerators.cpp
index 3a5867b..2248f15 100644
--- a/lib/CodeGen/BlockGenerators.cpp
+++ b/lib/CodeGen/BlockGenerators.cpp
@@ -1566,7 +1566,7 @@
 
     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/lib/Support/ScopHelper.cpp b/lib/Support/ScopHelper.cpp
index 8d39230..fedb7b0 100644
--- a/lib/Support/ScopHelper.cpp
+++ b/lib/Support/ScopHelper.cpp
@@ -440,7 +440,7 @@
   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()));