[PATCH] D59696: [CGP] Build the DominatorTree lazily

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 22 07:09:07 PDT 2019


tejohnson created this revision.
tejohnson added a reviewer: spatel.
Herald added a subscriber: jdoerfert.
Herald added a project: LLVM.

In r355512 CGP was changed to build the DominatorTree only once per
function traversal, to avoid repeatedly building it each time it was
accessed. This solved one compile time issue but introduced another. In
the second case, we now were building the DT unnecessarily many times
when we performed many function traversals (i.e. more than once per
function when running CGP because of changes made each time).

Change to saving the DT in the CodeGenPrepare object, and building it
lazily when needed. It is reset whenever we need to rebuild it.

The case that exposed the issue there are 617 functions, and we walk
them (i.e. execute the "while (MadeChange)" loop in runOnFunction) a
total of 12083 times (so previously we were building the DT 12083
times). With this patch we only build the DT 844 times (average of 1.37
times per function). We dropped the total time to compile this file from
538.11s without this patch to 339.63s with it.

There is still an issue as CGP is taking much longer than all other
passes even with this patch, and before a recent compiler release cut at
r355392 the total time to this compile was only 97 sec with a huge
reduction in CGP time. I suspect that one of the other recent changes to
CGP led to iterating each function many more times on average, but I
need to do some more investigation.


Repository:
  rL LLVM

https://reviews.llvm.org/D59696

Files:
  lib/CodeGen/CodeGenPrepare.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59696.191877.patch
Type: text/x-patch
Size: 10025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190322/d35d289a/attachment.bin>


More information about the llvm-commits mailing list