[llvm] 8c8dbc1 - X86: pass swift_async context in R14 on Win64

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 14 11:03:00 PDT 2021


Author: Saleem Abdulrasool
Date: 2021-06-14T11:02:21-07:00
New Revision: 8c8dbc10825cf099607af3da58b839e10c68320f

URL: https://github.com/llvm/llvm-project/commit/8c8dbc10825cf099607af3da58b839e10c68320f
DIFF: https://github.com/llvm/llvm-project/commit/8c8dbc10825cf099607af3da58b839e10c68320f.diff

LOG: X86: pass swift_async context in R14 on Win64

Pass swift_async context in a callee-saved register rather than as a
regular parameter.  This is similar to the Swift `self` and `error`
parameters.

Added: 
    llvm/test/CodeGen/X86/swift-async-reg-win64.ll

Modified: 
    llvm/lib/Target/X86/X86CallingConv.td

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86CallingConv.td b/llvm/lib/Target/X86/X86CallingConv.td
index c86d658653fda..98883bbf59a8a 100644
--- a/llvm/lib/Target/X86/X86CallingConv.td
+++ b/llvm/lib/Target/X86/X86CallingConv.td
@@ -627,6 +627,10 @@ def CC_X86_Win64_C : CallingConv<[
   // Pass SwiftSelf in a callee saved register.
   CCIfSwiftSelf<CCIfType<[i64], CCAssignToReg<[R13]>>>,
 
+  // Pass SwiftAsync in an otherwise callee saved register so that calls to
+  // normal functions don't need to save it somewhere.
+  CCIfSwiftAsync<CCIfType<[i64], CCAssignToReg<[R14]>>>,
+
   // The 'CFGuardTarget' parameter, if any, is passed in RAX.
   CCIfCFGuardTarget<CCAssignToReg<[RAX]>>,
 

diff  --git a/llvm/test/CodeGen/X86/swift-async-reg-win64.ll b/llvm/test/CodeGen/X86/swift-async-reg-win64.ll
new file mode 100644
index 0000000000000..96b3ef71a424e
--- /dev/null
+++ b/llvm/test/CodeGen/X86/swift-async-reg-win64.ll
@@ -0,0 +1,17 @@
+; RUN: llc -mtriple x86_64-unknown-windows-msvc %s -o - | FileCheck %s
+; RUN: llc -mtriple x86_64-unknown-windows-msvc %s -o - -fast-isel | FileCheck %s
+
+define i8* @argument(i8* swiftasync %in) {
+  ret i8* %in
+}
+
+; CHECK-LABEL: argument:
+; CHECK: movq    %r14, %rax
+
+define void @call(i8* %in) {
+  call i8* @argument(i8* swiftasync %in)
+  ret void
+}
+
+; CHECK-LABEL: call:
+; CHECK: movq %rcx, %r14


        


More information about the llvm-commits mailing list