LLVM: include/llvm/Analysis/DominanceFrontierImpl.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
18#define LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
19
22#include "llvm/Config/llvm-config.h"
26#include
27#include
28
29namespace llvm {
30
31template
45
46template <class BlockT, bool IsPostDom>
49 OS << " DomFrontier for BB ";
50 if (I->first)
51 I->first->printAsOperand(OS, false);
52 else
53 OS << " <>";
54 OS << " is:\t";
55
57
58 for (const BlockT *BB : BBs) {
59 OS << ' ';
60 if (BB)
61 BB->printAsOperand(OS, false);
62 else
63 OS << "<>";
64 }
65 OS << '\n';
66 }
67}
68
69#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
70template <class BlockT, bool IsPostDom>
74#endif
75
76template
80 BlockT *BB = Node->getBlock();
82
83 std::vector<DFCalculateWorkObject> workList;
85
87 do {
89 assert(currentW && "Missing work object.");
90
91 BlockT *currentBB = currentW->currentBB;
92 BlockT *parentBB = currentW->parentBB;
93 const DomTreeNodeT *currentNode = currentW->Node;
94 const DomTreeNodeT *parentNode = currentW->parentNode;
95 assert(currentBB && "Invalid work object. Missing current Basic Block");
96 assert(currentNode && "Invalid work object. Missing current Node");
98
99
100 if (visited.insert(currentBB).second) {
101
103
104 if (DT[Succ]->getIDom() != currentNode)
106 }
107 }
108
109
110
111
112 bool visitChild = false;
113 for (typename DomTreeNodeT::const_iterator NI = currentNode->begin(),
114 NE = currentNode->end();
115 NI != NE; ++NI) {
116 DomTreeNodeT *IDominee = *NI;
117 BlockT *childBB = IDominee->getBlock();
118 if (visited.count(childBB) == 0) {
120 childBB, currentBB, IDominee, currentNode));
121 visitChild = true;
122 }
123 }
124
125
126
127 if (!visitChild) {
128 if (!parentBB) {
129 Result = &S;
130 break;
131 }
132
133 typename DomSetType::const_iterator CDFI = S.begin(), CDFE = S.end();
134 DomSetType &parentSet = this->Frontiers[parentBB];
135 for (; CDFI != CDFE; ++CDFI) {
137 parentSet.insert(*CDFI);
138 }
139 workList.pop_back();
140 }
141
142 } while (!workList.empty());
143
145}
146
147}
148
149#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines a set of templates that efficiently compute a dominator tree over a generic graph.
This file defines the SmallPtrSet class.
DFCalculateWorkObject(BlockT *B, BlockT *P, const DomTreeNodeT *N, const DomTreeNodeT *PN)
Definition DominanceFrontierImpl.h:36
BlockT * currentBB
Definition DominanceFrontierImpl.h:40
const DomTreeNodeT * parentNode
Definition DominanceFrontierImpl.h:43
DomTreeNodeBase< BlockT > DomTreeNodeT
Definition DominanceFrontierImpl.h:34
const DomTreeNodeT * Node
Definition DominanceFrontierImpl.h:42
BlockT * parentBB
Definition DominanceFrontierImpl.h:41
Base class for the actual dominator tree node.
void print(raw_ostream &OS) const
print - Convert to human readable form
Definition DominanceFrontierImpl.h:47
void dump() const
dump - Dump the dominance frontier to dbgs().
Definition DominanceFrontierImpl.h:71
SetVector< BasicBlock * > DomSetType
typename DomSetMapType::const_iterator const_iterator
bool properlyDominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
const DomSetType & calculate(const DomTreeT &DT, const DomTreeNodeT *Node)
Definition DominanceFrontierImpl.h:78
typename DominanceFrontierBase< BlockT, false >::DomSetType DomSetType
DomTreeBase< BlockT > DomTreeT
DomTreeNodeBase< BlockT > DomTreeNodeT
A vector that has set insertion semantics.
iterator end()
Get an iterator to the end of the SetVector.
iterator begin()
Get an iterator to the beginning of the SetVector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
iterator_range< typename GraphTraits< GraphType >::ChildIteratorType > children(const typename GraphTraits< GraphType >::NodeRef &G)