[ms-inline asm] Add back-end test case for r166632. Make sure we emit the
[oota-llvm.git] / test / CodeGen / X86 / win64_alloca_dynalloca.ll
1 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-mingw32     | FileCheck %s -check-prefix=M64
2 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-win32       | FileCheck %s -check-prefix=W64
3 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-win32-macho | FileCheck %s -check-prefix=EFI
4 ; PR8777
5 ; PR8778
6
7 define i64 @foo(i64 %n, i64 %x) nounwind {
8 entry:
9
10   %buf0 = alloca i8, i64 4096, align 1
11
12 ; ___chkstk must adjust %rsp.
13 ; M64: movq  %rsp, %rbp
14 ; M64:       $4096, %rax
15 ; M64: callq ___chkstk
16 ; M64-NOT:   %rsp
17
18 ; __chkstk does not adjust %rsp.
19 ; W64: movq  %rsp, %rbp
20 ; W64:       $4096, %rax
21 ; W64: callq __chkstk
22 ; W64: subq  $4096, %rsp
23
24 ; Freestanding
25 ; EFI: movq  %rsp, %rbp
26 ; EFI:       $[[B0OFS:4096|4104]], %rsp
27 ; EFI-NOT:   call
28
29   %buf1 = alloca i8, i64 %n, align 1
30
31 ; M64: leaq  15(%{{.*}}), %rax
32 ; M64: andq  $-16, %rax
33 ; M64: callq ___chkstk
34 ; M64-NOT:   %rsp
35 ; M64: movq  %rsp, %rax
36
37 ; W64: leaq  15(%{{.*}}), %rax
38 ; W64: andq  $-16, %rax
39 ; W64: callq __chkstk
40 ; W64: subq  %rax, %rsp
41 ; W64: movq  %rsp, %rax
42
43 ; EFI: leaq  15(%{{.*}}), [[R1:%r.*]]
44 ; EFI: andq  $-16, [[R1]]
45 ; EFI: movq  %rsp, [[R64:%r.*]]
46 ; EFI: subq  [[R1]], [[R64]]
47 ; EFI: movq  [[R64]], %rsp
48
49   %r = call i64 @bar(i64 %n, i64 %x, i64 %n, i8* %buf0, i8* %buf1) nounwind
50
51 ; M64: subq  $48, %rsp
52 ; M64: leaq  -4096(%rbp), %r9
53 ; M64: movq  %rax, 32(%rsp)
54 ; M64: callq bar
55
56 ; W64: subq  $48, %rsp
57 ; W64: leaq  -4096(%rbp), %r9
58 ; W64: movq  %rax, 32(%rsp)
59 ; W64: callq bar
60
61 ; EFI: subq  $48, %rsp
62 ; EFI: leaq  -[[B0OFS]](%rbp), %r9
63 ; EFI: movq  [[R64]], 32(%rsp)
64 ; EFI: callq _bar
65
66   ret i64 %r
67
68 ; M64: movq    %rbp, %rsp
69
70 ; W64: movq    %rbp, %rsp
71
72 }
73
74 declare i64 @bar(i64, i64, i64, i8* nocapture, i8* nocapture) nounwind