[llvm] r371692 - [GlobalISel][AArch64] Check caller for swifterror params in tailcall eligibility
Jessica Paquette via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 11 16:44:16 PDT 2019
Author: paquette
Date: Wed Sep 11 16:44:16 2019
New Revision: 371692
URL: http://llvm.org/viewvc/llvm-project?rev=371692&view=rev
Log:
[GlobalISel][AArch64] Check caller for swifterror params in tailcall eligibility
Before, we only checked the callee for swifterror. However, we should also be
checking the caller to see if it has a swifterror parameter.
Since we don't currently handle outgoing arguments, this didn't show up in the
swifterror.ll testcase.
Also, remove the swifterror checks from call-translator-tail-call.ll, since
they are covered by the existing swifterror testing. Better to have it all in
one place.
Differential Revision: https://reviews.llvm.org/D67465
Modified:
llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
llvm/trunk/test/CodeGen/AArch64/GlobalISel/swifterror.ll
Modified: llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp?rev=371692&r1=371691&r2=371692&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp Wed Sep 11 16:44:16 2019
@@ -493,11 +493,15 @@ bool AArch64CallLowering::isEligibleForT
// caller has an argument with "inreg" attribute.
//
// FIXME: Check whether the callee also has an "inreg" argument.
+ //
+ // When the caller has a swifterror argument, we don't want to tail call
+ // because would have to move into the swifterror register before the
+ // tail call.
if (any_of(CallerF.args(), [](const Argument &A) {
- return A.hasByValAttr() || A.hasInRegAttr();
+ return A.hasByValAttr() || A.hasInRegAttr() || A.hasSwiftErrorAttr();
})) {
- LLVM_DEBUG(dbgs() << "... Cannot tail call from callers with byval or "
- "inreg arguments.\n");
+ LLVM_DEBUG(dbgs() << "... Cannot tail call from callers with byval, "
+ "inreg, or swifterror arguments\n");
return false;
}
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll?rev=371692&r1=371691&r2=371692&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll Wed Sep 11 16:44:16 2019
@@ -52,50 +52,6 @@ define i32 @test_nonvoid_ret() {
ret i32 %call
}
-; Don't want to handle swifterror at all right now, since lowerCall will
-; insert a COPY after the call right now.
-; TODO: Support this.
-%swift_error = type {i64, i8}
-define float @swifterror(%swift_error** swifterror %ptr) {
- ; COMMON-LABEL: name: swifterror
- ; COMMON: bb.1 (%ir-block.0):
- ; COMMON: liveins: $x21
- ; COMMON: [[COPY:%[0-9]+]]:_(p0) = COPY $x21
- ; COMMON: [[COPY1:%[0-9]+]]:gpr64all = COPY [[COPY]](p0)
- ; COMMON: [[COPY2:%[0-9]+]]:_(p0) = COPY [[COPY1]]
- ; COMMON: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
- ; COMMON: $x21 = COPY [[COPY2]](p0)
- ; COMMON: BL @swifterror, csr_aarch64_aapcs_swifterror, implicit-def $lr, implicit $sp, implicit $x21, implicit-def $s0, implicit-def $x21
- ; COMMON: [[COPY3:%[0-9]+]]:_(s32) = COPY $s0
- ; COMMON: [[COPY4:%[0-9]+]]:gpr64all = COPY $x21
- ; COMMON: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
- ; COMMON: $s0 = COPY [[COPY3]](s32)
- ; COMMON: $x21 = COPY [[COPY4]]
- ; COMMON: RET_ReallyLR implicit $s0, implicit $x21
- %call = tail call float @swifterror(%swift_error** swifterror %ptr)
- ret float %call
-}
-
-define swiftcc float @swifterror_swiftcc(%swift_error** swifterror %ptr) {
- ; COMMON-LABEL: name: swifterror_swiftcc
- ; COMMON: bb.1 (%ir-block.0):
- ; COMMON: liveins: $x21
- ; COMMON: [[COPY:%[0-9]+]]:_(p0) = COPY $x21
- ; COMMON: [[COPY1:%[0-9]+]]:gpr64all = COPY [[COPY]](p0)
- ; COMMON: [[COPY2:%[0-9]+]]:_(p0) = COPY [[COPY1]]
- ; COMMON: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
- ; COMMON: $x21 = COPY [[COPY2]](p0)
- ; COMMON: BL @swifterror_swiftcc, csr_aarch64_aapcs_swifterror, implicit-def $lr, implicit $sp, implicit $x21, implicit-def $s0, implicit-def $x21
- ; COMMON: [[COPY3:%[0-9]+]]:_(s32) = COPY $s0
- ; COMMON: [[COPY4:%[0-9]+]]:gpr64all = COPY $x21
- ; COMMON: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
- ; COMMON: $s0 = COPY [[COPY3]](s32)
- ; COMMON: $x21 = COPY [[COPY4]]
- ; COMMON: RET_ReallyLR implicit $s0, implicit $x21
- %call = tail call swiftcc float @swifterror_swiftcc(%swift_error** swifterror %ptr)
- ret float %call
-}
-
; Right now, this should not be tail called.
; TODO: Support this.
declare void @varargs(i32, double, i64, ...)
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/swifterror.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/swifterror.ll?rev=371692&r1=371691&r2=371692&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/swifterror.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/swifterror.ll Wed Sep 11 16:44:16 2019
@@ -487,6 +487,15 @@ entry:
ret void
}
+; CHECK: tailcall_from_swifterror2
+; CHECK-NOT: b _simple_fn
+; CHECK: bl _simple_fn
+declare void @simple_fn()
+define swiftcc void @tailcall_from_swifterror2(%swift_error** swifterror %error_ptr_ref) {
+ tail call void @simple_fn()
+ ret void
+}
+
declare swiftcc void @foo2(%swift_error** swifterror)
; CHECK-LABEL: testAssign
; CHECK: mov x21, xzr
More information about the llvm-commits
mailing list