[all-commits] [llvm/llvm-project] 0426be: [AArch64] Homogeneous Prolog and Epilog Size Optim...

kyulee-com via All-commits all-commits at lists.llvm.org
Mon Feb 1 21:27:56 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0426be3df6180747bd68706db87a70580f064f0f
      https://github.com/llvm/llvm-project/commit/0426be3df6180747bd68706db87a70580f064f0f
  Author: Kyungwoo Lee <kyulee.llvm at gmail.com>
  Date:   2021-02-02 (Tue, 02 Feb 2021)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64.h
    M llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
    M llvm/lib/Target/AArch64/AArch64FrameLowering.h
    M llvm/lib/Target/AArch64/AArch64InstrInfo.td
    A llvm/lib/Target/AArch64/AArch64LowerHomogeneousPrologEpilog.cpp
    M llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
    M llvm/lib/Target/AArch64/CMakeLists.txt
    A llvm/test/CodeGen/AArch64/arm64-homogeneous-prolog-epilog-bad-outline.mir
    A llvm/test/CodeGen/AArch64/arm64-homogeneous-prolog-epilog-frame-tail.ll
    A llvm/test/CodeGen/AArch64/arm64-homogeneous-prolog-epilog-no-helper.ll
    A llvm/test/CodeGen/AArch64/arm64-homogeneous-prolog-epilog.ll

  Log Message:
  -----------
  [AArch64] Homogeneous Prolog and Epilog Size Optimization

Prologs and epilogs handle callee-save registers and tend to be irregular with
different immediate offsets that are not often handled by the MachineOutliner.
Commit D18619/a5335647d5e8 (combining stack operations) stretched irregularity
further.

This patch tries to emit homogeneous stores and loads with the same offset for
prologs and epilogs respectively. We have observed that this canonicalizes
(homogenizes) prologs and epilogs significantly and results in a greatly
increased chance of outlining, resulting in a code size reduction.

Despite the above results, there are still size wins to be had that the
MachineOutliner does not provide due to the special handling X30/LR. To handle
the LR case, his patch custom-outlines prologs and epilogs in place. It does
this by doing the following:

  * Injects HOM_Prolog and HOM_Epilog pseudo instructions during a Prolog and
    Epilog Injection Pass.
  * Lowers and optimizes said pseudos in a AArchLowerHomogneousPrologEpilog Pass.
  * Outlined helpers are created on demand. Identical helpers are merged by the linker.
  * An opt-in flag is introduced to enable this feature. Another threshold flag
    is also introduced to control the aggressiveness of outlining for application's need.

This reduced an average of 4% of code size on LLVM-TestSuite/CTMark targeting arm64/-Oz.

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




More information about the All-commits mailing list