[PATCH] D67189: [AArch64][GlobalISel] Teach AArch64CallLowering to handle basic sibling calls

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 11:13:42 PDT 2019


paquette created this revision.
paquette added reviewers: aemerson, t.p.northover.
Herald added subscribers: Petar.Avramovic, volkan, hiraditya, kristof.beyls, javed.absar, rovka.
Herald added a project: LLVM.

This adds support for basic sibling call lowering in AArch64. The intent here is to only handle tail calls which do not change the ABI (hence, sibling calls.)

At this point, it is very restricted. It does not handle

- Vararg calls
- Calls with outgoing arguments
- Calls whose calling conventions differ from the caller's calling convention
- Tail/sibling calls with BTI enabled

This patch adds

- `AArch64CallLowering::isEligibleForTailCallOptimization`, which is equivalent to the same function in AArch64ISelLowering.cpp (albeit with the restrictions above.)
- `mayTailCallThisCC` and `canGuaranteeTCO`, which are identical to those in AArch64ISelLowering.cpp
- `getCallOpcode`, which is exactly what it sounds like

Tail/sibling calls are lowered by checking if they pass target-independent tail call positioning checks, and checking if they satisfy `isEligibleForTailCallOptimization`. If they do, then a tail call instruction is emitted instead of a normal call. If we have a sibling call (which is always the case in this patch), then we do not emit any stack adjustment operations. When we go to lower a return, we check if we've already emitted a tail call. If so, then we skip the return lowering.

For testing, this patch

- Adds test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll to test which tail calls we currently lower, which ones we don't, and which ones we shouldn't.
- Updates test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll to show that we fall back as expected.

Also updates test/CodeGen/AArch64/dllimport.ll, which now generates a tail call instead of a normal call (matching the other instruction selectors.)


https://reviews.llvm.org/D67189

Files:
  llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
  llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
  llvm/lib/Target/AArch64/AArch64CallLowering.cpp
  llvm/lib/Target/AArch64/AArch64CallLowering.h
  llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
  llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll
  llvm/test/CodeGen/AArch64/dllimport.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67189.218753.patch
Type: text/x-patch
Size: 17401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190904/e358f073/attachment-0001.bin>


More information about the llvm-commits mailing list