Chandler Carruth | a1da0bf | 2012-06-18 09:15:04 +0000 | [diff] [blame] | 1 | ; 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 | ; |
Preston Gurd | f2ea70a | 2012-07-19 18:53:21 +0000 | [diff] [blame] | 6 | ; RUN: llc < %s -mcpu=generic -force-align-stack -stack-alignment=32 | FileCheck %s |
Chandler Carruth | a1da0bf | 2012-06-18 09:15:04 +0000 | [diff] [blame] | 7 | |
| 8 | target 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" |
| 9 | target triple = "i386-unknown-linux-gnu" |
| 10 | |
| 11 | define i32 @f(i8* %p) nounwind { |
| 12 | entry: |
| 13 | %0 = load i8* %p |
| 14 | %conv = sext i8 %0 to i32 |
| 15 | ret i32 %conv |
| 16 | } |
| 17 | |
| 18 | define i64 @g(i32 %i) nounwind { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 19 | ; CHECK-LABEL: g: |
Chad Rosier | bdb08ac | 2012-07-10 17:45:53 +0000 | [diff] [blame] | 20 | ; CHECK: pushl %ebp |
Chandler Carruth | a1da0bf | 2012-06-18 09:15:04 +0000 | [diff] [blame] | 21 | ; CHECK-NEXT: movl %esp, %ebp |
Alexey Samsonov | dcc1291 | 2012-07-16 06:54:09 +0000 | [diff] [blame] | 22 | ; CHECK-NEXT: pushl |
| 23 | ; CHECK-NEXT: pushl |
Chad Rosier | bdb08ac | 2012-07-10 17:45:53 +0000 | [diff] [blame] | 24 | ; CHECK-NEXT: andl $-32, %esp |
Alexey Samsonov | dcc1291 | 2012-07-16 06:54:09 +0000 | [diff] [blame] | 25 | ; CHECK-NEXT: subl $32, %esp |
Chad Rosier | bdb08ac | 2012-07-10 17:45:53 +0000 | [diff] [blame] | 26 | ; |
Chad Rosier | 710be7d | 2012-07-31 18:29:21 +0000 | [diff] [blame] | 27 | ; Now setup the base pointer (%esi). |
| 28 | ; CHECK-NEXT: movl %esp, %esi |
Chandler Carruth | a1da0bf | 2012-06-18 09:15:04 +0000 | [diff] [blame] | 29 | ; CHECK-NOT: {{[^ ,]*}}, %esp |
| 30 | ; |
| 31 | ; The next adjustment of the stack is due to the alloca. |
| 32 | ; CHECK: movl %{{...}}, %esp |
| 33 | ; CHECK-NOT: {{[^ ,]*}}, %esp |
| 34 | ; |
| 35 | ; Next we set up the memset call, and then undo it. |
| 36 | ; CHECK: subl $32, %esp |
| 37 | ; CHECK-NOT: {{[^ ,]*}}, %esp |
| 38 | ; CHECK: calll memset |
| 39 | ; CHECK-NEXT: addl $32, %esp |
| 40 | ; CHECK-NOT: {{[^ ,]*}}, %esp |
| 41 | ; |
| 42 | ; Next we set up the call to 'f'. |
| 43 | ; CHECK: subl $32, %esp |
| 44 | ; CHECK-NOT: {{[^ ,]*}}, %esp |
| 45 | ; CHECK: calll f |
| 46 | ; CHECK-NEXT: addl $32, %esp |
| 47 | ; CHECK-NOT: {{[^ ,]*}}, %esp |
| 48 | ; |
Alexey Samsonov | dcc1291 | 2012-07-16 06:54:09 +0000 | [diff] [blame] | 49 | ; Restore %esp from %ebp (frame pointer) and subtract the size of |
| 50 | ; zone with callee-saved registers to pop them. |
| 51 | ; This is the state prior to stack realignment and the allocation of VLAs. |
Chandler Carruth | a1da0bf | 2012-06-18 09:15:04 +0000 | [diff] [blame] | 52 | ; CHECK-NOT: popl |
Alexey Samsonov | dcc1291 | 2012-07-16 06:54:09 +0000 | [diff] [blame] | 53 | ; CHECK: leal -8(%ebp), %esp |
Chandler Carruth | a1da0bf | 2012-06-18 09:15:04 +0000 | [diff] [blame] | 54 | ; CHECK-NEXT: popl |
| 55 | ; CHECK-NEXT: popl |
Chad Rosier | bdb08ac | 2012-07-10 17:45:53 +0000 | [diff] [blame] | 56 | ; CHECK-NEXT: popl %ebp |
Chandler Carruth | a1da0bf | 2012-06-18 09:15:04 +0000 | [diff] [blame] | 57 | ; CHECK-NEXT: ret |
| 58 | |
| 59 | entry: |
| 60 | br label %if.then |
| 61 | |
| 62 | if.then: |
| 63 | %0 = alloca i8, i32 %i |
| 64 | call void @llvm.memset.p0i8.i32(i8* %0, i8 0, i32 %i, i32 1, i1 false) |
| 65 | %call = call i32 @f(i8* %0) |
| 66 | %conv = sext i32 %call to i64 |
| 67 | ret i64 %conv |
| 68 | } |
| 69 | |
| 70 | declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) nounwind |