]> granicus.if.org Git - llvm/commit
[AArch64][GlobalISel] Teach AArch64CallLowering to handle basic sibling calls
authorJessica Paquette <jpaquette@apple.com>
Wed, 4 Sep 2019 22:54:52 +0000 (22:54 +0000)
committerJessica Paquette <jpaquette@apple.com>
Wed, 4 Sep 2019 22:54:52 +0000 (22:54 +0000)
commitd74809ef32cd06b9f39987168b4cbe602e1e52b4
tree8d4c6ea599d5b8c7b1b216b422301d96ad22011e
parentf24949cb9d0e5343ab57f712cac4fcc1230f7fb5
[AArch64][GlobalISel] Teach AArch64CallLowering to handle basic sibling calls

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 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 branch-target-enforcement-indirect-calls.ll to show that we fall back
  as expected.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370996 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/GlobalISel/CallLowering.h
lib/CodeGen/GlobalISel/CallLowering.cpp
lib/Target/AArch64/AArch64CallLowering.cpp
lib/Target/AArch64/AArch64CallLowering.h
test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll [new file with mode: 0644]
test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll
test/CodeGen/AArch64/dllimport.ll