Matt Wala | d4799f4 | 2014-08-14 14:24:12 -0700 | [diff] [blame] | 1 | ; This checks to ensure that Subzero aligns spill slots. |
| 2 | |
Karl Schimpf | 2a5324a | 2014-09-25 09:37:49 -0700 | [diff] [blame] | 3 | ; TODO(kschimpf) Find out why lc2i needed. |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 4 | ; REQUIRES: allow_llvm_ir_as_input |
Karl Schimpf | 2a5324a | 2014-09-25 09:37:49 -0700 | [diff] [blame] | 5 | ; RUN: %lc2i -i %s --args --verbose none \ |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 6 | ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 7 | ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
Karl Schimpf | 2a5324a | 2014-09-25 09:37:49 -0700 | [diff] [blame] | 8 | ; RUN: %lc2i -i %s --args -O2 --verbose none \ |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 9 | ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 10 | ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
Matt Wala | d4799f4 | 2014-08-14 14:24:12 -0700 | [diff] [blame] | 11 | |
| 12 | ; The location of the stack slot for a variable is inferred from the |
| 13 | ; return sequence. |
| 14 | |
| 15 | ; In this file, "global" refers to a variable with a live range across |
| 16 | ; multiple basic blocks (not an LLVM global variable) and "local" |
| 17 | ; refers to a variable that is live in only a single basic block. |
| 18 | |
| 19 | define <4 x i32> @align_global_vector(i32 %arg) { |
| 20 | entry: |
| 21 | %vec.global = insertelement <4 x i32> undef, i32 %arg, i32 0 |
| 22 | br label %block |
| 23 | block: |
| 24 | call void @ForceXmmSpills() |
| 25 | ret <4 x i32> %vec.global |
| 26 | ; CHECK-LABEL: align_global_vector: |
| 27 | ; CHECK: movups xmm0, xmmword ptr [esp] |
| 28 | ; CHECK-NEXT: add esp, 28 |
| 29 | ; CHECK-NEXT: ret |
| 30 | } |
| 31 | |
| 32 | define <4 x i32> @align_local_vector(i32 %arg) { |
| 33 | entry: |
| 34 | br label %block |
| 35 | block: |
| 36 | %vec.local = insertelement <4 x i32> undef, i32 %arg, i32 0 |
| 37 | call void @ForceXmmSpills() |
| 38 | ret <4 x i32> %vec.local |
| 39 | ; CHECK-LABEL: align_local_vector: |
| 40 | ; CHECK: movups xmm0, xmmword ptr [esp] |
| 41 | ; CHECK-NEXT: add esp, 28 |
| 42 | ; CHECK-NEXT: ret |
| 43 | } |
| 44 | |
| 45 | declare void @ForceXmmSpills() |
| 46 | |
| 47 | define <4 x i32> @align_global_vector_ebp_based(i32 %arg) { |
| 48 | entry: |
| 49 | %alloc = alloca i8, i32 1, align 1 |
| 50 | %vec.global = insertelement <4 x i32> undef, i32 %arg, i32 0 |
| 51 | br label %block |
| 52 | block: |
| 53 | call void @ForceXmmSpillsAndUseAlloca(i8* %alloc) |
| 54 | ret <4 x i32> %vec.global |
| 55 | ; CHECK-LABEL: align_global_vector_ebp_based: |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 56 | ; CHECK: movups xmm0, xmmword ptr [ebp - 24] |
Matt Wala | d4799f4 | 2014-08-14 14:24:12 -0700 | [diff] [blame] | 57 | ; CHECK-NEXT: mov esp, ebp |
| 58 | ; CHECK-NEXT: pop ebp |
| 59 | ; CHECK: ret |
| 60 | } |
| 61 | |
| 62 | define <4 x i32> @align_local_vector_ebp_based(i32 %arg) { |
| 63 | entry: |
| 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: |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 69 | ; CHECK: movups xmm0, xmmword ptr [ebp - 24] |
Matt Wala | d4799f4 | 2014-08-14 14:24:12 -0700 | [diff] [blame] | 70 | ; CHECK-NEXT: mov esp, ebp |
| 71 | ; CHECK-NEXT: pop ebp |
| 72 | ; CHECK: ret |
| 73 | } |
| 74 | |
| 75 | define <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 |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 86 | ; CHECK-NEXT: movss dword ptr [esp + {{12|28}}], xmm0 |
| 87 | ; CHECK: movups xmm0, xmmword ptr [{{esp|esp \+ 16}}] |
Matt Wala | d4799f4 | 2014-08-14 14:24:12 -0700 | [diff] [blame] | 88 | ; CHECK-NEXT: add esp, 44 |
| 89 | ; CHECK-NEXT: ret |
| 90 | } |
| 91 | |
| 92 | declare void @ForceXmmSpillsAndUseAlloca(i8*) |
| 93 | declare void @ForceXmmSpillsAndUseFloat(float) |