1; RUN: llc < %s -mtriple=i686-windows -stackrealign | FileCheck %s
2
3declare void @good(i32 %a, i32 %b, i32 %c, i32 %d)
4declare void @oneparam(i32 %a)
5declare void @eightparams(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h)
6
7; When there is no reserved call frame, check that additional alignment
8; is added when the pushes don't add up to the required alignment.
9; CHECK-LABEL: test5:
10; CHECK: subl    $16, %esp
11; CHECK-NEXT: pushl   $4
12; CHECK-NEXT: pushl   $3
13; CHECK-NEXT: pushl   $2
14; CHECK-NEXT: pushl   $1
15; CHECK-NEXT: call
16define void @test5(i32 %k) {
17entry:
18  %a = alloca i32, i32 %k
19  call void @good(i32 1, i32 2, i32 3, i32 4)
20  ret void
21}
22
23; When the alignment adds up, do the transformation
24; CHECK-LABEL: test5b:
25; CHECK: pushl   $8
26; CHECK-NEXT: pushl   $7
27; CHECK-NEXT: pushl   $6
28; CHECK-NEXT: pushl   $5
29; CHECK-NEXT: pushl   $4
30; CHECK-NEXT: pushl   $3
31; CHECK-NEXT: pushl   $2
32; CHECK-NEXT: pushl   $1
33; CHECK-NEXT: call
34define void @test5b() optsize {
35entry:
36  call void @eightparams(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8)
37  ret void
38}
39
40; When having to compensate for the alignment isn't worth it,
41; don't use pushes.
42; CHECK-LABEL: test5c:
43; CHECK: movl $1, (%esp)
44; CHECK-NEXT: call
45define void @test5c() optsize {
46entry:
47  call void @oneparam(i32 1)
48  ret void
49}
50
51!llvm.module.flags = !{!0}
52!0 = !{i32 2, !"override-stack-alignment", i32 32}
53