Skip to content

Commit a54704d

Browse files
authored
[WebAssembly] Split and tidy up target features test (#96735)
This splits `target-features.ll` into two tests: `target-features-attrs.ll` and `target-features-cpus.ll`. Now `target-features-attrs.ll` contains tests with bitcode function attributes and `-mattr=` options. The current `target-features.ll` file's FileCheck lines are confusing, mainly because it is unclear how `CHECK` and `ATTRS` lines are meant to be different. Turns out, before 67ec874, `-mattr=` options used to override any existing bitcode function attributes, but after the commit that's not the case anymore. So the original test had a line that tested `i32.atomic.rmw.cmpxchg` was not generated when `-mattr=+simd128` was given (because the existing `+atomics` in the function attributes is overriden). That commit deleted that line and changed some `ATTRS` lines into `CHECK`, which was confusing. This PR simplifies that part and does not test the absence of any instructions, and the effect of `-mattr=` option is only tested with the target features section. And `target-features-cpus.ll` only tests the sets of features enabled by `-mcpu=` lines. It is better to have this as a separate file because once you have bitcode function attributes they end up in the target features section too, making the testing of only the `-mcpu=` options difficult.
1 parent 57d3d07 commit a54704d

File tree

2 files changed

+84
-68
lines changed

2 files changed

+84
-68
lines changed
Lines changed: 36 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
; RUN: llc < %s | FileCheck %s --check-prefixes CHECK,ATTRS
2-
; RUN: llc < %s -mcpu=mvp -mattr=+simd128 | FileCheck %s --check-prefixes CHECK,SIMD128
3-
; RUN: llc < %s -mcpu=bleeding-edge | FileCheck %s --check-prefixes CHECK,BLEEDING-EDGE
1+
; RUN: llc -mcpu=mvp < %s | FileCheck %s
2+
; RUN: llc -mcpu=mvp -mattr=+simd128 < %s | FileCheck %s --check-prefixes SIMD128
43

54
; Test that codegen emits target features from the command line or
65
; function attributes correctly and that features are enabled for the
@@ -33,84 +32,53 @@ attributes #2 = { "target-features"="+reference-types" }
3332
; CHECK-LABEL: fn_atomics:
3433

3534
; Expanded atomicrmw min
36-
; ATTRS: loop
35+
; CHECK: loop
3736
; CHECK: i32.atomic.rmw.cmpxchg
38-
; ATTRS: end_loop
37+
; CHECK: end_loop
3938

4039
; nontrapping fptoint
4140
; CHECK: i32.trunc_sat_f32_u
42-
; ATTRS: i32.store
41+
; CHECK: i32.store
4342

4443
; `fn_nontrapping_fptoint` should be the same as `fn_atomics`
4544
; CHECK-LABEL: fn_nontrapping_fptoint:
4645

4746
; Expanded atomicrmw min
48-
; ATTRS: loop
47+
; CHECK: loop
4948
; CHECK: i32.atomic.rmw.cmpxchg
50-
; ATTRS: end_loop
49+
; CHECK: end_loop
5150

5251
; nontrapping fptoint
5352
; CHECK: i32.trunc_sat_f32_u
54-
; ATTRS: i32.store
53+
; CHECK: i32.store
5554

55+
; Features in function attributes:
56+
; +atomics, +nontrapping-fptoint, +reference-types
5657
; CHECK-LABEL: .custom_section.target_features,"",@
57-
58-
; +atomics, +reference-types, +mutable-globals
59-
; ATTRS-NEXT: .int8 5
60-
; ATTRS-NEXT: .int8 43
61-
; ATTRS-NEXT: .int8 7
62-
; ATTRS-NEXT: .ascii "atomics"
63-
; ATTRS-NEXT: .int8 43
64-
; ATTRS-NEXT: .int8 15
65-
; ATTRS-NEXT: .ascii "mutable-globals"
66-
; ATTRS-NEXT: .int8 43
67-
; ATTRS-NEXT: .int8 19
68-
; ATTRS-NEXT: .ascii "nontrapping-fptoint"
69-
; ATTRS-NEXT: .int8 43
70-
; ATTRS-NEXT: .int8 15
71-
; ATTRS-NEXT: .ascii "reference-types"
72-
; ATTRS-NEXT: .int8 43
73-
; ATTRS-NEXT: .int8 8
74-
58+
; CHECK-NEXT: .int8 3
59+
; CHECK-NEXT: .int8 43
60+
; CHECK-NEXT: .int8 7
61+
; CHECK-NEXT: .ascii "atomics"
62+
; CHECK-NEXT: .int8 43
63+
; CHECK-NEXT: .int8 19
64+
; CHECK-NEXT: .ascii "nontrapping-fptoint"
65+
; CHECK-NEXT: .int8 43
66+
; CHECK-NEXT: .int8 15
67+
; CHECK-NEXT: .ascii "reference-types"
68+
69+
; Features in function attributes + features specified by -mattr= option:
7570
; +atomics, +nontrapping-fptoint, +reference-types, +simd128
76-
; SIMD128-NEXT: .int8 4
77-
; SIMD128-NEXT: .int8 43
78-
; SIMD128-NEXT: .int8 7
79-
; SIMD128-NEXT: .ascii "atomics"
80-
; SIMD128-NEXT: .int8 43
81-
; SIMD128-NEXT: .int8 19
82-
; SIMD128-NEXT: .ascii "nontrapping-fptoint"
83-
; SIMD128-NEXT: .int8 43
84-
; SIMD128-NEXT: .int8 15
85-
; SIMD128-NEXT: .ascii "reference-types"
86-
; SIMD128-NEXT: .int8 43
87-
; SIMD128-NEXT: .int8 7
88-
; SIMD128-NEXT: .ascii "simd128"
89-
90-
; +atomics, +bulk-memory, +mutable-globals, +nontrapping-fptoint,
91-
; +reference-types, +sign-ext, +simd128, +tail-call
92-
; BLEEDING-EDGE-NEXT: .int8 8
93-
; BLEEDING-EDGE-NEXT: .int8 43
94-
; BLEEDING-EDGE-NEXT: .int8 7
95-
; BLEEDING-EDGE-NEXT: .ascii "atomics"
96-
; BLEEDING-EDGE-NEXT: .int8 43
97-
; BLEEDING-EDGE-NEXT: .int8 11
98-
; BLEEDING-EDGE-NEXT: .ascii "bulk-memory"
99-
; BLEEDING-EDGE-NEXT: .int8 43
100-
; BLEEDING-EDGE-NEXT: .int8 15
101-
; BLEEDING-EDGE-NEXT: .ascii "mutable-globals"
102-
; BLEEDING-EDGE-NEXT: .int8 43
103-
; BLEEDING-EDGE-NEXT: .int8 19
104-
; BLEEDING-EDGE-NEXT: .ascii "nontrapping-fptoint"
105-
; BLEEDING-EDGE-NEXT: .int8 43
106-
; BLEEDING-EDGE-NEXT: .int8 15
107-
; BLEEDING-EDGE-NEXT: .ascii "reference-types"
108-
; BLEEDING-EDGE-NEXT: .int8 43
109-
; BLEEDING-EDGE-NEXT: .int8 8
110-
; BLEEDING-EDGE-NEXT: .ascii "sign-ext"
111-
; BLEEDING-EDGE-NEXT: .int8 43
112-
; BLEEDING-EDGE-NEXT: .int8 7
113-
; BLEEDING-EDGE-NEXT: .ascii "simd128"
114-
; BLEEDING-EDGE-NEXT: .int8 43
115-
; BLEEDING-EDGE-NEXT: .int8 9
116-
; BLEEDING-EDGE-NEXT: .ascii "tail-call"
71+
; SIMD128-LABEL: .custom_section.target_features,"",@
72+
; SIMD128-NEXT: .int8 4
73+
; SIMD128-NEXT: .int8 43
74+
; SIMD128-NEXT: .int8 7
75+
; SIMD128-NEXT: .ascii "atomics"
76+
; SIMD128-NEXT: .int8 43
77+
; SIMD128-NEXT: .int8 19
78+
; SIMD128-NEXT: .ascii "nontrapping-fptoint"
79+
; SIMD128-NEXT: .int8 43
80+
; SIMD128-NEXT: .int8 15
81+
; SIMD128-NEXT: .ascii "reference-types"
82+
; SIMD128-NEXT: .int8 43
83+
; SIMD128-NEXT: .int8 7
84+
; SIMD128-NEXT: .ascii "simd128"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
; RUN: llc < %s -mcpu=mvp | FileCheck %s --check-prefixes MVP
2+
; RUN: llc < %s -mcpu=generic | FileCheck %s --check-prefixes GENERIC
3+
; RUN: llc < %s | FileCheck %s --check-prefixes GENERIC
4+
; RUN: llc < %s -mcpu=bleeding-edge | FileCheck %s --check-prefixes BLEEDING-EDGE
5+
6+
; Test that the target features section contains the correct set of features
7+
; depending on -mcpu= options.
8+
9+
target triple = "wasm32-unknown-unknown"
10+
11+
; mvp: should not contain the target features section
12+
; MVP-NOT: .custom_section.target_features,"",@
13+
14+
; generic: +mutable-globals, +sign-ext
15+
; GENERIC-LABEL: .custom_section.target_features,"",@
16+
; GENERIC-NEXT: .int8 2
17+
; GENERIC-NEXT: .int8 43
18+
; GENERIC-NEXT: .int8 15
19+
; GENERIC-NEXT: .ascii "mutable-globals"
20+
; GENERIC-NEXT: .int8 43
21+
; GENERIC-NEXT: .int8 8
22+
; GENERIC-NEXT: .ascii "sign-ext"
23+
24+
; bleeding-edge: +atomics, +bulk-memory, +mutable-globals, +nontrapping-fptoint,
25+
; +sign-ext, +simd128, +tail-call
26+
; BLEEDING-EDGE-LABEL: .section .custom_section.target_features,"",@
27+
; BLEEDING-EDGE-NEXT: .int8 7
28+
; BLEEDING-EDGE-NEXT: .int8 43
29+
; BLEEDING-EDGE-NEXT: .int8 7
30+
; BLEEDING-EDGE-NEXT: .ascii "atomics"
31+
; BLEEDING-EDGE-NEXT: .int8 43
32+
; BLEEDING-EDGE-NEXT: .int8 11
33+
; BLEEDING-EDGE-NEXT: .ascii "bulk-memory"
34+
; BLEEDING-EDGE-NEXT: .int8 43
35+
; BLEEDING-EDGE-NEXT: .int8 15
36+
; BLEEDING-EDGE-NEXT: .ascii "mutable-globals"
37+
; BLEEDING-EDGE-NEXT: .int8 43
38+
; BLEEDING-EDGE-NEXT: .int8 19
39+
; BLEEDING-EDGE-NEXT: .ascii "nontrapping-fptoint"
40+
; BLEEDING-EDGE-NEXT: .int8 43
41+
; BLEEDING-EDGE-NEXT: .int8 8
42+
; BLEEDING-EDGE-NEXT: .ascii "sign-ext"
43+
; BLEEDING-EDGE-NEXT: .int8 43
44+
; BLEEDING-EDGE-NEXT: .int8 7
45+
; BLEEDING-EDGE-NEXT: .ascii "simd128"
46+
; BLEEDING-EDGE-NEXT: .int8 43
47+
; BLEEDING-EDGE-NEXT: .int8 9
48+
; BLEEDING-EDGE-NEXT: .ascii "tail-call"

0 commit comments

Comments
 (0)