|
| 1 | +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 |
| 2 | +# RUN: llc -mtriple aarch64-none-elf -mattr=+mte --run-pass=aarch64-ldst-opt %s -o - | FileCheck %s |
| 3 | + |
| 4 | +## When generating code with sanitize_memtag, we make use of the fact that the |
| 5 | +## sp+imm forms of many load and store instructions are not tag-checked, so we |
| 6 | +## can use SP directly instead of needing a register holding the tagged |
| 7 | +## pointer. However, this isn't true for the writeback versions of the |
| 8 | +## instructions, so we can't fold ADDs and SUBs into them in |
| 9 | +## AArch64LoadStoreOptimizer. This would be possible in cases where the |
| 10 | +## loads/stores only access untagged stack slots, but that information isn't |
| 11 | +## easily available after frame index elimination. |
| 12 | + |
| 13 | +--- | |
| 14 | + define void @pre_index() { |
| 15 | + entry: |
| 16 | + ret void |
| 17 | + } |
| 18 | + define void @pre_index_memtag() sanitize_memtag { |
| 19 | + entry: |
| 20 | + ret void |
| 21 | + } |
| 22 | + define void @pre_index_memtag_not_sp() sanitize_memtag { |
| 23 | + entry: |
| 24 | + ret void |
| 25 | + } |
| 26 | + define void @post_index() { |
| 27 | + entry: |
| 28 | + ret void |
| 29 | + } |
| 30 | + define void @post_index_memtag() sanitize_memtag { |
| 31 | + entry: |
| 32 | + ret void |
| 33 | + } |
| 34 | + define void @post_index_memtag_not_sp() sanitize_memtag { |
| 35 | + entry: |
| 36 | + ret void |
| 37 | + } |
| 38 | +... |
| 39 | +--- |
| 40 | +name: pre_index |
| 41 | +body: | |
| 42 | + bb.0.entry: |
| 43 | + liveins: $x0 |
| 44 | +
|
| 45 | + ; CHECK-LABEL: name: pre_index |
| 46 | + ; CHECK: liveins: $x0 |
| 47 | + ; CHECK-NEXT: {{ $}} |
| 48 | + ; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 |
| 49 | + ; CHECK-NEXT: early-clobber $sp = STRXpre killed renamable $x0, $sp, 16 |
| 50 | + ; CHECK-NEXT: RET undef $lr |
| 51 | + $sp = frame-setup SUBXri $sp, 16, 0 |
| 52 | + STRXui killed renamable $x0, $sp, 2 |
| 53 | + $sp = ADDXri $sp, 16, 0 |
| 54 | + RET undef $lr |
| 55 | +... |
| 56 | +--- |
| 57 | +name: pre_index_memtag |
| 58 | +body: | |
| 59 | + bb.0.entry: |
| 60 | + liveins: $x0 |
| 61 | +
|
| 62 | + ; CHECK-LABEL: name: pre_index_memtag |
| 63 | + ; CHECK: liveins: $x0 |
| 64 | + ; CHECK-NEXT: {{ $}} |
| 65 | + ; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 |
| 66 | + ; CHECK-NEXT: STRXui killed renamable $x0, $sp, 2 |
| 67 | + ; CHECK-NEXT: $sp = ADDXri $sp, 16, 0 |
| 68 | + ; CHECK-NEXT: RET undef $lr |
| 69 | + $sp = frame-setup SUBXri $sp, 16, 0 |
| 70 | + STRXui killed renamable $x0, $sp, 2 |
| 71 | + $sp = ADDXri $sp, 16, 0 |
| 72 | + RET undef $lr |
| 73 | +... |
| 74 | +--- |
| 75 | +name: pre_index_memtag_not_sp |
| 76 | +body: | |
| 77 | + bb.0.entry: |
| 78 | + liveins: $x0, $x1 |
| 79 | +
|
| 80 | + ; CHECK-LABEL: name: pre_index_memtag_not_sp |
| 81 | + ; CHECK: liveins: $x0, $x1 |
| 82 | + ; CHECK-NEXT: {{ $}} |
| 83 | + ; CHECK-NEXT: $x1 = frame-setup SUBXri $x1, 16, 0 |
| 84 | + ; CHECK-NEXT: early-clobber $x1 = STRXpre killed renamable $x0, $x1, 16 |
| 85 | + ; CHECK-NEXT: RET undef $lr, implicit $x1 |
| 86 | + $x1 = frame-setup SUBXri $x1, 16, 0 |
| 87 | + STRXui killed renamable $x0, $x1, 2 |
| 88 | + $x1 = ADDXri $x1, 16, 0 |
| 89 | + RET undef $lr, implicit $x1 |
| 90 | +... |
| 91 | +--- |
| 92 | +name: post_index |
| 93 | +body: | |
| 94 | + bb.0.entry: |
| 95 | + liveins: $x0 |
| 96 | +
|
| 97 | + ; CHECK-LABEL: name: post_index |
| 98 | + ; CHECK: liveins: $x0 |
| 99 | + ; CHECK-NEXT: {{ $}} |
| 100 | + ; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 |
| 101 | + ; CHECK-NEXT: early-clobber $sp = STRXpost killed renamable $x0, $sp, 16 |
| 102 | + ; CHECK-NEXT: RET undef $lr |
| 103 | + $sp = frame-setup SUBXri $sp, 16, 0 |
| 104 | + STRXui killed renamable $x0, $sp, 0 |
| 105 | + $sp = ADDXri $sp, 16, 0 |
| 106 | + RET undef $lr |
| 107 | +... |
| 108 | +--- |
| 109 | +name: post_index_memtag |
| 110 | +body: | |
| 111 | + bb.0.entry: |
| 112 | + liveins: $x0 |
| 113 | +
|
| 114 | + ; CHECK-LABEL: name: post_index_memtag |
| 115 | + ; CHECK: liveins: $x0 |
| 116 | + ; CHECK-NEXT: {{ $}} |
| 117 | + ; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0 |
| 118 | + ; CHECK-NEXT: STRXui killed renamable $x0, $sp, 0 |
| 119 | + ; CHECK-NEXT: $sp = ADDXri $sp, 16, 0 |
| 120 | + ; CHECK-NEXT: RET undef $lr |
| 121 | + $sp = frame-setup SUBXri $sp, 16, 0 |
| 122 | + STRXui killed renamable $x0, $sp, 0 |
| 123 | + $sp = ADDXri $sp, 16, 0 |
| 124 | + RET undef $lr |
| 125 | +... |
| 126 | +--- |
| 127 | +name: post_index_memtag_not_sp |
| 128 | +body: | |
| 129 | + bb.0.entry: |
| 130 | + liveins: $x0, $x1 |
| 131 | +
|
| 132 | + ; CHECK-LABEL: name: post_index_memtag_not_sp |
| 133 | + ; CHECK: liveins: $x0, $x1 |
| 134 | + ; CHECK-NEXT: {{ $}} |
| 135 | + ; CHECK-NEXT: $x1 = frame-setup SUBXri $x1, 16, 0 |
| 136 | + ; CHECK-NEXT: early-clobber $x1 = STRXpost killed renamable $x0, $x1, 16 |
| 137 | + ; CHECK-NEXT: RET undef $lr, implicit $x1 |
| 138 | + $x1 = frame-setup SUBXri $x1, 16, 0 |
| 139 | + STRXui killed renamable $x0, $x1, 0 |
| 140 | + $x1 = ADDXri $x1, 16, 0 |
| 141 | + RET undef $lr, implicit $x1 |
| 142 | +... |
0 commit comments