Coverage Report

Created: 2018-12-14 11:24

/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
51.8k
      : 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
36.5k
      : 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
15.2k
      : 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
34.4k
                                                const DomTreeNodeT *Node) {
163
34.4k
  BlockT *BB = Node->getBlock();
164
34.4k
  DomSetType *Result = nullptr;
165
34.4k
166
34.4k
  std::vector<DFCalculateWorkObject<BlockT>> workList;
167
34.4k
  SmallPtrSet<BlockT *, 32> visited;
168
34.4k
169
34.4k
  workList.push_back(DFCalculateWorkObject<BlockT>(BB, nullptr, Node, nullptr));
170
63.9k
  do {
171
63.9k
    DFCalculateWorkObject<BlockT> *currentW = &workList.back();
172
63.9k
    assert(currentW && "Missing work object.");
173
63.9k
174
63.9k
    BlockT *currentBB = currentW->currentBB;
175
63.9k
    BlockT *parentBB = currentW->parentBB;
176
63.9k
    const DomTreeNodeT *currentNode = currentW->Node;
177
63.9k
    const DomTreeNodeT *parentNode = currentW->parentNode;
178
63.9k
    assert(currentBB && "Invalid work object. Missing current Basic Block");
179
63.9k
    assert(currentNode && "Invalid work object. Missing current Node");
180
63.9k
    DomSetType &S = this->Frontiers[currentBB];
181
63.9k
182
63.9k
    // Visit each block only once.
183
63.9k
    if (visited.insert(currentBB).second) {
184
51.8k
      // Loop over CFG successors to calculate DFlocal[currentNode]
185
51.8k
      for (const auto Succ : children<BlockT *>(currentBB)) {
186
24.2k
        // Does Node immediately dominate this successor?
187
24.2k
        if (DT[Succ]->getIDom() != currentNode)
188
7.60k
          S.insert(Succ);
189
24.2k
      }
190
51.8k
    }
191
63.9k
192
63.9k
    // At this point, S is DFlocal.  Now we union in DFup's of our children...
193
63.9k
    // Loop through and visit the nodes that Node immediately dominates (Node's
194
63.9k
    // children in the IDomTree)
195
63.9k
    bool visitChild = false;
196
63.9k
    for (typename DomTreeNodeT::const_iterator NI = currentNode->begin(),
197
63.9k
                                               NE = currentNode->end();
198
98.7k
         NI != NE; 
++NI34.8k
) {
199
34.8k
      DomTreeNodeT *IDominee = *NI;
200
34.8k
      BlockT *childBB = IDominee->getBlock();
201
34.8k
      if (visited.count(childBB) == 0) {
202
17.4k
        workList.push_back(DFCalculateWorkObject<BlockT>(
203
17.4k
            childBB, currentBB, IDominee, currentNode));
204
17.4k
        visitChild = true;
205
17.4k
      }
206
34.8k
    }
207
63.9k
208
63.9k
    // If all children are visited or there is any child then pop this block
209
63.9k
    // from the workList.
210
63.9k
    if (!visitChild) {
211
51.8k
      if (!parentBB) {
212
34.4k
        Result = &S;
213
34.4k
        break;
214
34.4k
      }
215
17.4k
216
17.4k
      typename DomSetType::const_iterator CDFI = S.begin(), CDFE = S.end();
217
17.4k
      DomSetType &parentSet = this->Frontiers[parentBB];
218
32.0k
      for (; CDFI != CDFE; 
++CDFI14.6k
) {
219
14.6k
        if (!DT.properlyDominates(parentNode, DT[*CDFI]))
220
7.53k
          parentSet.insert(*CDFI);
221
14.6k
      }
222
17.4k
      workList.pop_back();
223
17.4k
    }
224
63.9k
225
63.9k
  } while (
!workList.empty()29.5k
);
226
34.4k
227
34.4k
  return *Result;
228
34.4k
}
llvm::ForwardDominanceFrontierBase<llvm::BasicBlock>::calculate(llvm::DominatorTreeBase<llvm::BasicBlock, false> const&, llvm::DomTreeNodeBase<llvm::BasicBlock> const*)
Line
Count
Source
162
24.2k
                                                const DomTreeNodeT *Node) {
163
24.2k
  BlockT *BB = Node->getBlock();
164
24.2k
  DomSetType *Result = nullptr;
165
24.2k
166
24.2k
  std::vector<DFCalculateWorkObject<BlockT>> workList;
167
24.2k
  SmallPtrSet<BlockT *, 32> visited;
168
24.2k
169
24.2k
  workList.push_back(DFCalculateWorkObject<BlockT>(BB, nullptr, Node, nullptr));
170
45.3k
  do {
171
45.3k
    DFCalculateWorkObject<BlockT> *currentW = &workList.back();
172
45.3k
    assert(currentW && "Missing work object.");
173
45.3k
174
45.3k
    BlockT *currentBB = currentW->currentBB;
175
45.3k
    BlockT *parentBB = currentW->parentBB;
176
45.3k
    const DomTreeNodeT *currentNode = currentW->Node;
177
45.3k
    const DomTreeNodeT *parentNode = currentW->parentNode;
178
45.3k
    assert(currentBB && "Invalid work object. Missing current Basic Block");
179
45.3k
    assert(currentNode && "Invalid work object. Missing current Node");
180
45.3k
    DomSetType &S = this->Frontiers[currentBB];
181
45.3k
182
45.3k
    // Visit each block only once.
183
45.3k
    if (visited.insert(currentBB).second) {
184
36.5k
      // Loop over CFG successors to calculate DFlocal[currentNode]
185
36.5k
      for (const auto Succ : children<BlockT *>(currentBB)) {
186
16.9k
        // Does Node immediately dominate this successor?
187
16.9k
        if (DT[Succ]->getIDom() != currentNode)
188
5.02k
          S.insert(Succ);
189
16.9k
      }
190
36.5k
    }
191
45.3k
192
45.3k
    // At this point, S is DFlocal.  Now we union in DFup's of our children...
193
45.3k
    // Loop through and visit the nodes that Node immediately dominates (Node's
194
45.3k
    // children in the IDomTree)
195
45.3k
    bool visitChild = false;
196
45.3k
    for (typename DomTreeNodeT::const_iterator NI = currentNode->begin(),
197
45.3k
                                               NE = currentNode->end();
198
70.0k
         NI != NE; 
++NI24.6k
) {
199
24.6k
      DomTreeNodeT *IDominee = *NI;
200
24.6k
      BlockT *childBB = IDominee->getBlock();
201
24.6k
      if (visited.count(childBB) == 0) {
202
12.3k
        workList.push_back(DFCalculateWorkObject<BlockT>(
203
12.3k
            childBB, currentBB, IDominee, currentNode));
204
12.3k
        visitChild = true;
205
12.3k
      }
206
24.6k
    }
207
45.3k
208
45.3k
    // If all children are visited or there is any child then pop this block
209
45.3k
    // from the workList.
210
45.3k
    if (!visitChild) {
211
36.5k
      if (!parentBB) {
212
24.2k
        Result = &S;
213
24.2k
        break;
214
24.2k
      }
215
12.3k
216
12.3k
      typename DomSetType::const_iterator CDFI = S.begin(), CDFE = S.end();
217
12.3k
      DomSetType &parentSet = this->Frontiers[parentBB];
218
22.7k
      for (; CDFI != CDFE; 
++CDFI10.3k
) {
219
10.3k
        if (!DT.properlyDominates(parentNode, DT[*CDFI]))
220
5.61k
          parentSet.insert(*CDFI);
221
10.3k
      }
222
12.3k
      workList.pop_back();
223
12.3k
    }
224
45.3k
225
45.3k
  } while (
!workList.empty()21.1k
);
226
24.2k
227
24.2k
  return *Result;
228
24.2k
}
llvm::ForwardDominanceFrontierBase<llvm::MachineBasicBlock>::calculate(llvm::DominatorTreeBase<llvm::MachineBasicBlock, false> const&, llvm::DomTreeNodeBase<llvm::MachineBasicBlock> const*)
Line
Count
Source
162
10.1k
                                                const DomTreeNodeT *Node) {
163
10.1k
  BlockT *BB = Node->getBlock();
164
10.1k
  DomSetType *Result = nullptr;
165
10.1k
166
10.1k
  std::vector<DFCalculateWorkObject<BlockT>> workList;
167
10.1k
  SmallPtrSet<BlockT *, 32> visited;
168
10.1k
169
10.1k
  workList.push_back(DFCalculateWorkObject<BlockT>(BB, nullptr, Node, nullptr));
170
18.5k
  do {
171
18.5k
    DFCalculateWorkObject<BlockT> *currentW = &workList.back();
172
18.5k
    assert(currentW && "Missing work object.");
173
18.5k
174
18.5k
    BlockT *currentBB = currentW->currentBB;
175
18.5k
    BlockT *parentBB = currentW->parentBB;
176
18.5k
    const DomTreeNodeT *currentNode = currentW->Node;
177
18.5k
    const DomTreeNodeT *parentNode = currentW->parentNode;
178
18.5k
    assert(currentBB && "Invalid work object. Missing current Basic Block");
179
18.5k
    assert(currentNode && "Invalid work object. Missing current Node");
180
18.5k
    DomSetType &S = this->Frontiers[currentBB];
181
18.5k
182
18.5k
    // Visit each block only once.
183
18.5k
    if (visited.insert(currentBB).second) {
184
15.2k
      // Loop over CFG successors to calculate DFlocal[currentNode]
185
15.2k
      for (const auto Succ : children<BlockT *>(currentBB)) {
186
7.31k
        // Does Node immediately dominate this successor?
187
7.31k
        if (DT[Succ]->getIDom() != currentNode)
188
2.57k
          S.insert(Succ);
189
7.31k
      }
190
15.2k
    }
191
18.5k
192
18.5k
    // At this point, S is DFlocal.  Now we union in DFup's of our children...
193
18.5k
    // Loop through and visit the nodes that Node immediately dominates (Node's
194
18.5k
    // children in the IDomTree)
195
18.5k
    bool visitChild = false;
196
18.5k
    for (typename DomTreeNodeT::const_iterator NI = currentNode->begin(),
197
18.5k
                                               NE = currentNode->end();
198
28.7k
         NI != NE; 
++NI10.1k
) {
199
10.1k
      DomTreeNodeT *IDominee = *NI;
200
10.1k
      BlockT *childBB = IDominee->getBlock();
201
10.1k
      if (visited.count(childBB) == 0) {
202
5.06k
        workList.push_back(DFCalculateWorkObject<BlockT>(
203
5.06k
            childBB, currentBB, IDominee, currentNode));
204
5.06k
        visitChild = true;
205
5.06k
      }
206
10.1k
    }
207
18.5k
208
18.5k
    // If all children are visited or there is any child then pop this block
209
18.5k
    // from the workList.
210
18.5k
    if (!visitChild) {
211
15.2k
      if (!parentBB) {
212
10.1k
        Result = &S;
213
10.1k
        break;
214
10.1k
      }
215
5.06k
216
5.06k
      typename DomSetType::const_iterator CDFI = S.begin(), CDFE = S.end();
217
5.06k
      DomSetType &parentSet = this->Frontiers[parentBB];
218
9.28k
      for (; CDFI != CDFE; 
++CDFI4.22k
) {
219
4.22k
        if (!DT.properlyDominates(parentNode, DT[*CDFI]))
220
1.92k
          parentSet.insert(*CDFI);
221
4.22k
      }
222
5.06k
      workList.pop_back();
223
5.06k
    }
224
18.5k
225
18.5k
  } while (
!workList.empty()8.40k
);
226
10.1k
227
10.1k
  return *Result;
228
10.1k
}
229
230
} // end namespace llvm
231
232
#endif // LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H