Coverage Report

Created: 2018-09-25 00:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Analysis/DominanceFrontierImpl.h
Line
Count
Source (jump to first uncovered line)
1
//===- llvm/Analysis/DominanceFrontier.h - Dominator Frontiers --*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This is the generic implementation of the DominanceFrontier class, which
11
// calculate and holds the dominance frontier for a function for.
12
//
13
// This should be considered deprecated, don't add any more uses of this data
14
// structure.
15
//
16
//===----------------------------------------------------------------------===//
17
18
#ifndef LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
19
#define LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
20
21
#include "llvm/ADT/GraphTraits.h"
22
#include "llvm/ADT/SmallPtrSet.h"
23
#include "llvm/Analysis/DominanceFrontier.h"
24
#include "llvm/Config/llvm-config.h"
25
#include "llvm/Support/Debug.h"
26
#include "llvm/Support/GenericDomTree.h"
27
#include "llvm/Support/raw_ostream.h"
28
#include <cassert>
29
#include <set>
30
#include <utility>
31
#include <vector>
32
33
namespace llvm {
34
35
template <class BlockT>
36
class DFCalculateWorkObject {
37
public:
38
  using DomTreeNodeT = DomTreeNodeBase<BlockT>;
39
40
  DFCalculateWorkObject(BlockT *B, BlockT *P, const DomTreeNodeT *N,
41
                        const DomTreeNodeT *PN)
42
45.7k
      : currentBB(B), parentBB(P), Node(N), parentNode(PN) {}
llvm::DFCalculateWorkObject<llvm::BasicBlock>::DFCalculateWorkObject(llvm::BasicBlock*, llvm::BasicBlock*, llvm::DomTreeNodeBase<llvm::BasicBlock> const*, llvm::DomTreeNodeBase<llvm::BasicBlock> const*)
Line
Count
Source
42
34.7k
      : currentBB(B), parentBB(P), Node(N), parentNode(PN) {}
llvm::DFCalculateWorkObject<llvm::MachineBasicBlock>::DFCalculateWorkObject(llvm::MachineBasicBlock*, llvm::MachineBasicBlock*, llvm::DomTreeNodeBase<llvm::MachineBasicBlock> const*, llvm::DomTreeNodeBase<llvm::MachineBasicBlock> const*)
Line
Count
Source
42
10.9k
      : currentBB(B), parentBB(P), Node(N), parentNode(PN) {}
43
44
  BlockT *currentBB;
45
  BlockT *parentBB;
46
  const DomTreeNodeT *Node;
47
  const DomTreeNodeT *parentNode;
48
};
49
50
template <class BlockT, bool IsPostDom>
51
0
void DominanceFrontierBase<BlockT, IsPostDom>::removeBlock(BlockT *BB) {
52
0
  assert(find(BB) != end() && "Block is not in DominanceFrontier!");
53
0
  for (iterator I = begin(), E = end(); I != E; ++I)
54
0
    I->second.erase(BB);
55
0
  Frontiers.erase(BB);
56
0
}
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::BasicBlock, false>::removeBlock(llvm::BasicBlock*)
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::BasicBlock, true>::removeBlock(llvm::BasicBlock*)
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, false>::removeBlock(llvm::MachineBasicBlock*)
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, true>::removeBlock(llvm::MachineBasicBlock*)
57
58
template <class BlockT, bool IsPostDom>
59
void DominanceFrontierBase<BlockT, IsPostDom>::addToFrontier(iterator I,
60
0
                                                             BlockT *Node) {
61
0
  assert(I != end() && "BB is not in DominanceFrontier!");
62
0
  assert(I->second.count(Node) && "Node is not in DominanceFrontier of BB");
63
0
  I->second.erase(Node);
64
0
}
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::BasicBlock, false>::addToFrontier(std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<llvm::BasicBlock*, std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> > >, std::__1::__tree_node<std::__1::__value_type<llvm::BasicBlock*, std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> > >, void*>*, long> >, llvm::BasicBlock*)
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::BasicBlock, true>::addToFrontier(std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<llvm::BasicBlock*, std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> > >, std::__1::__tree_node<std::__1::__value_type<llvm::BasicBlock*, std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> > >, void*>*, long> >, llvm::BasicBlock*)
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, false>::addToFrontier(std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<llvm::MachineBasicBlock*, std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> > >, std::__1::__tree_node<std::__1::__value_type<llvm::MachineBasicBlock*, std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> > >, void*>*, long> >, llvm::MachineBasicBlock*)
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, true>::addToFrontier(std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<llvm::MachineBasicBlock*, std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> > >, std::__1::__tree_node<std::__1::__value_type<llvm::MachineBasicBlock*, std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> > >, void*>*, long> >, llvm::MachineBasicBlock*)
65
66
template <class BlockT, bool IsPostDom>
67
void DominanceFrontierBase<BlockT, IsPostDom>::removeFromFrontier(
68
0
    iterator I, BlockT *Node) {
69
0
  assert(I != end() && "BB is not in DominanceFrontier!");
70
0
  assert(I->second.count(Node) && "Node is not in DominanceFrontier of BB");
71
0
  I->second.erase(Node);
72
0
}
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::BasicBlock, false>::removeFromFrontier(std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<llvm::BasicBlock*, std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> > >, std::__1::__tree_node<std::__1::__value_type<llvm::BasicBlock*, std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> > >, void*>*, long> >, llvm::BasicBlock*)
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::BasicBlock, true>::removeFromFrontier(std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<llvm::BasicBlock*, std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> > >, std::__1::__tree_node<std::__1::__value_type<llvm::BasicBlock*, std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> > >, void*>*, long> >, llvm::BasicBlock*)
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, false>::removeFromFrontier(std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<llvm::MachineBasicBlock*, std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> > >, std::__1::__tree_node<std::__1::__value_type<llvm::MachineBasicBlock*, std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> > >, void*>*, long> >, llvm::MachineBasicBlock*)
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, true>::removeFromFrontier(std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<llvm::MachineBasicBlock*, std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> > >, std::__1::__tree_node<std::__1::__value_type<llvm::MachineBasicBlock*, std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> > >, void*>*, long> >, llvm::MachineBasicBlock*)
73
74
template <class BlockT, bool IsPostDom>
75
bool DominanceFrontierBase<BlockT, IsPostDom>::compareDomSet(
76
0
    DomSetType &DS1, const DomSetType &DS2) const {
77
0
  std::set<BlockT *> tmpSet;
78
0
  for (BlockT *BB : DS2)
79
0
    tmpSet.insert(BB);
80
0
81
0
  for (typename DomSetType::const_iterator I = DS1.begin(), E = DS1.end();
82
0
       I != E;) {
83
0
    BlockT *Node = *I++;
84
0
85
0
    if (tmpSet.erase(Node) == 0)
86
0
      // Node is in DS1 but tnot in DS2.
87
0
      return true;
88
0
  }
89
0
90
0
  if (!tmpSet.empty()) {
91
0
    // There are nodes that are in DS2 but not in DS1.
92
0
    return true;
93
0
  }
94
0
95
0
  // DS1 and DS2 matches.
96
0
  return false;
97
0
}
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::BasicBlock, false>::compareDomSet(std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> >&, std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> > const&) const
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::BasicBlock, true>::compareDomSet(std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> >&, std::__1::set<llvm::BasicBlock*, std::__1::less<llvm::BasicBlock*>, std::__1::allocator<llvm::BasicBlock*> > const&) const
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, false>::compareDomSet(std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> >&, std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> > const&) const
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, true>::compareDomSet(std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> >&, std::__1::set<llvm::MachineBasicBlock*, std::__1::less<llvm::MachineBasicBlock*>, std::__1::allocator<llvm::MachineBasicBlock*> > const&) const
98
99
template <class BlockT, bool IsPostDom>
100
bool DominanceFrontierBase<BlockT, IsPostDom>::compare(
101
0
    DominanceFrontierBase<BlockT, IsPostDom> &Other) const {
102
0
  DomSetMapType tmpFrontiers;
103
0
  for (typename DomSetMapType::const_iterator I = Other.begin(),
104
0
                                              E = Other.end();
105
0
       I != E; ++I)
106
0
    tmpFrontiers.insert(std::make_pair(I->first, I->second));
107
0
108
0
  for (typename DomSetMapType::iterator I = tmpFrontiers.begin(),
109
0
                                        E = tmpFrontiers.end();
110
0
       I != E;) {
111
0
    BlockT *Node = I->first;
112
0
    const_iterator DFI = find(Node);
113
0
    if (DFI == end())
114
0
      return true;
115
0
116
0
    if (compareDomSet(I->second, DFI->second))
117
0
      return true;
118
0
119
0
    ++I;
120
0
    tmpFrontiers.erase(Node);
121
0
  }
122
0
123
0
  if (!tmpFrontiers.empty())
124
0
    return true;
125
0
126
0
  return false;
127
0
}
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::BasicBlock, false>::compare(llvm::DominanceFrontierBase<llvm::BasicBlock, false>&) const
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::BasicBlock, true>::compare(llvm::DominanceFrontierBase<llvm::BasicBlock, true>&) const
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, false>::compare(llvm::DominanceFrontierBase<llvm::MachineBasicBlock, false>&) const
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, true>::compare(llvm::DominanceFrontierBase<llvm::MachineBasicBlock, true>&) const
128
129
template <class BlockT, bool IsPostDom>
130
2
void DominanceFrontierBase<BlockT, IsPostDom>::print(raw_ostream &OS) const {
131
12
  for (const_iterator I = begin(), E = end(); I != E; 
++I10
) {
132
10
    OS << "  DomFrontier for BB ";
133
10
    if (I->first)
134
10
      I->first->printAsOperand(OS, false);
135
0
    else
136
0
      OS << " <<exit node>>";
137
10
    OS << " is:\t";
138
10
139
10
    const std::set<BlockT *> &BBs = I->second;
140
10
141
10
    for (const BlockT *BB : BBs) {
142
6
      OS << ' ';
143
6
      if (BB)
144
6
        BB->printAsOperand(OS, false);
145
0
      else
146
0
        OS << "<<exit node>>";
147
6
    }
148
10
    OS << '\n';
149
10
  }
150
2
}
llvm::DominanceFrontierBase<llvm::BasicBlock, false>::print(llvm::raw_ostream&) const
Line
Count
Source
130
2
void DominanceFrontierBase<BlockT, IsPostDom>::print(raw_ostream &OS) const {
131
12
  for (const_iterator I = begin(), E = end(); I != E; 
++I10
) {
132
10
    OS << "  DomFrontier for BB ";
133
10
    if (I->first)
134
10
      I->first->printAsOperand(OS, false);
135
0
    else
136
0
      OS << " <<exit node>>";
137
10
    OS << " is:\t";
138
10
139
10
    const std::set<BlockT *> &BBs = I->second;
140
10
141
10
    for (const BlockT *BB : BBs) {
142
6
      OS << ' ';
143
6
      if (BB)
144
6
        BB->printAsOperand(OS, false);
145
0
      else
146
0
        OS << "<<exit node>>";
147
6
    }
148
10
    OS << '\n';
149
10
  }
150
2
}
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::BasicBlock, true>::print(llvm::raw_ostream&) const
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, false>::print(llvm::raw_ostream&) const
Unexecuted instantiation: llvm::DominanceFrontierBase<llvm::MachineBasicBlock, true>::print(llvm::raw_ostream&) const
151
152
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
153
template <class BlockT, bool IsPostDom>
154
void DominanceFrontierBase<BlockT, IsPostDom>::dump() const {
155
  print(dbgs());
156
}
157
#endif
158
159
template <class BlockT>
160
const typename ForwardDominanceFrontierBase<BlockT>::DomSetType &
161
ForwardDominanceFrontierBase<BlockT>::calculate(const DomTreeT &DT,
162
29.4k
                                                const DomTreeNodeT *Node) {
163
29.4k
  BlockT *BB = Node->getBlock();
164
29.4k
  DomSetType *Result = nullptr;
165
29.4k
166
29.4k
  std::vector<DFCalculateWorkObject<BlockT>> workList;
167
29.4k
  SmallPtrSet<BlockT *, 32> visited;
168
29.4k
169
29.4k
  workList.push_back(DFCalculateWorkObject<BlockT>(BB, nullptr, Node, nullptr));
170
57.1k
  do {
171
57.1k
    DFCalculateWorkObject<BlockT> *currentW = &workList.back();
172
57.1k
    assert(currentW && "Missing work object.");
173
57.1k
174
57.1k
    BlockT *currentBB = currentW->currentBB;
175
57.1k
    BlockT *parentBB = currentW->parentBB;
176
57.1k
    const DomTreeNodeT *currentNode = currentW->Node;
177
57.1k
    const DomTreeNodeT *parentNode = currentW->parentNode;
178
57.1k
    assert(currentBB && "Invalid work object. Missing current Basic Block");
179
57.1k
    assert(currentNode && "Invalid work object. Missing current Node");
180
57.1k
    DomSetType &S = this->Frontiers[currentBB];
181
57.1k
182
57.1k
    // Visit each block only once.
183
57.1k
    if (visited.insert(currentBB).second) {
184
45.7k
      // Loop over CFG successors to calculate DFlocal[currentNode]
185
45.7k
      for (const auto Succ : children<BlockT *>(currentBB)) {
186
22.6k
        // Does Node immediately dominate this successor?
187
22.6k
        if (DT[Succ]->getIDom() != currentNode)
188
7.07k
          S.insert(Succ);
189
22.6k
      }
190
45.7k
    }
191
57.1k
192
57.1k
    // At this point, S is DFlocal.  Now we union in DFup's of our children...
193
57.1k
    // Loop through and visit the nodes that Node immediately dominates (Node's
194
57.1k
    // children in the IDomTree)
195
57.1k
    bool visitChild = false;
196
57.1k
    for (typename DomTreeNodeT::const_iterator NI = currentNode->begin(),
197
57.1k
                                               NE = currentNode->end();
198
89.6k
         NI != NE; 
++NI32.4k
) {
199
32.4k
      DomTreeNodeT *IDominee = *NI;
200
32.4k
      BlockT *childBB = IDominee->getBlock();
201
32.4k
      if (visited.count(childBB) == 0) {
202
16.2k
        workList.push_back(DFCalculateWorkObject<BlockT>(
203
16.2k
            childBB, currentBB, IDominee, currentNode));
204
16.2k
        visitChild = true;
205
16.2k
      }
206
32.4k
    }
207
57.1k
208
57.1k
    // If all children are visited or there is any child then pop this block
209
57.1k
    // from the workList.
210
57.1k
    if (!visitChild) {
211
45.7k
      if (!parentBB) {
212
29.4k
        Result = &S;
213
29.4k
        break;
214
29.4k
      }
215
16.2k
216
16.2k
      typename DomSetType::const_iterator CDFI = S.begin(), CDFE = S.end();
217
16.2k
      DomSetType &parentSet = this->Frontiers[parentBB];
218
29.9k
      for (; CDFI != CDFE; 
++CDFI13.7k
) {
219
13.7k
        if (!DT.properlyDominates(parentNode, DT[*CDFI]))
220
7.10k
          parentSet.insert(*CDFI);
221
13.7k
      }
222
16.2k
      workList.pop_back();
223
16.2k
    }
224
57.1k
225
57.1k
  } while (
!workList.empty()27.6k
);
226
29.4k
227
29.4k
  return *Result;
228
29.4k
}
llvm::ForwardDominanceFrontierBase<llvm::BasicBlock>::calculate(llvm::DominatorTreeBase<llvm::BasicBlock, false> const&, llvm::DomTreeNodeBase<llvm::BasicBlock> const*)
Line
Count
Source
162
22.8k
                                                const DomTreeNodeT *Node) {
163
22.8k
  BlockT *BB = Node->getBlock();
164
22.8k
  DomSetType *Result = nullptr;
165
22.8k
166
22.8k
  std::vector<DFCalculateWorkObject<BlockT>> workList;
167
22.8k
  SmallPtrSet<BlockT *, 32> visited;
168
22.8k
169
22.8k
  workList.push_back(DFCalculateWorkObject<BlockT>(BB, nullptr, Node, nullptr));
170
43.1k
  do {
171
43.1k
    DFCalculateWorkObject<BlockT> *currentW = &workList.back();
172
43.1k
    assert(currentW && "Missing work object.");
173
43.1k
174
43.1k
    BlockT *currentBB = currentW->currentBB;
175
43.1k
    BlockT *parentBB = currentW->parentBB;
176
43.1k
    const DomTreeNodeT *currentNode = currentW->Node;
177
43.1k
    const DomTreeNodeT *parentNode = currentW->parentNode;
178
43.1k
    assert(currentBB && "Invalid work object. Missing current Basic Block");
179
43.1k
    assert(currentNode && "Invalid work object. Missing current Node");
180
43.1k
    DomSetType &S = this->Frontiers[currentBB];
181
43.1k
182
43.1k
    // Visit each block only once.
183
43.1k
    if (visited.insert(currentBB).second) {
184
34.7k
      // Loop over CFG successors to calculate DFlocal[currentNode]
185
34.7k
      for (const auto Succ : children<BlockT *>(currentBB)) {
186
16.2k
        // Does Node immediately dominate this successor?
187
16.2k
        if (DT[Succ]->getIDom() != currentNode)
188
4.78k
          S.insert(Succ);
189
16.2k
      }
190
34.7k
    }
191
43.1k
192
43.1k
    // At this point, S is DFlocal.  Now we union in DFup's of our children...
193
43.1k
    // Loop through and visit the nodes that Node immediately dominates (Node's
194
43.1k
    // children in the IDomTree)
195
43.1k
    bool visitChild = false;
196
43.1k
    for (typename DomTreeNodeT::const_iterator NI = currentNode->begin(),
197
43.1k
                                               NE = currentNode->end();
198
66.8k
         NI != NE; 
++NI23.6k
) {
199
23.6k
      DomTreeNodeT *IDominee = *NI;
200
23.6k
      BlockT *childBB = IDominee->getBlock();
201
23.6k
      if (visited.count(childBB) == 0) {
202
11.8k
        workList.push_back(DFCalculateWorkObject<BlockT>(
203
11.8k
            childBB, currentBB, IDominee, currentNode));
204
11.8k
        visitChild = true;
205
11.8k
      }
206
23.6k
    }
207
43.1k
208
43.1k
    // If all children are visited or there is any child then pop this block
209
43.1k
    // from the workList.
210
43.1k
    if (!visitChild) {
211
34.7k
      if (!parentBB) {
212
22.8k
        Result = &S;
213
22.8k
        break;
214
22.8k
      }
215
11.8k
216
11.8k
      typename DomSetType::const_iterator CDFI = S.begin(), CDFE = S.end();
217
11.8k
      DomSetType &parentSet = this->Frontiers[parentBB];
218
21.7k
      for (; CDFI != CDFE; 
++CDFI9.91k
) {
219
9.91k
        if (!DT.properlyDominates(parentNode, DT[*CDFI]))
220
5.38k
          parentSet.insert(*CDFI);
221
9.91k
      }
222
11.8k
      workList.pop_back();
223
11.8k
    }
224
43.1k
225
43.1k
  } while (
!workList.empty()20.3k
);
226
22.8k
227
22.8k
  return *Result;
228
22.8k
}
llvm::ForwardDominanceFrontierBase<llvm::MachineBasicBlock>::calculate(llvm::DominatorTreeBase<llvm::MachineBasicBlock, false> const&, llvm::DomTreeNodeBase<llvm::MachineBasicBlock> const*)
Line
Count
Source
162
6.58k
                                                const DomTreeNodeT *Node) {
163
6.58k
  BlockT *BB = Node->getBlock();
164
6.58k
  DomSetType *Result = nullptr;
165
6.58k
166
6.58k
  std::vector<DFCalculateWorkObject<BlockT>> workList;
167
6.58k
  SmallPtrSet<BlockT *, 32> visited;
168
6.58k
169
6.58k
  workList.push_back(DFCalculateWorkObject<BlockT>(BB, nullptr, Node, nullptr));
170
13.9k
  do {
171
13.9k
    DFCalculateWorkObject<BlockT> *currentW = &workList.back();
172
13.9k
    assert(currentW && "Missing work object.");
173
13.9k
174
13.9k
    BlockT *currentBB = currentW->currentBB;
175
13.9k
    BlockT *parentBB = currentW->parentBB;
176
13.9k
    const DomTreeNodeT *currentNode = currentW->Node;
177
13.9k
    const DomTreeNodeT *parentNode = currentW->parentNode;
178
13.9k
    assert(currentBB && "Invalid work object. Missing current Basic Block");
179
13.9k
    assert(currentNode && "Invalid work object. Missing current Node");
180
13.9k
    DomSetType &S = this->Frontiers[currentBB];
181
13.9k
182
13.9k
    // Visit each block only once.
183
13.9k
    if (visited.insert(currentBB).second) {
184
10.9k
      // Loop over CFG successors to calculate DFlocal[currentNode]
185
10.9k
      for (const auto Succ : children<BlockT *>(currentBB)) {
186
6.42k
        // Does Node immediately dominate this successor?
187
6.42k
        if (DT[Succ]->getIDom() != currentNode)
188
2.29k
          S.insert(Succ);
189
6.42k
      }
190
10.9k
    }
191
13.9k
192
13.9k
    // At this point, S is DFlocal.  Now we union in DFup's of our children...
193
13.9k
    // Loop through and visit the nodes that Node immediately dominates (Node's
194
13.9k
    // children in the IDomTree)
195
13.9k
    bool visitChild = false;
196
13.9k
    for (typename DomTreeNodeT::const_iterator NI = currentNode->begin(),
197
13.9k
                                               NE = currentNode->end();
198
22.7k
         NI != NE; 
++NI8.82k
) {
199
8.82k
      DomTreeNodeT *IDominee = *NI;
200
8.82k
      BlockT *childBB = IDominee->getBlock();
201
8.82k
      if (visited.count(childBB) == 0) {
202
4.41k
        workList.push_back(DFCalculateWorkObject<BlockT>(
203
4.41k
            childBB, currentBB, IDominee, currentNode));
204
4.41k
        visitChild = true;
205
4.41k
      }
206
8.82k
    }
207
13.9k
208
13.9k
    // If all children are visited or there is any child then pop this block
209
13.9k
    // from the workList.
210
13.9k
    if (!visitChild) {
211
10.9k
      if (!parentBB) {
212
6.58k
        Result = &S;
213
6.58k
        break;
214
6.58k
      }
215
4.41k
216
4.41k
      typename DomSetType::const_iterator CDFI = S.begin(), CDFE = S.end();
217
4.41k
      DomSetType &parentSet = this->Frontiers[parentBB];
218
8.20k
      for (; CDFI != CDFE; 
++CDFI3.79k
) {
219
3.79k
        if (!DT.properlyDominates(parentNode, DT[*CDFI]))
220
1.71k
          parentSet.insert(*CDFI);
221
3.79k
      }
222
4.41k
      workList.pop_back();
223
4.41k
    }
224
13.9k
225
13.9k
  } while (
!workList.empty()7.38k
);
226
6.58k
227
6.58k
  return *Result;
228
6.58k
}
229
230
} // end namespace llvm
231
232
#endif // LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H