]> granicus.if.org Git - llvm/commitdiff
[X86] Enable tail calls for CallingConv::Swift
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>
Fri, 5 Apr 2019 20:18:25 +0000 (20:18 +0000)
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>
Fri, 5 Apr 2019 20:18:25 +0000 (20:18 +0000)
It's currently only enabled on AArch64 (enabled in r281376).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357809 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/swiftcc.ll

index 6ad615a94e9d77275c943c3ccc6ba507b74ade89..0e0d07b349f7be0a90107ac7f7d5b529857eac31 100644 (file)
@@ -2941,6 +2941,8 @@ static bool mayTailCallThisCC(CallingConv::ID CC) {
   case CallingConv::X86_StdCall:
   case CallingConv::X86_VectorCall:
   case CallingConv::X86_FastCall:
+  // Swift:
+  case CallingConv::Swift:
     return true;
   default:
     return canGuaranteeTCO(CC);
index dc36ee247f1147bfbff2b414cbb54b8697e67c52..2e71307fe764d71cf8cdef423e3c74ceb968048c 100644 (file)
@@ -1,11 +1,21 @@
-; RUN: llc -mtriple x86_64-unknown-windows-msvc -filetype asm -o - %s | FileCheck %s
+; RUN: llc -mtriple x86_64-- -filetype asm -o - %s | FileCheck %s
+; RUN: llc -mtriple x86_64-unknown-windows-msvc -filetype asm -o - %s | FileCheck %s --check-prefix=MSVC
 
 define swiftcc void @f() {
   %1 = alloca i8
   ret void
 }
 
-; CHECK-LABEL: f
-; CHECK: .seh_stackalloc 8
-; CHECK: .seh_endprologue
+; MSVC-LABEL: f
+; MSVC: .seh_stackalloc 8
+; MSVC: .seh_endprologue
 
+declare swiftcc i64 @myFunc()
+define swiftcc i64 @myFunc2()  nounwind {
+  %r = tail call swiftcc i64 @myFunc()
+  ret i64 %r
+}
+
+; CHECK-LABEL: myFunc2
+; CHECK: jmp myFunc
+; CHECK-NOT: call