Skip to content

Commit 3d9b07f

Browse files
committed
[rebase][FIXME] add assert in IteratedDominanceFrontier code broken by rebased (unused)
Commenting line that does not compile and add an assert for now (this code is unused). `mlir::DominanceInfo::updateDFSNumbers` removed by llvm commit: https://github.com/flang-compiler/f18-llvm-project/blob/e8283ecc45175527ef69286a40d44668d4ed28b8/flang/lib/Optimizer/Analysis/IteratedDominanceFrontier.cpp This needs an actual fix.
1 parent 19e1502 commit 3d9b07f

File tree

1 file changed

+45
-39
lines changed

1 file changed

+45
-39
lines changed

flang/lib/Optimizer/Analysis/IteratedDominanceFrontier.cpp

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace fir {
2323

2424
template <class NodeTy, bool IsPostDom>
2525
void IDFCalculator<NodeTy, IsPostDom>::calculate(
26-
llvm::SmallVectorImpl<NodeTy *> &PHIBlocks) {
26+
llvm::SmallVectorImpl<NodeTy *> &phiBlocks) {
2727
// Use a priority queue keyed on dominator tree level so that inserted nodes
2828
// are handled from the bottom of the dominator tree upwards. We also augment
2929
// the level with a DFS number to ensure that the blocks are ordered in a
@@ -35,68 +35,74 @@ void IDFCalculator<NodeTy, IsPostDom>::calculate(
3535
std::priority_queue<DomTreeNodePair,
3636
llvm::SmallVector<DomTreeNodePair, 32>,
3737
llvm::less_second>;
38-
IDFPriorityQueue PQ;
38+
IDFPriorityQueue pq;
3939

40-
if (DefBlocks->empty())
40+
if (defBlocks->empty())
4141
return;
42-
43-
DT.updateDFSNumbers();
44-
45-
for (NodeTy *BB : *DefBlocks) {
46-
if (DomTreeNode *Node = DT.getNode(BB))
47-
PQ.push({Node, std::make_pair(Node->getLevel(), Node->getDFSNumIn())});
42+
43+
// FIXME: updateDFSNumbers was removed in:
44+
// https://github.com/llvm/llvm-project/commit/412ae15de49a227de25a695735451f8908ebf999
45+
// This code should be updated, but it is not clear how. Since the pass
46+
// is not used currently, add an assert and comment the broken
47+
// code so that it compiles.
48+
assert(true && "FIXME, this code should not be run until fixed");
49+
//dt.updateDFSNumbers();
50+
51+
for (NodeTy *bb : *defBlocks) {
52+
if (DomTreeNode *node = dt.getNode(bb))
53+
pq.push({node, std::make_pair(node->getLevel(), node->getDFSNumIn())});
4854
}
4955

50-
llvm::SmallVector<DomTreeNode *, 32> Worklist;
51-
llvm::SmallPtrSet<DomTreeNode *, 32> VisitedPQ;
52-
llvm::SmallPtrSet<DomTreeNode *, 32> VisitedWorklist;
56+
llvm::SmallVector<DomTreeNode *, 32> worklist;
57+
llvm::SmallPtrSet<DomTreeNode *, 32> visitedpq;
58+
llvm::SmallPtrSet<DomTreeNode *, 32> visitedWorklist;
5359

54-
while (!PQ.empty()) {
55-
DomTreeNodePair RootPair = PQ.top();
56-
PQ.pop();
57-
DomTreeNode *Root = RootPair.first;
58-
unsigned RootLevel = RootPair.second.first;
60+
while (!pq.empty()) {
61+
DomTreeNodePair rootPair = pq.top();
62+
pq.pop();
63+
DomTreeNode *root = rootPair.first;
64+
unsigned rootLevel = rootPair.second.first;
5965

6066
// Walk all dominator tree children of Root, inspecting their CFG edges with
6167
// targets elsewhere on the dominator tree. Only targets whose level is at
6268
// most Root's level are added to the iterated dominance frontier of the
6369
// definition set.
6470

65-
Worklist.clear();
66-
Worklist.push_back(Root);
67-
VisitedWorklist.insert(Root);
71+
worklist.clear();
72+
worklist.push_back(root);
73+
visitedWorklist.insert(root);
6874

69-
while (!Worklist.empty()) {
70-
DomTreeNode *Node = Worklist.pop_back_val();
71-
NodeTy *BB = Node->getBlock();
75+
while (!worklist.empty()) {
76+
DomTreeNode *node = worklist.pop_back_val();
77+
NodeTy *bb = node->getBlock();
7278
// Succ is the successor in the direction we are calculating IDF, so it is
7379
// successor for IDF, and predecessor for Reverse IDF.
74-
auto DoWork = [&](NodeTy *Succ) {
75-
DomTreeNode *SuccNode = DT.getNode(Succ);
80+
auto doWork = [&](NodeTy *succ) {
81+
DomTreeNode *succNode = dt.getNode(succ);
7682

77-
const unsigned SuccLevel = SuccNode->getLevel();
78-
if (SuccLevel > RootLevel)
83+
const unsigned succLevel = succNode->getLevel();
84+
if (succLevel > rootLevel)
7985
return;
8086

81-
if (!VisitedPQ.insert(SuccNode).second)
87+
if (!visitedpq.insert(succNode).second)
8288
return;
8389

84-
NodeTy *SuccBB = SuccNode->getBlock();
85-
if (useLiveIn && !LiveInBlocks->count(SuccBB))
90+
NodeTy *succBB = succNode->getBlock();
91+
if (useLiveIn && !liveInBlocks->count(succBB))
8692
return;
8793

88-
PHIBlocks.emplace_back(SuccBB);
89-
if (!DefBlocks->count(SuccBB))
90-
PQ.push(std::make_pair(
91-
SuccNode, std::make_pair(SuccLevel, SuccNode->getDFSNumIn())));
94+
phiBlocks.emplace_back(succBB);
95+
if (!defBlocks->count(succBB))
96+
pq.push(std::make_pair(
97+
succNode, std::make_pair(succLevel, succNode->getDFSNumIn())));
9298
};
9399

94-
for (auto *Succ : BB->getSuccessors())
95-
DoWork(Succ);
100+
for (auto *succ : bb->getSuccessors())
101+
doWork(succ);
96102

97-
for (auto DomChild : *Node) {
98-
if (VisitedWorklist.insert(DomChild).second)
99-
Worklist.push_back(DomChild);
103+
for (auto domChild : *node) {
104+
if (visitedWorklist.insert(domChild).second)
105+
worklist.push_back(domChild);
100106
}
101107
}
102108
}

0 commit comments

Comments
 (0)