[PATCH] D30900: [PPC] Eliminate stack frame in non-leaf function based on shrink wrapping

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 13 09:41:11 PDT 2017


inouehrs created this revision.

We can expand the scope of shrink wrapping by not creating a stack frame in non-leaf functions.
For example, in the call sequence of A->B->C , we can help shrink wrapping while compiling B by allowing C directly return the control to A when exiting from C. I call it //direct return//.
In this case, we do not need to create stack frame in B and it increases the opportunity of shrink wrapping.
To apply direct return, we need to confirm some conditions including:

1. invocation B->C must be a tail call (i.e. no instruction between call and return in B).
2. invocation B->C must be with the internal linkage since direct return does not comply with ABI.
3. other ABI specific checks.

In this patch, this optimization is enabled only for PowerPC64 with ELFv2 ABI, but it might be applicable for other platforms by implementing a platform-specific part.

The original motivation of this patch is to optimize the hot method of tcmalloc. In which GCC applies shrink wrapping with the direct return, but LLVM cannot. By applying this patch and basic block deduplication ( https://reviews.llvm.org/D30774 ), LLVM can do shrink wrapping for this hot method.


https://reviews.llvm.org/D30900

Files:
  include/llvm/Target/TargetInstrInfo.h
  lib/CodeGen/ShrinkWrap.cpp
  lib/Target/PowerPC/PPCISelLowering.cpp
  lib/Target/PowerPC/PPCInstr64Bit.td
  lib/Target/PowerPC/PPCInstrInfo.cpp
  lib/Target/PowerPC/PPCInstrInfo.h
  lib/Target/PowerPC/PPCMachineFunctionInfo.h
  test/CodeGen/PowerPC/shrinkwrap_direct_return.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30900.91556.patch
Type: text/x-patch
Size: 17410 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170313/3a46cffc/attachment.bin>


More information about the llvm-commits mailing list