llvm-project/llvm/unittests/Transforms/Utils
Vedant Kumar c299006879 [HotColdSplitting] Identify larger cold regions using domtree queries
The current splitting algorithm works in three stages:

  1) Identify cold blocks, then
  2) Use forward/backward propagation to mark hot blocks, then
  3) Grow a SESE region of blocks *outside* of the set of hot blocks and
  start outlining.

While testing this pass on Apple internal frameworks I noticed that some
kinds of control flow (e.g. loops) are never outlined, even though they
unconditionally lead to / follow cold blocks. I noticed two other issues
related to how cold regions are identified:

  - An inconsistency can arise in the internal state of the hotness
  propagation stage, as a block may end up in both the ColdBlocks set
  and the HotBlocks set. Further inconsistencies can arise as these sets
  do not match what's in ProfileSummaryInfo.

  - It isn't necessary to limit outlining to single-exit regions.

This patch teaches the splitting algorithm to identify maximal cold
regions and outline them. A maximal cold region is defined as the set of
blocks post-dominated by a cold sink block, or dominated by that sink
block. This approach can successfully outline loops in the cold path. As
a side benefit, it maintains less internal state than the current
approach.

Due to a limitation in CodeExtractor, blocks within the maximal cold
region which aren't dominated by a single entry point (a so-called "max
ancestor") are filtered out.

Results:
  - X86 (LNT + -Os + externals): 134KB of TEXT were outlined compared to
  47KB pre-patch, or a ~3x improvement. Did not see a performance impact
  across two runs.
  - AArch64 (LNT + -Os + externals + Apple-internal benchmarks): 149KB
  of TEXT were outlined. Ditto re: performance impact.
  - Outlining results improve marginally in the internal frameworks I
  tested.

Follow-ups:
  - Outline more than once per function, outline large single basic
  blocks, & try to remove unconditional branches in outlined functions.

Differential Revision: https://reviews.llvm.org/D53627

llvm-svn: 345209
2018-10-24 22:15:41 +00:00
..
ASanStackFrameLayoutTest.cpp [asan] Add a full redzone after every stack variable 2017-11-18 01:13:18 +00:00
BasicBlockUtilsTest.cpp Rename a few unittests/.../Foo.cpp files to FooTest.cpp 2018-09-03 12:43:26 +00:00
CMakeLists.txt [LoopUnroll] Add check to Latch's terminator in UnrollRuntimeLoopRemainder 2018-09-25 10:08:47 +00:00
CloningTest.cpp Rename a few unittests/.../Foo.cpp files to FooTest.cpp 2018-09-03 12:43:26 +00:00
CodeExtractorTest.cpp [HotColdSplitting] Identify larger cold regions using domtree queries 2018-10-24 22:15:41 +00:00
FunctionComparatorTest.cpp Rename a few unittests/.../Foo.cpp files to FooTest.cpp 2018-09-03 12:43:26 +00:00
IntegerDivisionTest.cpp Rename a few unittests/.../Foo.cpp files to FooTest.cpp 2018-09-03 12:43:26 +00:00
LocalTest.cpp Fix -Wdangling-else gcc warning. NFCI. 2018-09-16 12:30:41 +00:00
SSAUpdaterBulkTest.cpp Rename a few unittests/.../Foo.cpp files to FooTest.cpp 2018-09-03 12:43:26 +00:00
UnrollLoopTest.cpp [LoopUnroll] Add check to Latch's terminator in UnrollRuntimeLoopRemainder 2018-09-25 10:08:47 +00:00
ValueMapperTest.cpp Re-sort #include lines for unittests. This uses a slightly modified 2017-06-06 11:06:56 +00:00