Generate the segmented stack prologue for fastcc too.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 11 Jan 2012 18:41:19 +0000 (18:41 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 11 Jan 2012 18:41:19 +0000 (18:41 +0000)
Patch by Brian Anderson.

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

lib/Target/X86/X86FrameLowering.cpp
test/CodeGen/X86/segmented-stacks.ll

index fba4788d6a50e1a7848f2b45c02c769aadcd264e..4386762c85391ed0fdedab38a367c981d8549358 100644 (file)
@@ -1306,7 +1306,8 @@ GetScratchRegister(bool Is64Bit, const MachineFunction &MF) {
     CallingConv::ID CallingConvention = MF.getFunction()->getCallingConv();
     bool IsNested = HasNestArgument(&MF);
 
-    if (CallingConvention == CallingConv::X86_FastCall) {
+    if (CallingConvention == CallingConv::X86_FastCall ||
+        CallingConvention == CallingConv::Fast) {
       if (IsNested) {
         report_fatal_error("Segmented stacks does not support fastcall with "
                            "nested function.");
index 27537c085c818a5115d0ba83c246fb9a76050b68..0e125d36a76af87689c48911909885100793381a 100644 (file)
@@ -114,3 +114,58 @@ define void @test_large() {
 ; X64-NEXT: ret
 
 }
+
+define fastcc void @test_fastcc() {
+        %mem = alloca i32, i32 10
+        call void @dummy_use (i32* %mem, i32 10)
+        ret void
+
+; X32:      test_fastcc:
+
+; X32:      cmpl %gs:48, %esp
+; X32-NEXT: ja      .LBB3_2
+
+; X32:      pushl $0
+; X32-NEXT: pushl $60
+; X32-NEXT: calll __morestack
+; X32-NEXT: ret
+
+; X64:      test_fastcc:
+
+; X64:      cmpq %fs:112, %rsp
+; X64-NEXT: ja      .LBB3_2
+
+; X64:      movabsq $40, %r10
+; X64-NEXT: movabsq $0, %r11
+; X64-NEXT: callq __morestack
+; X64-NEXT: ret
+
+}
+
+define fastcc void @test_fastcc_large() {
+        %mem = alloca i32, i32 10000
+        call void @dummy_use (i32* %mem, i32 0)
+        ret void
+
+; X32:      test_fastcc_large:
+
+; X32:      leal -40012(%esp), %eax
+; X32-NEXT: cmpl %gs:48, %eax
+; X32-NEXT: ja      .LBB4_2
+
+; X32:      pushl $0
+; X32-NEXT: pushl $40012
+; X32-NEXT: calll __morestack
+; X32-NEXT: ret
+
+; X64:      test_fastcc_large:
+
+; X64:      leaq -40008(%rsp), %r11
+; X64-NEXT: cmpq %fs:112, %r11
+; X64-NEXT: ja      .LBB4_2
+
+; X64:      movabsq $40008, %r10
+; X64-NEXT: movabsq $0, %r11
+; X64-NEXT: callq __morestack
+; X64-NEXT: ret
+}