[TI removal] Switch some newly added code over to use `Instruction`
directly.
llvm-svn: 344768
diff --git a/llvm/include/llvm/Analysis/DivergenceAnalysis.h b/llvm/include/llvm/Analysis/DivergenceAnalysis.h
index 356c144..9fadf52 100644
--- a/llvm/include/llvm/Analysis/DivergenceAnalysis.h
+++ b/llvm/include/llvm/Analysis/DivergenceAnalysis.h
@@ -80,7 +80,7 @@
void print(raw_ostream &OS, const Module *) const;
private:
- bool updateTerminator(const TerminatorInst &Term) const;
+ bool updateTerminator(const Instruction &Term) const;
bool updatePHINode(const PHINode &Phi) const;
/// \brief Computes whether \p Inst is divergent based on the
@@ -135,7 +135,7 @@
/// \brief Propagate induced value divergence due to control divergence in \p
/// Term.
- void propagateBranchDivergence(const TerminatorInst &Term);
+ void propagateBranchDivergence(const Instruction &Term);
/// \brief Propagate divergent caused by a divergent loop exit.
///
diff --git a/llvm/include/llvm/Analysis/SyncDependenceAnalysis.h b/llvm/include/llvm/Analysis/SyncDependenceAnalysis.h
index f464c4d..df693d9 100644
--- a/llvm/include/llvm/Analysis/SyncDependenceAnalysis.h
+++ b/llvm/include/llvm/Analysis/SyncDependenceAnalysis.h
@@ -29,8 +29,6 @@
class DominatorTree;
class Loop;
class PostDominatorTree;
-class TerminatorInst;
-class TerminatorInst;
using ConstBlockSet = SmallPtrSet<const BasicBlock *, 4>;
@@ -59,7 +57,7 @@
/// header. Those exit blocks are added to the returned set.
/// If L is the parent loop of \p Term and an exit of L is in the returned
/// set then L is a divergent loop.
- const ConstBlockSet &join_blocks(const TerminatorInst &Term);
+ const ConstBlockSet &join_blocks(const Instruction &Term);
/// \brief Computes divergent join points and loop exits (in the surrounding
/// loop) caused by the divergent loop exits of\p Loop.
@@ -79,7 +77,7 @@
const LoopInfo &LI;
std::map<const Loop *, std::unique_ptr<ConstBlockSet>> CachedLoopExitJoins;
- std::map<const TerminatorInst *, std::unique_ptr<ConstBlockSet>>
+ std::map<const Instruction *, std::unique_ptr<ConstBlockSet>>
CachedBranchJoins;
};
diff --git a/llvm/lib/Analysis/DivergenceAnalysis.cpp b/llvm/lib/Analysis/DivergenceAnalysis.cpp
index 9453f68..de47445 100644
--- a/llvm/lib/Analysis/DivergenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DivergenceAnalysis.cpp
@@ -108,7 +108,7 @@
UniformOverrides.insert(&UniVal);
}
-bool DivergenceAnalysis::updateTerminator(const TerminatorInst &Term) const {
+bool DivergenceAnalysis::updateTerminator(const Instruction &Term) const {
if (Term.getNumSuccessors() <= 1)
return false;
if (auto *BranchTerm = dyn_cast<BranchInst>(&Term)) {
@@ -297,7 +297,7 @@
return false;
}
-void DivergenceAnalysis::propagateBranchDivergence(const TerminatorInst &Term) {
+void DivergenceAnalysis::propagateBranchDivergence(const Instruction &Term) {
LLVM_DEBUG(dbgs() << "propBranchDiv " << Term.getParent()->getName() << "\n");
markDivergent(Term);
@@ -380,11 +380,10 @@
continue;
// propagate divergence caused by terminator
- if (isa<TerminatorInst>(I)) {
- auto &Term = cast<TerminatorInst>(I);
- if (updateTerminator(Term)) {
+ if (I.isTerminator()) {
+ if (updateTerminator(I)) {
// propagate control divergence to affected instructions
- propagateBranchDivergence(Term);
+ propagateBranchDivergence(I);
continue;
}
}
diff --git a/llvm/lib/Analysis/SyncDependenceAnalysis.cpp b/llvm/lib/Analysis/SyncDependenceAnalysis.cpp
index 9c40ffe..e1a7e44 100644
--- a/llvm/lib/Analysis/SyncDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/SyncDependenceAnalysis.cpp
@@ -208,7 +208,7 @@
}
// find all blocks reachable by two disjoint paths from @rootTerm.
- // This method works for both divergent TerminatorInsts and loops with
+ // This method works for both divergent terminators and loops with
// divergent exits.
// @rootBlock is either the block containing the branch or the header of the
// divergent loop.
@@ -355,7 +355,7 @@
}
const ConstBlockSet &
-SyncDependenceAnalysis::join_blocks(const TerminatorInst &Term) {
+SyncDependenceAnalysis::join_blocks(const Instruction &Term) {
// trivial case
if (Term.getNumSuccessors() < 1) {
return EmptyBlockSet;