[PATCH] D76570: [AArch64] Homogeneous Prolog and Epilog for Size Optimization

Kyungwoo Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 22 11:45:16 PDT 2020


kyulee created this revision.
Herald added subscribers: llvm-commits, danielkiss, hiraditya, kristof.beyls, mgorny.
Herald added a project: LLVM.
kyulee added reviewers: dmgreen, gberry, t.p.northover.

Prolog and epilog to handle callee-save registers tend to be irregular with different immediate offsets, which are not often being outlined (by machine outliner) when optimizing for size. From D18619 <https://reviews.llvm.org/D18619>, combining stack operations stretched irregularity further.
This patch tries to emit homogeneous stores and loads with the same offset for prolog and epilog respectively.  We have observed that this homogeneous prolog and epilog significantly increased the chance of outlining, resulting in a code size reduction. However, it was still far from the minimum size code due to requiring the special handling of the return register, x30.
This patch custom-outlines prolog and epilog in place:

- Injects HOM_Prolog and HOM_Epilog psuedo instructions in Prolog and Epilog Injection Pass
- Lower and optimize them in 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76570

Files:
  llvm/lib/Target/AArch64/AArch64.h
  llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
  llvm/lib/Target/AArch64/AArch64FrameLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64LowerHomogeneousPrologEpilog.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Target/AArch64/CMakeLists.txt
  llvm/test/CodeGen/AArch64/arm64-homogeneous-prolog-epilog-frame-tail.ll
  llvm/test/CodeGen/AArch64/arm64-homogeneous-prolog-epilog-no-helper.ll
  llvm/test/CodeGen/AArch64/arm64-homogeneous-prolog-epilog.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76570.251904.patch
Type: text/x-patch
Size: 39908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200322/9452b52d/attachment.bin>


More information about the llvm-commits mailing list