[llvm] r313956 - AArch64: support SwiftCC properly on AAPCS64

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 21:31:44 PDT 2017


Author: compnerd
Date: Thu Sep 21 21:31:44 2017
New Revision: 313956

URL: http://llvm.org/viewvc/llvm-project?rev=313956&view=rev
Log:
AArch64: support SwiftCC properly on AAPCS64

The previous SwiftCC support for AAPCS64 was partially correct.  It
setup swiftself parameters in the proper register but failed to setup
swifterror in the correct register.  This would break compilation of
swift code for non-Darwin AAPCS64 conforming environments.

Added:
    llvm/trunk/test/CodeGen/AArch64/swift-error.ll
Modified:
    llvm/trunk/lib/Target/AArch64/AArch64CallingConvention.td

Modified: llvm/trunk/lib/Target/AArch64/AArch64CallingConvention.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64CallingConvention.td?rev=313956&r1=313955&r2=313956&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64CallingConvention.td (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64CallingConvention.td Thu Sep 21 21:31:44 2017
@@ -49,6 +49,9 @@ def CC_AArch64_AAPCS : CallingConv<[
   // Pass SwiftSelf in a callee saved register.
   CCIfSwiftSelf<CCIfType<[i64], CCAssignToRegWithShadow<[X20], [W20]>>>,
 
+  // A SwiftError is passed in X21.
+  CCIfSwiftError<CCIfType<[i64], CCAssignToRegWithShadow<[X21], [W21]>>>,
+
   CCIfConsecutiveRegs<CCCustom<"CC_AArch64_Custom_Block">>,
 
   // Handle i1, i8, i16, i32, i64, f32, f64 and v2f64 by passing in registers,

Added: llvm/trunk/test/CodeGen/AArch64/swift-error.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/swift-error.ll?rev=313956&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/swift-error.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/swift-error.ll Thu Sep 21 21:31:44 2017
@@ -0,0 +1,18 @@
+; RUN: llc -mtriple aarch64-unknown-linux-gnu -filetype asm -o - %s | FileCheck %s
+
+%swift.error = type opaque
+
+declare swiftcc void @f(%swift.error** swifterror)
+
+define swiftcc void @g(i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %swift.error** swifterror %error) {
+entry:
+  call swiftcc void @f(%swift.error** nonnull nocapture swifterror %error)
+  ret void
+}
+
+; CHEECK-LABEL: g
+; CHECK: str x30, [sp, #-16]!
+; CHECK: bl f
+; CHECK: ldr x30, [sp], #16
+; CHECK: ret
+




More information about the llvm-commits mailing list