[PATCH] D53245: Teach the DominatorTree fallback to recalculation when applying updates to speedup JT (PR37929)

Chijun Sima via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 13 07:04:52 PDT 2018


NutshellySima created this revision.
NutshellySima added reviewers: kuhar, brzycki, trentxintong, davide, dmgreen, grosser.
Herald added subscribers: llvm-commits, kristina.

This patch makes the dominatortree recalculate when applying updates with the size of the update vector larger than 650. 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.25      | 1188x   |
| clang-5.0.0.0.bc            | 9.7        | 7.2       | 1.34x   |
| clang-5.0.0.4.bc            | 11.6       | 5.2       | 2.2x    |
|


Repository:
  rL LLVM

https://reviews.llvm.org/D53245

Files:
  include/llvm/Support/GenericDomTreeConstruction.h


Index: include/llvm/Support/GenericDomTreeConstruction.h
===================================================================
--- include/llvm/Support/GenericDomTreeConstruction.h
+++ include/llvm/Support/GenericDomTreeConstruction.h
@@ -1191,6 +1191,12 @@
     });
     LLVM_DEBUG(dbgs() << "\n");
 
+    // Recalculate the DominatorTree when the number of updates
+    // exceeds a threshold, which always makes direct updating slower than
+    // recalculation.
+    if (NumLegalized >= 650)
+      CalculateFromScratch(DT, &BUI);
+
     // If the DominatorTree was recalculated at some point, stop the batch
     // updates. Full recalculations ignore batch updates and look at the actual
     // CFG.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53245.169560.patch
Type: text/x-patch
Size: 705 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181013/ebb9b0b1/attachment.bin>


More information about the llvm-commits mailing list