1*9880d681SAndroid Build Coastguard Worker; This test is attempting to detect when we request forced re-alignment of the 2*9880d681SAndroid Build Coastguard Worker; stack to an alignment greater than would be available due to the ABI. We 3*9880d681SAndroid Build Coastguard Worker; arbitrarily force alignment up to 32-bytes for i386 hoping that this will 4*9880d681SAndroid Build Coastguard Worker; exceed any ABI provisions. 5*9880d681SAndroid Build Coastguard Worker; 6*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mcpu=generic -stackrealign -stack-alignment=32 | FileCheck %s 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Workertarget 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*9880d681SAndroid Build Coastguard Workertarget triple = "i386-unknown-linux-gnu" 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Workerdefine i32 @f(i8* %p) nounwind { 12*9880d681SAndroid Build Coastguard Workerentry: 13*9880d681SAndroid Build Coastguard Worker %0 = load i8, i8* %p 14*9880d681SAndroid Build Coastguard Worker %conv = sext i8 %0 to i32 15*9880d681SAndroid Build Coastguard Worker ret i32 %conv 16*9880d681SAndroid Build Coastguard Worker} 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Workerdefine i64 @g(i32 %i) nounwind { 19*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: g: 20*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %ebp 21*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movl %esp, %ebp 22*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: pushl 23*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: pushl 24*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: andl $-32, %esp 25*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: subl $32, %esp 26*9880d681SAndroid Build Coastguard Worker; 27*9880d681SAndroid Build Coastguard Worker; Now setup the base pointer (%esi). 28*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movl %esp, %esi 29*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{[^ ,]*}}, %esp 30*9880d681SAndroid Build Coastguard Worker; 31*9880d681SAndroid Build Coastguard Worker; The next adjustment of the stack is due to the alloca. 32*9880d681SAndroid Build Coastguard Worker; CHECK: movl %{{...}}, %esp 33*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{[^ ,]*}}, %esp 34*9880d681SAndroid Build Coastguard Worker; 35*9880d681SAndroid Build Coastguard Worker; Next we set up the memset call. 36*9880d681SAndroid Build Coastguard Worker; CHECK: subl $20, %esp 37*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{[^ ,]*}}, %esp 38*9880d681SAndroid Build Coastguard Worker; CHECK: pushl 39*9880d681SAndroid Build Coastguard Worker; CHECK: pushl 40*9880d681SAndroid Build Coastguard Worker; CHECK: pushl 41*9880d681SAndroid Build Coastguard Worker; CHECK: calll memset 42*9880d681SAndroid Build Coastguard Worker; 43*9880d681SAndroid Build Coastguard Worker; Deallocating 32 bytes of outgoing call frame for memset and 44*9880d681SAndroid Build Coastguard Worker; allocating 28 bytes for calling f yields a 4-byte adjustment: 45*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: addl $4, %esp 46*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{[^ ,]*}}, %esp 47*9880d681SAndroid Build Coastguard Worker; 48*9880d681SAndroid Build Coastguard Worker; And move on to call 'f', and then restore the stack. 49*9880d681SAndroid Build Coastguard Worker; CHECK: pushl 50*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{[^ ,]*}}, %esp 51*9880d681SAndroid Build Coastguard Worker; CHECK: calll f 52*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: addl $32, %esp 53*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{[^ ,]*}}, %esp 54*9880d681SAndroid Build Coastguard Worker; 55*9880d681SAndroid Build Coastguard Worker; Restore %esp from %ebp (frame pointer) and subtract the size of 56*9880d681SAndroid Build Coastguard Worker; zone with callee-saved registers to pop them. 57*9880d681SAndroid Build Coastguard Worker; This is the state prior to stack realignment and the allocation of VLAs. 58*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: popl 59*9880d681SAndroid Build Coastguard Worker; CHECK: leal -8(%ebp), %esp 60*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: popl 61*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: popl 62*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: popl %ebp 63*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ret 64*9880d681SAndroid Build Coastguard Worker 65*9880d681SAndroid Build Coastguard Workerentry: 66*9880d681SAndroid Build Coastguard Worker br label %if.then 67*9880d681SAndroid Build Coastguard Worker 68*9880d681SAndroid Build Coastguard Workerif.then: 69*9880d681SAndroid Build Coastguard Worker %0 = alloca i8, i32 %i 70*9880d681SAndroid Build Coastguard Worker call void @llvm.memset.p0i8.i32(i8* %0, i8 0, i32 %i, i32 1, i1 false) 71*9880d681SAndroid Build Coastguard Worker %call = call i32 @f(i8* %0) 72*9880d681SAndroid Build Coastguard Worker %conv = sext i32 %call to i64 73*9880d681SAndroid Build Coastguard Worker ret i64 %conv 74*9880d681SAndroid Build Coastguard Worker} 75*9880d681SAndroid Build Coastguard Worker 76*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) nounwind 77