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

kyulee-com via All-commits all-commits at lists.llvm.org
Tue Feb 2 14:58:08 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4f58b1bd29747ff491148ef8e27bf310b7f07d97
      https://github.com/llvm/llvm-project/commit/4f58b1bd29747ff491148ef8e27bf310b7f07d97
  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

Second land attempt. MachineVerifier DefRegState expensive check errors fixed.

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