[PATCH] D67282: [GlobalISel][AArch64] Handle tail calls with non-void return types
Jessica Paquette via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 10:15:38 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371425: [GlobalISel][AArch64] Handle tail calls with non-void return types (authored by paquette, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D67282?vs=219122&id=219387#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67282/new/
https://reviews.llvm.org/D67282
Files:
llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
llvm/trunk/test/CodeGen/AArch64/dllimport.ll
Index: llvm/trunk/test/CodeGen/AArch64/dllimport.ll
===================================================================
--- llvm/trunk/test/CodeGen/AArch64/dllimport.ll
+++ llvm/trunk/test/CodeGen/AArch64/dllimport.ll
@@ -1,6 +1,6 @@
; RUN: llc -mtriple aarch64-unknown-windows-msvc -filetype asm -o - %s | FileCheck %s -check-prefixes=CHECK,DAG-ISEL
; RUN: llc -mtriple aarch64-unknown-windows-msvc -fast-isel -filetype asm -o - %s | FileCheck %s -check-prefixes=CHECK,FAST-ISEL
-; RUN: llc -mtriple aarch64-unknown-windows-msvc -O0 -filetype asm -o - %s | FileCheck %s -check-prefixes=CHECK,GLOBAL-ISEL,GLOBAL-ISEL-FALLBACK
+; RUN: llc -mtriple aarch64-unknown-windows-msvc -verify-machineinstrs -O0 -filetype asm -o - %s | FileCheck %s -check-prefixes=CHECK,GLOBAL-ISEL,GLOBAL-ISEL-FALLBACK
@var = external dllimport global i32
@ext = external global i32
@@ -59,4 +59,4 @@
; CHECK-LABEL: call_internal
; DAG-ISEL: b internal
; FAST-ISEL: b internal
-; GLOBAL-ISEL: bl internal
+; GLOBAL-ISEL: b internal
Index: llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
===================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
@@ -47,12 +47,7 @@
define i32 @test_nonvoid_ret() {
; COMMON-LABEL: name: test_nonvoid_ret
; COMMON: bb.1 (%ir-block.0):
- ; COMMON: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
- ; COMMON: BL @nonvoid_ret, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit-def $w0
- ; COMMON: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
- ; COMMON: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
- ; COMMON: $w0 = COPY [[COPY]](s32)
- ; COMMON: RET_ReallyLR implicit $w0
+ ; COMMON: TCRETURNdi @nonvoid_ret, 0, csr_aarch64_aapcs, implicit $sp
%call = tail call i32 @nonvoid_ret()
ret i32 %call
}
Index: llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp
+++ llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp
@@ -450,14 +450,6 @@
return false;
}
- if (!Info.OrigRet.Ty->isVoidTy()) {
- // TODO: lowerCall will insert COPYs to handle the call's return value.
- // This needs some refactoring to avoid this with tail call returns. For
- // now, just don't handle that case.
- LLVM_DEBUG(dbgs() << "... Cannot handle non-void return types yet.\n");
- return false;
- }
-
if (!mayTailCallThisCC(CalleeCC)) {
LLVM_DEBUG(dbgs() << "... Calling convention cannot be tail called.\n");
return false;
@@ -649,6 +641,11 @@
*MF.getSubtarget().getRegBankInfo(), *MIB, MIB->getDesc(), Info.Callee,
0));
+ // If we're tail calling, then we're the return from the block. So, we don't
+ // want to copy anything.
+ if (IsSibCall)
+ return true;
+
// Finally we can copy the returned value back into its virtual-register. In
// symmetry with the arugments, the physical register must be an
// implicit-define of the call instruction.
@@ -668,13 +665,10 @@
MIRBuilder.buildCopy(Info.SwiftErrorVReg, Register(AArch64::X21));
}
- if (!IsSibCall) {
- // If we aren't sibcalling, we need to move the stack.
- CallSeqStart.addImm(Handler.StackSize).addImm(0);
- MIRBuilder.buildInstr(AArch64::ADJCALLSTACKUP)
- .addImm(Handler.StackSize)
- .addImm(0);
- }
+ CallSeqStart.addImm(Handler.StackSize).addImm(0);
+ MIRBuilder.buildInstr(AArch64::ADJCALLSTACKUP)
+ .addImm(Handler.StackSize)
+ .addImm(0);
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67282.219387.patch
Type: text/x-patch
Size: 3700 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190909/6168a057/attachment-0001.bin>
More information about the llvm-commits
mailing list