Skip to content

Commit 272085f

Browse files
authored
[DomTree] Remove unnecessary domtree level check in SemiNCA (NFC) (#73107)
runSemiNCA() currently checks that the ReverseChildren are below MinLevel in the DT, which is used when performing incremental updates. However, ReverseChildren is populated during runDFS with only the predecessors that are part of that DFS walk, which will itself be level limited in the relevant cases. As such, I don't believe that this should be checked during runSemiNCA(). This code probably dates back to a time when predecessors were not cached during runDFS and as such not limited to the visited subtree only.
1 parent 17139f3 commit 272085f

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

llvm/include/llvm/Support/GenericDomTreeConstruction.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ struct SemiNCAInfo {
268268
}
269269

270270
// This function requires DFS to be run before calling it.
271-
void runSemiNCA(DomTreeT &DT, const unsigned MinLevel = 0) {
271+
void runSemiNCA() {
272272
const unsigned NextDFSNum(NumToNode.size());
273273
SmallVector<InfoRec *, 8> NumToInfo = {nullptr};
274274
NumToInfo.reserve(NextDFSNum);
@@ -291,11 +291,6 @@ struct SemiNCAInfo {
291291
assert(NodeToInfo.contains(N) &&
292292
"ReverseChildren should not contain unreachable predecessors");
293293

294-
const TreeNodePtr TN = DT.getNode(N);
295-
// Skip predecessors whose level is above the subtree we are processing.
296-
if (TN && TN->getLevel() < MinLevel)
297-
continue;
298-
299294
unsigned SemiU = NumToInfo[eval(N, i + 1, EvalStack, NumToInfo)]->Semi;
300295
if (SemiU < WInfo.Semi) WInfo.Semi = SemiU;
301296
}
@@ -576,7 +571,7 @@ struct SemiNCAInfo {
576571
DT.Roots = FindRoots(DT, PostViewBUI);
577572
SNCA.doFullDFSWalk(DT, AlwaysDescend);
578573

579-
SNCA.runSemiNCA(DT);
574+
SNCA.runSemiNCA();
580575
if (BUI) {
581576
BUI->IsRecalculated = true;
582577
LLVM_DEBUG(
@@ -904,7 +899,7 @@ struct SemiNCAInfo {
904899

905900
SemiNCAInfo SNCA(BUI);
906901
SNCA.runDFS(Root, 0, UnreachableDescender, 0);
907-
SNCA.runSemiNCA(DT);
902+
SNCA.runSemiNCA();
908903
SNCA.attachNewSubtree(DT, Incoming);
909904

910905
LLVM_DEBUG(dbgs() << "After adding unreachable nodes\n");
@@ -998,7 +993,7 @@ struct SemiNCAInfo {
998993
SemiNCAInfo SNCA(BUI);
999994
SNCA.runDFS(ToIDom, 0, DescendBelow, 0);
1000995
LLVM_DEBUG(dbgs() << "\tRunning Semi-NCA\n");
1001-
SNCA.runSemiNCA(DT, Level);
996+
SNCA.runSemiNCA();
1002997
SNCA.reattachExistingSubtree(DT, PrevIDomSubTree);
1003998
}
1004999

@@ -1122,7 +1117,7 @@ struct SemiNCAInfo {
11221117
<< BlockNamePrinter(PrevIDom) << "\nRunning Semi-NCA\n");
11231118

11241119
// Rebuild the remaining part of affected subtree.
1125-
SNCA.runSemiNCA(DT, MinLevel);
1120+
SNCA.runSemiNCA();
11261121
SNCA.reattachExistingSubtree(DT, PrevIDom);
11271122
}
11281123

0 commit comments

Comments
 (0)