brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · b9d020e Raw
80 lines · plain
1; This test is attempting to detect when we request forced re-alignment of the2; stack to an alignment greater than would be available due to the ABI. We3; arbitrarily force alignment up to 32-bytes for i386 hoping that this will4; exceed any ABI provisions.5;6; RUN: llc < %s -mcpu=generic -stackrealign | FileCheck %s7 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(ptr %p) nounwind {12entry:13  %0 = load i8, ptr %p14  %conv = sext i8 %0 to i3215  ret i32 %conv16}17 18define i64 @g(i32 %i) nounwind {19; CHECK-LABEL: g:20; CHECK:      pushl  %ebp21; CHECK-NEXT: movl   %esp, %ebp22; CHECK-NEXT: pushl23; CHECK-NEXT: pushl24; CHECK-NEXT: andl   $-32, %esp25; CHECK-NEXT: subl   $32, %esp26;27; Now setup the base pointer (%esi).28; CHECK-NEXT: movl   %esp, %esi29; CHECK-NOT:         {{[^ ,]*}}, %esp30;31; The next adjustment of the stack is due to the alloca.32; CHECK:      movl   %{{...}}, %esp33; CHECK-NOT:         {{[^ ,]*}}, %esp34;35; Next we set up the memset call.36; CHECK:      subl   $20, %esp37; CHECK-NOT:         {{[^ ,]*}}, %esp38; CHECK:      pushl39; CHECK:      pushl40; CHECK:      pushl41; CHECK:      calll  memset42;43; Deallocating 32 bytes of outgoing call frame for memset and44; allocating 28 bytes for calling f yields a 4-byte adjustment:45; CHECK-NEXT: addl   $4, %esp46; CHECK-NOT:         {{[^ ,]*}}, %esp47;48; And move on to call 'f', and then restore the stack.49; CHECK:      pushl50; CHECK-NOT:         {{[^ ,]*}}, %esp51; CHECK:      calll  f52; CHECK-NEXT: addl   $32, %esp53; CHECK-NOT:         {{[^ ,]*}}, %esp54;55; Restore %esp from %ebp (frame pointer) and subtract the size of56; zone with callee-saved registers to pop them.57; This is the state prior to stack realignment and the allocation of VLAs.58; CHECK-NOT:  popl59; CHECK:      leal   -8(%ebp), %esp60; CHECK-NEXT: popl61; CHECK-NEXT: popl62; CHECK-NEXT: popl   %ebp63; CHECK-NEXT: ret64 65entry:66  br label %if.then67 68if.then:69  %0 = alloca i8, i32 %i70  call void @llvm.memset.p0.i32(ptr %0, i8 0, i32 %i, i1 false)71  %call = call i32 @f(ptr %0)72  %conv = sext i32 %call to i6473  ret i64 %conv74}75 76declare void @llvm.memset.p0.i32(ptr, i8, i32, i1) nounwind77 78!llvm.module.flags = !{!0}79!0 = !{i32 2, !"override-stack-alignment", i32 32}80