forked from OSchip/llvm-project
[TI removal] Switch some newly added code over to use `Instruction`
directly. llvm-svn: 344768
This commit is contained in:
parent
2386657d49
commit
608e6faa06
llvm
include/llvm/Analysis
lib/Analysis
|
@ -80,7 +80,7 @@ public:
|
||||||
void print(raw_ostream &OS, const Module *) const;
|
void print(raw_ostream &OS, const Module *) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool updateTerminator(const TerminatorInst &Term) const;
|
bool updateTerminator(const Instruction &Term) const;
|
||||||
bool updatePHINode(const PHINode &Phi) const;
|
bool updatePHINode(const PHINode &Phi) const;
|
||||||
|
|
||||||
/// \brief Computes whether \p Inst is divergent based on the
|
/// \brief Computes whether \p Inst is divergent based on the
|
||||||
|
@ -135,7 +135,7 @@ private:
|
||||||
|
|
||||||
/// \brief Propagate induced value divergence due to control divergence in \p
|
/// \brief Propagate induced value divergence due to control divergence in \p
|
||||||
/// Term.
|
/// Term.
|
||||||
void propagateBranchDivergence(const TerminatorInst &Term);
|
void propagateBranchDivergence(const Instruction &Term);
|
||||||
|
|
||||||
/// \brief Propagate divergent caused by a divergent loop exit.
|
/// \brief Propagate divergent caused by a divergent loop exit.
|
||||||
///
|
///
|
||||||
|
|
|
@ -29,8 +29,6 @@ class BasicBlock;
|
||||||
class DominatorTree;
|
class DominatorTree;
|
||||||
class Loop;
|
class Loop;
|
||||||
class PostDominatorTree;
|
class PostDominatorTree;
|
||||||
class TerminatorInst;
|
|
||||||
class TerminatorInst;
|
|
||||||
|
|
||||||
using ConstBlockSet = SmallPtrSet<const BasicBlock *, 4>;
|
using ConstBlockSet = SmallPtrSet<const BasicBlock *, 4>;
|
||||||
|
|
||||||
|
@ -59,7 +57,7 @@ public:
|
||||||
/// header. Those exit blocks are added to the returned set.
|
/// 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
|
/// 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.
|
/// 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
|
/// \brief Computes divergent join points and loop exits (in the surrounding
|
||||||
/// loop) caused by the divergent loop exits of\p Loop.
|
/// loop) caused by the divergent loop exits of\p Loop.
|
||||||
|
@ -79,7 +77,7 @@ private:
|
||||||
const LoopInfo &LI;
|
const LoopInfo &LI;
|
||||||
|
|
||||||
std::map<const Loop *, std::unique_ptr<ConstBlockSet>> CachedLoopExitJoins;
|
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;
|
CachedBranchJoins;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ void DivergenceAnalysis::addUniformOverride(const Value &UniVal) {
|
||||||
UniformOverrides.insert(&UniVal);
|
UniformOverrides.insert(&UniVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DivergenceAnalysis::updateTerminator(const TerminatorInst &Term) const {
|
bool DivergenceAnalysis::updateTerminator(const Instruction &Term) const {
|
||||||
if (Term.getNumSuccessors() <= 1)
|
if (Term.getNumSuccessors() <= 1)
|
||||||
return false;
|
return false;
|
||||||
if (auto *BranchTerm = dyn_cast<BranchInst>(&Term)) {
|
if (auto *BranchTerm = dyn_cast<BranchInst>(&Term)) {
|
||||||
|
@ -297,7 +297,7 @@ bool DivergenceAnalysis::propagateJoinDivergence(const BasicBlock &JoinBlock,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivergenceAnalysis::propagateBranchDivergence(const TerminatorInst &Term) {
|
void DivergenceAnalysis::propagateBranchDivergence(const Instruction &Term) {
|
||||||
LLVM_DEBUG(dbgs() << "propBranchDiv " << Term.getParent()->getName() << "\n");
|
LLVM_DEBUG(dbgs() << "propBranchDiv " << Term.getParent()->getName() << "\n");
|
||||||
|
|
||||||
markDivergent(Term);
|
markDivergent(Term);
|
||||||
|
@ -380,11 +380,10 @@ void DivergenceAnalysis::compute() {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// propagate divergence caused by terminator
|
// propagate divergence caused by terminator
|
||||||
if (isa<TerminatorInst>(I)) {
|
if (I.isTerminator()) {
|
||||||
auto &Term = cast<TerminatorInst>(I);
|
if (updateTerminator(I)) {
|
||||||
if (updateTerminator(Term)) {
|
|
||||||
// propagate control divergence to affected instructions
|
// propagate control divergence to affected instructions
|
||||||
propagateBranchDivergence(Term);
|
propagateBranchDivergence(I);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ struct DivergencePropagator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// find all blocks reachable by two disjoint paths from @rootTerm.
|
// 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.
|
// divergent exits.
|
||||||
// @rootBlock is either the block containing the branch or the header of the
|
// @rootBlock is either the block containing the branch or the header of the
|
||||||
// divergent loop.
|
// divergent loop.
|
||||||
|
@ -355,7 +355,7 @@ const ConstBlockSet &SyncDependenceAnalysis::join_blocks(const Loop &Loop) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConstBlockSet &
|
const ConstBlockSet &
|
||||||
SyncDependenceAnalysis::join_blocks(const TerminatorInst &Term) {
|
SyncDependenceAnalysis::join_blocks(const Instruction &Term) {
|
||||||
// trivial case
|
// trivial case
|
||||||
if (Term.getNumSuccessors() < 1) {
|
if (Term.getNumSuccessors() < 1) {
|
||||||
return EmptyBlockSet;
|
return EmptyBlockSet;
|
||||||
|
|
Loading…
Reference in New Issue