Skip to content

Commit 5993754

Browse files
committed
Merging r345353:
------------------------------------------------------------------------ r345353 | sima | 2018-10-25 18:28:36 -0700 (Thu, 25 Oct 2018) | 21 lines Teach the DominatorTree fallback to recalculation when applying updates to speedup JT (PR37929) Summary: This patch makes the dominatortree recalculate when applying updates with the size of the update vector larger than a threshold. Directly applying updates is usually slower than recalculating the whole domtree in this case. This patch fixes an issue which causes JT running slowly on some inputs. In bug 37929, the dominator tree is trying to apply 19,000+ updates several times, which takes several minutes. After this patch, the time used by DT.applyUpdates: | Input | Before (s) | After (s) | Speedup | | the 2nd Reproducer in 37929 | 297 | 0.15 | 1980x | | clang-5.0.0.0.bc | 9.7 | 4.3 | 2.26x | | clang-5.0.0.4.bc | 11.6 | 2.6 | 4.46x | Reviewers: kuhar, brzycki, trentxintong, davide, dmgreen, grosser Reviewed By: kuhar, brzycki Subscribers: kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D53245 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_70@347285 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 0599806 commit 5993754

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/llvm/Support/GenericDomTreeConstruction.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,20 @@ struct SemiNCAInfo {
11861186
<< '\t' << U << "\n");
11871187
LLVM_DEBUG(dbgs() << "\n");
11881188

1189+
// Recalculate the DominatorTree when the number of updates
1190+
// exceeds a threshold, which usually makes direct updating slower than
1191+
// recalculation. We select this threshold proportional to the
1192+
// size of the DominatorTree. The constant is selected
1193+
// by choosing the one with an acceptable performance on some real-world
1194+
// inputs.
1195+
1196+
// Make unittests of the incremental algorithm work
1197+
if (DT.DomTreeNodes.size() <= 100) {
1198+
if (NumLegalized > DT.DomTreeNodes.size())
1199+
CalculateFromScratch(DT, &BUI);
1200+
} else if (NumLegalized > DT.DomTreeNodes.size() / 40)
1201+
CalculateFromScratch(DT, &BUI);
1202+
11891203
// If the DominatorTree was recalculated at some point, stop the batch
11901204
// updates. Full recalculations ignore batch updates and look at the actual
11911205
// CFG.

0 commit comments

Comments
 (0)