[llvm] r275414 - Teach fast isel calls and rets about stdcall.

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 06:54:27 PDT 2016


Author: nico
Date: Thu Jul 14 08:54:26 2016
New Revision: 275414

URL: http://llvm.org/viewvc/llvm-project?rev=275414&view=rev
Log:
Teach fast isel calls and rets about stdcall.

stdcall is callee-pop like thiscall, so the thiscall changes already did most
of the work for this.  This change only opts stdcall in and adds tests.

Modified:
    llvm/trunk/lib/Target/X86/X86FastISel.cpp
    llvm/trunk/test/CodeGen/X86/fast-isel-call.ll
    llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll

Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=275414&r1=275413&r2=275414&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Thu Jul 14 08:54:26 2016
@@ -1151,6 +1151,7 @@ bool X86FastISel::X86SelectRet(const Ins
   if (CC != CallingConv::C &&
       CC != CallingConv::Fast &&
       CC != CallingConv::X86_FastCall &&
+      CC != CallingConv::X86_StdCall &&
       CC != CallingConv::X86_ThisCall &&
       CC != CallingConv::X86_64_SysV)
     return false;
@@ -3025,6 +3026,7 @@ bool X86FastISel::fastLowerCall(CallLowe
   case CallingConv::WebKit_JS:
   case CallingConv::Swift:
   case CallingConv::X86_FastCall:
+  case CallingConv::X86_StdCall:
   case CallingConv::X86_ThisCall:
   case CallingConv::X86_64_Win64:
   case CallingConv::X86_64_SysV:

Modified: llvm/trunk/test/CodeGen/X86/fast-isel-call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-call.ll?rev=275414&r1=275413&r2=275414&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fast-isel-call.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fast-isel-call.ll Thu Jul 14 08:54:26 2016
@@ -57,7 +57,7 @@ define void @test4(i8* %a, i8* %b) {
 
 ; STDERR-NOT: FastISel missed call:   call x86_thiscallcc void @thiscallfun
 %struct.S = type { i8 }
-define void @test5() #0 {
+define void @test5() {
 entry:
   %s = alloca %struct.S, align 1
 ; CHECK-LABEL: test5:
@@ -70,3 +70,16 @@ entry:
   ret void
 }
 declare x86_thiscallcc void @thiscallfun(%struct.S*, i32) #1
+
+; STDERR-NOT: FastISel missed call:   call x86_stdcallcc void @stdcallfun
+define void @test6() {
+entry:
+; CHECK-LABEL: test6:
+; CHECK: subl $12, %esp
+; CHECK: movl $43, (%esp)
+; CHECK: calll {{.*}}stdcallfun
+; CHECK: addl $8, %esp
+  call x86_stdcallcc void @stdcallfun(i32 43)
+  ret void
+}
+declare x86_stdcallcc void @stdcallfun(i32) #1

Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll?rev=275414&r1=275413&r2=275414&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll Thu Jul 14 08:54:26 2016
@@ -1,4 +1,5 @@
 ; RUN: llc -fast-isel -O0 -mcpu=generic -mtriple=i386-apple-darwin10 -relocation-model=pic < %s | FileCheck %s
+; RUN: llc -fast-isel -O0 -mcpu=generic -mtriple=i386-apple-darwin10 -relocation-model=pic < %s -fast-isel-verbose 2>&1 >/dev/null | FileCheck -check-prefix=STDERR -allow-empty %s
 
 ; This should use flds to set the return value.
 ; CHECK-LABEL: test0:
@@ -21,8 +22,9 @@ define void @test1({i32, i32, i32, i32}*
 ; This should pop 8 bytes on return.
 ; CHECK-LABEL: thiscallfun:
 ; CHECK: retl $8
-define x86_thiscallcc void @thiscallfun(i32* %this, i32 %a, i32 %b) nounwind {
-  ret void
+define x86_thiscallcc i32 @thiscallfun(i32* %this, i32 %a, i32 %b) nounwind {
+; STDERR-NOT: FastISel missed terminator: ret i32 12345
+  ret i32 12345
 }
 
 ; Here, the callee pop doesn't fit the 16 bit immediate -- see x86-big-ret.ll
@@ -36,11 +38,19 @@ define x86_thiscallcc void @thiscall_lar
   ret void
 }
 
+; This should pop 4 bytes on return.
+; CHECK-LABEL: stdcallfun:
+; CHECK: retl $4
+define x86_stdcallcc i32 @stdcallfun(i32 %a) nounwind {
+; STDERR-NOT: FastISel missed terminator: ret i32 54321
+  ret i32 54321
+}
+
 ; Properly initialize the pic base.
 ; CHECK-LABEL: test2:
 ; CHECK-NOT: HHH
-; CHECK: call{{.*}}L4$pb
-; CHECK-NEXT: L4$pb:
+; CHECK: call{{.*}}L5$pb
+; CHECK-NEXT: L5$pb:
 ; CHECK-NEXT: pop
 ; CHECK: HHH
 ; CHECK: retl
@@ -93,7 +103,7 @@ entry:
 ; SDag-ISel's arg push:
 ; CHECK: movl %esp, [[REGISTER:%[a-z]+]]
 ; CHECK: movl $42, ([[REGISTER]])
-; CHECK: movl L_test5dllimport$non_lazy_ptr-L7$pb(%eax), %eax
+; CHECK: movl L_test5dllimport$non_lazy_ptr-L8$pb(%eax), %eax
 
 }
 declare dllimport i32 @test5dllimport(i32)




More information about the llvm-commits mailing list