2012-06-18 11:15:04 +02:00
|
|
|
; This test is attempting to detect when we request forced re-alignment of the
|
|
|
|
; stack to an alignment greater than would be available due to the ABI. We
|
|
|
|
; arbitrarily force alignment up to 32-bytes for i386 hoping that this will
|
|
|
|
; exceed any ABI provisions.
|
|
|
|
;
|
|
|
|
; RUN: llc < %s -force-align-stack -stack-alignment=32 | FileCheck %s
|
|
|
|
|
|
|
|
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"
|
|
|
|
target triple = "i386-unknown-linux-gnu"
|
|
|
|
|
|
|
|
define i32 @f(i8* %p) nounwind {
|
|
|
|
entry:
|
|
|
|
%0 = load i8* %p
|
|
|
|
%conv = sext i8 %0 to i32
|
|
|
|
ret i32 %conv
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @g(i32 %i) nounwind {
|
|
|
|
; CHECK: g:
|
2012-07-10 19:45:53 +02:00
|
|
|
; CHECK: pushl %ebp
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NEXT: movl %esp, %ebp
|
2012-07-10 19:45:53 +02:00
|
|
|
; CHECK-NEXT: andl $-32, %esp
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NEXT: pushl
|
2012-07-10 19:45:53 +02:00
|
|
|
; CHECK-NEXT: pushl
|
|
|
|
; CHECK-NEXT: subl $24, %esp
|
|
|
|
;
|
|
|
|
; Now setup the base pointer (%ebx).
|
|
|
|
; CHECK-NEXT: movl %esp, %ebx
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
|
|
|
; The next adjustment of the stack is due to the alloca.
|
|
|
|
; CHECK: movl %{{...}}, %esp
|
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
|
|
|
; Next we set up the memset call, and then undo it.
|
|
|
|
; CHECK: subl $32, %esp
|
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
; CHECK: calll memset
|
|
|
|
; CHECK-NEXT: addl $32, %esp
|
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
|
|
|
; Next we set up the call to 'f'.
|
|
|
|
; CHECK: subl $32, %esp
|
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
; CHECK: calll f
|
|
|
|
; CHECK-NEXT: addl $32, %esp
|
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
2012-07-10 19:45:53 +02:00
|
|
|
; Restore %esp from %ebx (base pointer) so we can pop the callee-saved
|
|
|
|
; registers. This is the state prior to the allocation of VLAs.
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NOT: popl
|
2012-07-10 19:45:53 +02:00
|
|
|
; CHECK: movl %ebx, %esp
|
|
|
|
; CHECK-NEXT: addl $24, %esp
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NEXT: popl
|
|
|
|
; CHECK-NEXT: popl
|
2012-07-10 19:45:53 +02:00
|
|
|
;
|
|
|
|
; Finally we need to restore %esp from %ebp due to dynamic stack
|
|
|
|
; realignment.
|
|
|
|
; CHECK-NEXT: movl %ebp, %esp
|
|
|
|
; CHECK-NEXT: popl %ebp
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NEXT: ret
|
|
|
|
|
|
|
|
entry:
|
|
|
|
br label %if.then
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
%0 = alloca i8, i32 %i
|
|
|
|
call void @llvm.memset.p0i8.i32(i8* %0, i8 0, i32 %i, i32 1, i1 false)
|
|
|
|
%call = call i32 @f(i8* %0)
|
|
|
|
%conv = sext i32 %call to i64
|
|
|
|
ret i64 %conv
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) nounwind
|