blob: 48f963f58e8a75979efdb4508ce9771b1f2bb699 [file] [log] [blame]
Chandler Carrutha1da0bf2012-06-18 09:15:04 +00001; This test is attempting to detect when we request forced re-alignment of the
2; stack to an alignment greater than would be available due to the ABI. We
3; arbitrarily force alignment up to 32-bytes for i386 hoping that this will
4; exceed any ABI provisions.
5;
6; RUN: llc < %s -force-align-stack -stack-alignment=32 | FileCheck %s
7
8target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
9target triple = "i386-unknown-linux-gnu"
10
11define i32 @f(i8* %p) nounwind {
12entry:
13 %0 = load i8* %p
14 %conv = sext i8 %0 to i32
15 ret i32 %conv
16}
17
18define i64 @g(i32 %i) nounwind {
19; CHECK: g:
20; CHECK: pushl
21; CHECK-NEXT: movl %esp, %ebp
22; CHECK-NEXT: pushl
23; CHECK-NEXT: subl $20, %esp
24; CHECK-NOT: {{[^ ,]*}}, %esp
25;
26; The next adjustment of the stack is due to the alloca.
27; CHECK: movl %{{...}}, %esp
28; CHECK-NOT: {{[^ ,]*}}, %esp
29;
30; Next we set up the memset call, and then undo it.
31; CHECK: subl $32, %esp
32; CHECK-NOT: {{[^ ,]*}}, %esp
33; CHECK: calll memset
34; CHECK-NEXT: addl $32, %esp
35; CHECK-NOT: {{[^ ,]*}}, %esp
36;
37; Next we set up the call to 'f'.
38; CHECK: subl $32, %esp
39; CHECK-NOT: {{[^ ,]*}}, %esp
40; CHECK: calll f
41; CHECK-NEXT: addl $32, %esp
42; CHECK-NOT: {{[^ ,]*}}, %esp
43;
44; Finally we nede to restore %esp from %ebp, the alloca prevents us from
45; restoring it directly.
46; CHECK-NOT: popl
47; CHECK: leal -4(%ebp), %esp
48; CHECK-NEXT: popl
49; CHECK-NEXT: popl
50; CHECK-NEXT: ret
51
52entry:
53 br label %if.then
54
55if.then:
56 %0 = alloca i8, i32 %i
57 call void @llvm.memset.p0i8.i32(i8* %0, i8 0, i32 %i, i32 1, i1 false)
58 %call = call i32 @f(i8* %0)
59 %conv = sext i32 %call to i64
60 ret i64 %conv
61}
62
63declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) nounwind