OLD | NEW |
(Empty) | |
| 1 ; RUN: not pnacl-abicheck < %s | FileCheck %s |
| 2 ; Test types allowed by PNaCl ABI |
| 3 |
| 4 |
| 5 ; CHECK: Function badReturn has disallowed type: half* () |
| 6 define internal half* @badReturn() { |
| 7 unreachable |
| 8 } |
| 9 |
| 10 ; CHECK: Function badArgType1 has disallowed type: void (half, i32) |
| 11 define internal void @badArgType1(half %a, i32 %b) { |
| 12 ret void |
| 13 } |
| 14 ; CHECK: Function badArgType2 has disallowed type: void (i32, half) |
| 15 define internal void @badArgType2(i32 %a, half %b) { |
| 16 ret void |
| 17 } |
| 18 |
| 19 |
| 20 define internal void @func() { |
| 21 entry: |
| 22 br label %block |
| 23 block: |
| 24 |
| 25 ; We test for allowed/disallowed types via phi nodes. This gives us |
| 26 ; a uniform way to test any type. |
| 27 |
| 28 ; Allowed types |
| 29 |
| 30 ; Scalars. |
| 31 phi i1 [ undef, %entry ] |
| 32 phi i8 [ undef, %entry ] |
| 33 phi i16 [ undef, %entry ] |
| 34 phi i32 [ undef, %entry ] |
| 35 phi i64 [ undef, %entry ] |
| 36 phi float [ undef, %entry ] |
| 37 phi double [ undef, %entry ] |
| 38 ; Vectors. |
| 39 phi <4 x i1> [ undef, %entry ] |
| 40 phi <8 x i1> [ undef, %entry ] |
| 41 phi <16 x i1> [ undef, %entry ] |
| 42 phi <16 x i8> [ undef, %entry ] |
| 43 phi <8 x i16> [ undef, %entry ] |
| 44 phi <4 x i32> [ undef, %entry ] |
| 45 phi <4 x float> [ undef, %entry ] |
| 46 ; CHECK-NOT: disallowed |
| 47 |
| 48 |
| 49 ; Disallowed integer types |
| 50 |
| 51 phi i4 [ undef, %entry ] |
| 52 ; CHECK: Function func disallowed: bad operand: {{.*}} i4 |
| 53 |
| 54 phi i33 [ undef, %entry ] |
| 55 ; CHECK-NEXT: disallowed: bad operand: {{.*}} i33 |
| 56 |
| 57 phi i128 [ undef, %entry ] |
| 58 ; CHECK-NEXT: disallowed: bad operand: {{.*}} i128 |
| 59 |
| 60 |
| 61 ; Disallowed floating point types |
| 62 |
| 63 phi half [ undef, %entry ] |
| 64 ; CHECK-NEXT: disallowed: bad operand: {{.*}} half |
| 65 |
| 66 phi x86_fp80 [ undef, %entry ] |
| 67 ; CHECK-NEXT: disallowed: bad operand: {{.*}} x86_fp80 |
| 68 |
| 69 phi fp128 [ undef, %entry ] |
| 70 ; CHECK-NEXT: disallowed: bad operand: {{.*}} fp128 |
| 71 |
| 72 phi ppc_fp128 [ undef, %entry ] |
| 73 ; CHECK-NEXT: disallowed: bad operand: {{.*}} ppc_fp128 |
| 74 |
| 75 phi x86_mmx [ undef, %entry ] |
| 76 ; CHECK-NEXT: disallowed: bad operand: {{.*}} x86_mmx |
| 77 |
| 78 |
| 79 ; Derived types are disallowed too |
| 80 |
| 81 phi i32* [ undef, %entry ] |
| 82 ; CHECK-NEXT: disallowed: bad operand: {{.*}} i32* |
| 83 |
| 84 phi [1 x i32] [ undef, %entry ] |
| 85 ; CHECK-NEXT: disallowed: bad operand: {{.*}} [1 x i32] |
| 86 |
| 87 phi { i32, float } [ undef, %entry ] |
| 88 ; CHECK-NEXT: disallowed: bad operand: {{.*}} { i32, float } |
| 89 |
| 90 phi void (i32)* [ undef, %entry ] |
| 91 ; CHECK-NEXT: disallowed: bad operand: {{.*}} void (i32)* |
| 92 |
| 93 phi <{ i8, i32 }> [ undef, %entry ] |
| 94 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <{ i8, i32 }> |
| 95 |
| 96 ; Vector types of weird bit width are disallowed |
| 97 phi <1 x i1> [ undef, %entry ] |
| 98 phi <3 x i1> [ undef, %entry ] |
| 99 phi <17 x i1> [ undef, %entry ] |
| 100 phi <1 x i32> [ undef, %entry ] |
| 101 phi <2 x i32> [ undef, %entry ] |
| 102 phi <3 x i32> [ undef, %entry ] |
| 103 phi <5 x i32> [ undef, %entry ] |
| 104 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <1 x i1> |
| 105 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <3 x i1> |
| 106 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <17 x i1> |
| 107 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <1 x i32> |
| 108 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <2 x i32> |
| 109 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <3 x i32> |
| 110 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <5 x i32> |
| 111 |
| 112 ; i64 and double vectors are currently disallowed, and so are the |
| 113 ; corresponding bool vectors. |
| 114 phi <2 x i1> [ undef, %entry ] |
| 115 phi <2 x i64> [ undef, %entry ] |
| 116 phi <2 x double> [ undef, %entry ] |
| 117 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <2 x i1> |
| 118 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <2 x i64> |
| 119 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <2 x double> |
| 120 |
| 121 ; 256-bit width vectors are currently disallowed, and so are the |
| 122 ; corresponding bool vectors. |
| 123 phi <32 x i1> [ undef, %entry ] |
| 124 phi <32 x i8> [ undef, %entry ] |
| 125 phi <16 x i16> [ undef, %entry ] |
| 126 phi <8 x i32> [ undef, %entry ] |
| 127 phi <4 x i64> [ undef, %entry ] |
| 128 phi <8 x float> [ undef, %entry ] |
| 129 phi <4 x double> [ undef, %entry ] |
| 130 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <32 x i1> |
| 131 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <32 x i8> |
| 132 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <16 x i16> |
| 133 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <8 x i32> |
| 134 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <4 x i64> |
| 135 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <8 x float> |
| 136 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <4 x double> |
| 137 |
| 138 ; 512-bit width vectors are currently disallowed, and so are the |
| 139 ; corresponding bool vectors. |
| 140 phi <64 x i1> [ undef, %entry ] |
| 141 phi <64 x i8> [ undef, %entry ] |
| 142 phi <32 x i16> [ undef, %entry ] |
| 143 phi <16 x i32> [ undef, %entry ] |
| 144 phi <8 x i64> [ undef, %entry ] |
| 145 phi <16 x float> [ undef, %entry ] |
| 146 phi <8 x double> [ undef, %entry ] |
| 147 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <64 x i1> |
| 148 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <64 x i8> |
| 149 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <32 x i16> |
| 150 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <16 x i32> |
| 151 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <8 x i64> |
| 152 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <16 x float> |
| 153 ; CHECK-NEXT: disallowed: bad operand: {{.*}} <8 x double> |
| 154 |
| 155 ret void |
| 156 } |
| 157 |
| 158 |
| 159 ; Named types. With the current implementation, named types are legal |
| 160 ; until they are actually attempted to be used. Might want to fix that. |
| 161 %struct.s1 = type { half, float} |
| 162 %struct.s2 = type { i32, i32} |
| 163 |
| 164 define internal void @func2() { |
| 165 entry: |
| 166 br label %block |
| 167 block: |
| 168 |
| 169 phi %struct.s1 [ undef, %entry ] |
| 170 ; CHECK: disallowed: bad operand: {{.*}} %struct.s1 |
| 171 |
| 172 phi %struct.s2 [ undef, %entry ] |
| 173 ; CHECK-NEXT: disallowed: bad operand: {{.*}} %struct.s2 |
| 174 |
| 175 ret void |
| 176 } |
| 177 |
| 178 |
| 179 ; Circularities: here to make sure the verifier doesn't crash or assert. |
| 180 |
| 181 ; This oddity is perfectly legal according to the IR and ABI verifiers. |
| 182 ; Might want to fix that. (good luck initializing one of these, though.) |
| 183 %struct.snake = type { i32, %struct.tail } |
| 184 %struct.tail = type { %struct.snake, i32 } |
| 185 |
| 186 %struct.linked = type { i32, %struct.linked * } |
| 187 |
| 188 define internal void @func3() { |
| 189 entry: |
| 190 br label %block |
| 191 block: |
| 192 |
| 193 phi %struct.snake [ undef, %entry ] |
| 194 ; CHECK: disallowed: bad operand: {{.*}} %struct.snake |
| 195 |
| 196 phi %struct.linked [ undef, %entry ] |
| 197 ; CHECK-NEXT: disallowed: bad operand: {{.*}} %struct.linked |
| 198 |
| 199 ret void |
| 200 } |
| 201 |
| 202 |
| 203 ; This stops the verifier from complaining about the lack of an entry point. |
| 204 define void @_start(i32 %arg) { |
| 205 ret void |
| 206 } |
OLD | NEW |