2012-06-18 17:15:04 +08: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.
|
|
|
|
;
|
2015-09-12 02:54:38 +08:00
|
|
|
; RUN: llc < %s -mcpu=generic -stackrealign -stack-alignment=32 | FileCheck %s
|
2012-06-18 17:15:04 +08:00
|
|
|
|
|
|
|
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:
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i8, i8* %p
|
2012-06-18 17:15:04 +08:00
|
|
|
%conv = sext i8 %0 to i32
|
|
|
|
ret i32 %conv
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @g(i32 %i) nounwind {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: g:
|
2012-07-11 01:45:53 +08:00
|
|
|
; CHECK: pushl %ebp
|
2012-06-18 17:15:04 +08:00
|
|
|
; CHECK-NEXT: movl %esp, %ebp
|
|
|
|
; CHECK-NEXT: pushl
|
2012-07-11 01:45:53 +08:00
|
|
|
; CHECK-NEXT: pushl
|
2012-07-16 14:54:09 +08:00
|
|
|
; CHECK-NEXT: andl $-32, %esp
|
|
|
|
; CHECK-NEXT: subl $32, %esp
|
2012-07-11 01:45:53 +08:00
|
|
|
;
|
2012-08-01 02:29:21 +08:00
|
|
|
; Now setup the base pointer (%esi).
|
|
|
|
; CHECK-NEXT: movl %esp, %esi
|
2012-06-18 17:15:04 +08:00
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
|
|
|
; The next adjustment of the stack is due to the alloca.
|
|
|
|
; CHECK: movl %{{...}}, %esp
|
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
2016-04-07 08:05:49 +08:00
|
|
|
; Next we set up the memset call.
|
2014-12-09 14:10:44 +08:00
|
|
|
; CHECK: subl $20, %esp
|
2012-06-18 17:15:04 +08:00
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
2016-04-07 08:05:49 +08:00
|
|
|
; CHECK: pushl
|
|
|
|
; CHECK: pushl
|
|
|
|
; CHECK: pushl
|
2012-06-18 17:15:04 +08:00
|
|
|
; CHECK: calll memset
|
2016-04-07 08:05:49 +08:00
|
|
|
;
|
|
|
|
; Deallocating 32 bytes of outgoing call frame for memset and
|
|
|
|
; allocating 28 bytes for calling f yields a 4-byte adjustment:
|
|
|
|
; CHECK-NEXT: addl $4, %esp
|
2012-06-18 17:15:04 +08:00
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
2016-04-07 08:05:49 +08:00
|
|
|
; And move on to call 'f', and then restore the stack.
|
|
|
|
; CHECK: pushl
|
2012-06-18 17:15:04 +08:00
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
; CHECK: calll f
|
|
|
|
; CHECK-NEXT: addl $32, %esp
|
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
2012-07-16 14:54:09 +08:00
|
|
|
; Restore %esp from %ebp (frame pointer) and subtract the size of
|
|
|
|
; zone with callee-saved registers to pop them.
|
|
|
|
; This is the state prior to stack realignment and the allocation of VLAs.
|
2012-06-18 17:15:04 +08:00
|
|
|
; CHECK-NOT: popl
|
2012-07-16 14:54:09 +08:00
|
|
|
; CHECK: leal -8(%ebp), %esp
|
2012-06-18 17:15:04 +08:00
|
|
|
; CHECK-NEXT: popl
|
|
|
|
; CHECK-NEXT: popl
|
2012-07-11 01:45:53 +08:00
|
|
|
; CHECK-NEXT: popl %ebp
|
2012-06-18 17:15:04 +08:00
|
|
|
; CHECK-NEXT: ret
|
|
|
|
|
|
|
|
entry:
|
|
|
|
br label %if.then
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
%0 = alloca i8, i32 %i
|
2015-11-19 13:56:52 +08:00
|
|
|
call void @llvm.memset.p0i8.i32(i8* %0, i8 0, i32 %i, i32 1, i1 false)
|
2012-06-18 17:15:04 +08:00
|
|
|
%call = call i32 @f(i8* %0)
|
|
|
|
%conv = sext i32 %call to i64
|
|
|
|
ret i64 %conv
|
|
|
|
}
|
|
|
|
|
2015-11-19 13:56:52 +08:00
|
|
|
declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) nounwind
|