[PATCH] [MemoryDependenceAnalysis] Fix compile time slowdown
Bruno Cardoso Lopes
bruno.cardoso at gmail.com
Mon Sep 29 15:15:37 PDT 2014
Hi morisset, hfinkel, void,
One program takes ~3min to compile under -O2. This happens after a certain
function A is inlined ~700 times in a function B, inserting thousands of new
BBs. This leads to 80% of the compilation time spent in
MemoryDependenceAnalysis::getNonLocalPointerDependency, while searching for
nonlocal information for basic blocks.
Usually, to avoid spending a long time to process nonlocal loads, GVN bails out
if it gets more than 100 deps as a result from
MD->getNonLocalPointerDependency. However this only happens *after* all
nonlocal information for BBs have been computed, which is the bottleneck in
this scenario. For instance, there are 8280 times where
getNonLocalPointerDependency returns deps with more than 100 bbs and from
those, 600 times it returns more than 1000 blocks.
Bail out early during the nonlocal info computation whenever we reach a
specified threshold. This patch proposes a 100 BBs threshold, it also
reduces the compile time from 3min to 23s.
The test-suite presented no compile nor execution time regressions.
Some numbers from my machine (x86_64 darwin):
- 17s under -Oz (which avoids inlining).
- 1.3s under -O1.
- 2m51s under -O2 ToT
*** 23s under -O2 w/ Result.size() > 100
- 1m54s under -O2 w/ Result.size() > 500
As expected, w/ Result.size() > 100, GVN still yields the same outcome as in the 3min
2898 gvn - Number of loads PRE'd
1710 gvn - Number of loads deleted
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1700 bytes
Desc: not available
More information about the llvm-commits