23 #define DEBUG_TYPE "ddg" 37 assert(IList.
empty() &&
"Expected the IList to be empty on entry.");
38 if (isa<SimpleDDGNode>(
this)) {
39 for (
Instruction *
I : cast<const SimpleDDGNode>(
this)->getInstructions())
42 }
else if (isa<PiBlockDDGNode>(
this)) {
43 for (
const DDGNode *PN : cast<const PiBlockDDGNode>(
this)->getNodes()) {
44 assert(!isa<PiBlockDDGNode>(PN) &&
"Nested PiBlocks are not supported.");
46 PN->collectInstructions(Pred, TmpIList);
51 return !IList.
empty();
58 Out =
"single-instruction";
61 Out =
"multi-instruction";
78 OS <<
"Node Address:" << &N <<
":" << N.
getKind() <<
"\n";
79 if (isa<SimpleDDGNode>(N)) {
80 OS <<
" Instructions:\n";
81 for (
const Instruction *
I : cast<const SimpleDDGNode>(N).getInstructions())
83 }
else if (isa<PiBlockDDGNode>(&N)) {
84 OS <<
"--- start of nodes in pi-block ---\n";
85 auto &Nodes = cast<const PiBlockDDGNode>(&
N)->getNodes();
88 OS << *N << (++Count == Nodes.size() ?
"" :
"\n");
89 OS <<
"--- end of nodes in pi-block ---\n";
90 }
else if (!isa<RootDDGNode>(N))
93 OS << (N.
getEdges().
empty() ?
" Edges:none!\n" :
" Edges:\n");
105 assert(InstList.empty() &&
"Expected empty list.");
106 InstList.push_back(&I);
110 :
DDGNode(N), InstList(N.InstList) {
113 "constructing from invalid simple node.");
120 "constructing from invalid simple node.");
131 assert(!
NodeList.empty() &&
"pi-block node constructed with an empty list.");
137 "constructing from invalid pi-block node.");
143 "constructing from invalid pi-block node.");
229 "Root node is already added. No more nodes can be added.");
231 if (isa<RootDDGNode>(N))
235 for (
DDGNode *NI : Pi->getNodes())
236 PiBlockMap.
insert(std::make_pair(NI, Pi));
242 if (PiBlockMap.
find(&N) == PiBlockMap.
end())
244 auto *Pi = PiBlockMap.
find(&N)->second;
246 "Nested pi-blocks detected.");
254 if (!G.getPiBlock(*Node))
273 return std::make_unique<DataDependenceGraph>(L, AR.
LI,
DI);
This builds on the llvm/ADT/GraphTraits.h file to find the strongly connected components (SCCs) of a ...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents lattice values for constants.
Data Dependency Graph Edge.
DataDependenceGraph()=delete
Data Dependence Graph Node The graph can represent the following types of nodes:
void push_back(const T &Elt)
const NodeType & getTargetNode() const
Retrieve the target node this edge connects to.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
An efficient, type-erasing, non-owning reference to a callable.
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
DependenceInfo - This class is the main dependence-analysis driver.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static StringRef getName(Value *V)
RPOIterator endRPO() const
BlockT * getHeader() const
Subclass of DDGNode representing a pi-block.
scc_iterator< T > scc_begin(const T &G)
Construct the begin iterator for a deduced graph type T.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
const EdgeListTy & getEdges() const
Retrieve the outgoing edges for the node.
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
EdgeKind getKind() const
Get the edge kind.
void perform(LoopInfo *LI)
Traverse the loop blocks and store the DFS result.
iterator find(const_arg_type_t< KeyT > Val)
initializer< Ty > init(const Ty &Val)
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
Represent an edge in the directed graph.
scc_iterator< T > scc_end(const T &G)
Construct the end iterator for a deduced graph type T.
EdgeKind
The kind of edge in the DDG.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const StringRef getName() const
Return the label that is used to name this graph.
NodeKind getKind() const
Getter for the kind of this node.
Determine the kind of a node from its type.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
bool addNode(NodeType &N)
Add node N to the graph, if it's not added yet, and keep track of the root node as well as pi-blocks ...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
std::unique_ptr< DataDependenceGraph > Result
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Encapsulate some common data and functionality needed for different variations of data dependence gra...
Represent a node in the directed graph.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
bool shouldCreatePiBlocks() const final override
Return true if creation of pi-blocks are supported and desired, and false otherwise.
Result run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR)
DDG as a loop pass.
Store the result of a depth first search within basic blocks contained by a single loop...
iterator insert(iterator I, T &&Elt)
Analysis pass that builds the DDG for a loop.
LLVM_NODISCARD bool empty() const
Represents a single loop in the control flow graph.
StringRef getName() const
Return a constant reference to the value's name.
const Function * getParent() const
Return the enclosing method, or null if none.
bool empty() const
Determine if the SetVector is empty or not.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Subclass of DDGNode representing single or multi-instruction nodes.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool addNode(NodeType &N)
Add the given node N to the graph if it is not already present.
RPOIterator beginRPO() const
Reverse iterate over the cached postorder blocks.
static const Function * getParent(const Value *V)
This class implements an extremely fast bulk output stream that can only output to a stream...
const PiBlockDDGNode * getPiBlock(const NodeType &N) const
If node N belongs to a pi-block return a pointer to the pi-block, otherwise return null...
A container for analyses that lazily runs them and caches their results.
static cl::opt< bool > CreatePiBlocks("ddg-pi-blocks", cl::init(true), cl::Hidden, cl::ZeroOrMore, cl::desc("Create pi-block nodes."))
A special type used by analysis passes to provide an address that identifies that particular analysis...
bool collectInstructions(llvm::function_ref< bool(Instruction *)> const &Pred, InstructionListType &IList) const
Collect a list of instructions, in IList, for which predicate Pred evaluates to true when iterating o...