Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame^] | 1 | ; Test the allocation of frames in cases where we do not need to save |
| 2 | ; registers in the prologue. |
| 3 | ; |
| 4 | ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s |
| 5 | |
| 6 | ; The CFA offset is 160 (the caller-allocated part of the frame) + 168. |
| 7 | define void @f1(i64 %x) { |
| 8 | ; CHECK: f1: |
| 9 | ; CHECK: aghi %r15, -168 |
| 10 | ; CHECK: .cfi_def_cfa_offset 328 |
| 11 | ; CHECK: stg %r2, 160(%r15) |
| 12 | ; CHECK: aghi %r15, 168 |
| 13 | ; CHECK: br %r14 |
| 14 | %y = alloca i64, align 8 |
| 15 | store volatile i64 %x, i64* %y |
| 16 | ret void |
| 17 | } |
| 18 | |
| 19 | ; Check frames of size 32760, which is the largest size that can be both |
| 20 | ; allocated and freed using AGHI. This size is big enough to require |
| 21 | ; an emergency spill slot at 160(%r15), for instructions with unsigned |
| 22 | ; 12-bit offsets that end up being out of range. Fill the remaining |
| 23 | ; 32760 - 168 bytes by allocating (32760 - 168) / 8 = 4074 doublewords. |
| 24 | define void @f2(i64 %x) { |
| 25 | ; CHECK: f2: |
| 26 | ; CHECK: aghi %r15, -32760 |
| 27 | ; CHECK: .cfi_def_cfa_offset 32920 |
| 28 | ; CHECK: stg %r2, 168(%r15) |
| 29 | ; CHECK: aghi %r15, 32760 |
| 30 | ; CHECK: br %r14 |
| 31 | %y = alloca [4074 x i64], align 8 |
| 32 | %ptr = getelementptr inbounds [4074 x i64]* %y, i64 0, i64 0 |
| 33 | store volatile i64 %x, i64* %ptr |
| 34 | ret void |
| 35 | } |
| 36 | |
| 37 | ; Allocate one more doubleword. This is the one frame size that we can |
| 38 | ; allocate using AGHI but must free using AGFI. |
| 39 | define void @f3(i64 %x) { |
| 40 | ; CHECK: f3: |
| 41 | ; CHECK: aghi %r15, -32768 |
| 42 | ; CHECK: .cfi_def_cfa_offset 32928 |
| 43 | ; CHECK: stg %r2, 168(%r15) |
| 44 | ; CHECK: agfi %r15, 32768 |
| 45 | ; CHECK: br %r14 |
| 46 | %y = alloca [4075 x i64], align 8 |
| 47 | %ptr = getelementptr inbounds [4075 x i64]* %y, i64 0, i64 0 |
| 48 | store volatile i64 %x, i64* %ptr |
| 49 | ret void |
| 50 | } |
| 51 | |
| 52 | ; Allocate another doubleword on top of that. The allocation and free |
| 53 | ; must both use AGFI. |
| 54 | define void @f4(i64 %x) { |
| 55 | ; CHECK: f4: |
| 56 | ; CHECK: agfi %r15, -32776 |
| 57 | ; CHECK: .cfi_def_cfa_offset 32936 |
| 58 | ; CHECK: stg %r2, 168(%r15) |
| 59 | ; CHECK: agfi %r15, 32776 |
| 60 | ; CHECK: br %r14 |
| 61 | %y = alloca [4076 x i64], align 8 |
| 62 | %ptr = getelementptr inbounds [4076 x i64]* %y, i64 0, i64 0 |
| 63 | store volatile i64 %x, i64* %ptr |
| 64 | ret void |
| 65 | } |
| 66 | |
| 67 | ; The largest size that can be both allocated and freed using AGFI. |
| 68 | ; At this point the frame is too big to represent properly in the CFI. |
| 69 | define void @f5(i64 %x) { |
| 70 | ; CHECK: f5: |
| 71 | ; CHECK: agfi %r15, -2147483640 |
| 72 | ; CHECK: stg %r2, 168(%r15) |
| 73 | ; CHECK: agfi %r15, 2147483640 |
| 74 | ; CHECK: br %r14 |
| 75 | %y = alloca [268435434 x i64], align 8 |
| 76 | %ptr = getelementptr inbounds [268435434 x i64]* %y, i64 0, i64 0 |
| 77 | store volatile i64 %x, i64* %ptr |
| 78 | ret void |
| 79 | } |
| 80 | |
| 81 | ; The only frame size that can be allocated using a single AGFI but which |
| 82 | ; must be freed using two instructions. |
| 83 | define void @f6(i64 %x) { |
| 84 | ; CHECK: f6: |
| 85 | ; CHECK: agfi %r15, -2147483648 |
| 86 | ; CHECK: stg %r2, 168(%r15) |
| 87 | ; CHECK: agfi %r15, 2147483640 |
| 88 | ; CHECK: aghi %r15, 8 |
| 89 | ; CHECK: br %r14 |
| 90 | %y = alloca [268435435 x i64], align 8 |
| 91 | %ptr = getelementptr inbounds [268435435 x i64]* %y, i64 0, i64 0 |
| 92 | store volatile i64 %x, i64* %ptr |
| 93 | ret void |
| 94 | } |
| 95 | |
| 96 | ; The smallest frame size that needs two instructions to both allocate |
| 97 | ; and free the frame. |
| 98 | define void @f7(i64 %x) { |
| 99 | ; CHECK: f7: |
| 100 | ; CHECK: agfi %r15, -2147483648 |
| 101 | ; CHECK: aghi %r15, -8 |
| 102 | ; CHECK: stg %r2, 168(%r15) |
| 103 | ; CHECK: agfi %r15, 2147483640 |
| 104 | ; CHECK: aghi %r15, 16 |
| 105 | ; CHECK: br %r14 |
| 106 | %y = alloca [268435436 x i64], align 8 |
| 107 | %ptr = getelementptr inbounds [268435436 x i64]* %y, i64 0, i64 0 |
| 108 | store volatile i64 %x, i64* %ptr |
| 109 | ret void |
| 110 | } |