Home | History | Annotate | Download | only in llvm2ice_tests
      1 ; This checks to ensure that Subzero aligns spill slots.
      2 
      3 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -Om1 \
      4 ; RUN:   -allow-externally-defined-symbols | FileCheck %s
      5 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 \
      6 ; RUN:   -allow-externally-defined-symbols | FileCheck %s
      7 
      8 ; The location of the stack slot for a variable is inferred from the
      9 ; return sequence.
     10 
     11 ; In this file, "global" refers to a variable with a live range across
     12 ; multiple basic blocks (not an LLVM global variable) and "local"
     13 ; refers to a variable that is live in only a single basic block.
     14 
     15 define internal <4 x i32> @align_global_vector(i32 %arg) {
     16 entry:
     17   %vec.global = insertelement <4 x i32> undef, i32 %arg, i32 0
     18   br label %block
     19 block:
     20   call void @ForceXmmSpills()
     21   ret <4 x i32> %vec.global
     22 ; CHECK-LABEL: align_global_vector
     23 ; CHECK: movups xmm0,XMMWORD PTR [esp]
     24 ; CHECK-NEXT: add esp,0x1c
     25 ; CHECK-NEXT: ret
     26 }
     27 
     28 define internal <4 x i32> @align_local_vector(i32 %arg) {
     29 entry:
     30   br label %block
     31 block:
     32   %vec.local = insertelement <4 x i32> undef, i32 %arg, i32 0
     33   call void @ForceXmmSpills()
     34   ret <4 x i32> %vec.local
     35 ; CHECK-LABEL: align_local_vector
     36 ; CHECK: movups xmm0,XMMWORD PTR [esp]
     37 ; CHECK-NEXT: add esp,0x1c
     38 ; CHECK-NEXT: ret
     39 }
     40 
     41 declare void @ForceXmmSpills()
     42 
     43 define internal <4 x i32> @align_global_vector_ebp_based(i32 %arg) {
     44 entry:
     45   br label %eblock  ; Disable alloca optimization
     46 eblock:
     47   %alloc = alloca i8, i32 1, align 1
     48   %vec.global = insertelement <4 x i32> undef, i32 %arg, i32 0
     49   br label %block
     50 block:
     51   call void @ForceXmmSpillsAndUseAlloca(i8* %alloc)
     52   ret <4 x i32> %vec.global
     53 ; CHECK-LABEL: align_global_vector_ebp_based
     54 ; CHECK: movups xmm0,XMMWORD PTR [ebp-0x18]
     55 ; CHECK-NEXT: mov esp,ebp
     56 ; CHECK-NEXT: pop ebp
     57 ; CHECK: ret
     58 }
     59 
     60 define internal <4 x i32> @align_local_vector_ebp_based(i32 %arg) {
     61 entry:
     62   br label %eblock  ; Disable alloca optimization
     63 eblock:
     64   %alloc = alloca i8, i32 1, align 1
     65   %vec.local = insertelement <4 x i32> undef, i32 %arg, i32 0
     66   call void @ForceXmmSpillsAndUseAlloca(i8* %alloc)
     67   ret <4 x i32> %vec.local
     68 ; CHECK-LABEL: align_local_vector_ebp_based
     69 ; CHECK: movups xmm0,XMMWORD PTR [ebp-0x18]
     70 ; CHECK-NEXT: mov esp,ebp
     71 ; CHECK-NEXT: pop ebp
     72 ; CHECK: ret
     73 }
     74 
     75 define internal <4 x i32> @align_local_vector_and_global_float(i32 %arg) {
     76 entry:
     77   %float.global = sitofp i32 %arg to float
     78   call void @ForceXmmSpillsAndUseFloat(float %float.global)
     79   br label %block
     80 block:
     81   %vec.local = insertelement <4 x i32> undef, i32 undef, i32 0
     82   call void @ForceXmmSpillsAndUseFloat(float %float.global)
     83   ret <4 x i32> %vec.local
     84 ; CHECK-LABEL: align_local_vector_and_global_float
     85 ; CHECK: cvtsi2ss xmm0,eax
     86 ; CHECK-NEXT: movss DWORD PTR [esp+{{0x1c|0x2c}}],xmm0
     87 ; CHECK: movups xmm0,XMMWORD PTR [{{esp\+0x10|esp\+0x20}}]
     88 ; CHECK-NEXT: add esp,0x3c
     89 ; CHECK-NEXT: ret
     90 }
     91 
     92 declare void @ForceXmmSpillsAndUseAlloca(i8*)
     93 declare void @ForceXmmSpillsAndUseFloat(float)
     94