Skip to content

Commit c8c1e4e

Browse files
authored
[WebAssembly] Fix uses of -DAG and -NOT in wasm-target-features.c (#89777)
We are currently using `PREFIX-DAG` and `PREFIX-NOT` within a single `PREFIX` test in a mixed way, but `-DAG` and `-NOT` do not work that way. For example: Result: ``` 1 2 3 ``` Test file: ```c // CHECK-DAG: 3 // CHECK-DAG: 1 // CHECK-NOT: 2 ``` This does not work. The last line `CHECK-NOT: 2` does not trigger any error, because we've already covered all three lines (1~3) while matching `CHECK-DAG: 3` and `CHECK-DAG: 1`, and FileCheck tries to check the line `CHECK-NOT: 2` _after_ the line `3`. Actually, we have ```c // BLEEDING-EDGE-NOT:#define __wasm_reference_types__ 1{{$}} ``` even though reference-types is enabled in 'bleeding-edge' config, and this has not triggered any error. This section (https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive) explains the interactions between `CHECK-DAG` and `CHECK-NOT`s: > As a result, the surrounding `CHECK-DAG:` directives cannot be reordered, i.e. all occurrences matching `CHECK-DAG:` before `CHECK-NOT:` must not fall behind occurrences matching `CHECK-DAG:` after `CHECK-NOT:`. So in order to test the 'include' lists and 'not-include' lists, we have to run the tests twice with different prefixes. This splits `GENERIC` and `BLEEDING-EDGE` tests in two configs (`***-INCLUDE` and `***`) to test them correctly. This also adds some spaces after colons, sorts the feature lists, and adds `1{{$}}` to the `MVP` tests to make them consistent with `GENERIC` and `BLEEDING-EDGE` tests.
1 parent da1e3e8 commit c8c1e4e

File tree

1 file changed

+55
-38
lines changed

1 file changed

+55
-38
lines changed

clang/test/Preprocessor/wasm-target-features.c

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -132,60 +132,77 @@
132132
// RUN: -target wasm64-unknown-unknown -mcpu=mvp \
133133
// RUN: | FileCheck %s -check-prefix=MVP
134134
//
135-
// MVP-NOT:#define __wasm_simd128__
136-
// MVP-NOT:#define __wasm_nontrapping_fptoint__
137-
// MVP-NOT:#define __wasm_sign_ext__
138-
// MVP-NOT:#define __wasm_exception_handling__
139-
// MVP-NOT:#define __wasm_bulk_memory__
140-
// MVP-NOT:#define __wasm_atomics__
141-
// MVP-NOT:#define __wasm_mutable_globals__
142-
// MVP-NOT:#define __wasm_multivalue__
143-
// MVP-NOT:#define __wasm_tail_call__
144-
// MVP-NOT:#define __wasm_reference_types__
145-
// MVP-NOT:#define __wasm_extended_const__
146-
// MVP-NOT:#define __wasm_multimemory__
147-
// MVP-NOT:#define __wasm_relaxed_simd__
135+
// MVP-NOT: #define __wasm_atomics__ 1{{$}}
136+
// MVP-NOT: #define __wasm_bulk_memory__ 1{{$}}
137+
// MVP-NOT: #define __wasm_exception_handling__ 1{{$}}
138+
// MVP-NOT: #define __wasm_extended_const__ 1{{$}}
139+
// MVP-NOT: #define __wasm_multimemory__ 1{{$}}
140+
// MVP-NOT: #define __wasm_multivalue__ 1{{$}}
141+
// MVP-NOT: #define __wasm_mutable_globals__ 1{{$}}
142+
// MVP-NOT: #define __wasm_nontrapping_fptoint__ 1{{$}}
143+
// MVP-NOT: #define __wasm_reference_types__ 1{{$}}
144+
// MVP-NOT: #define __wasm_relaxed_simd__ 1{{$}}
145+
// MVP-NOT: #define __wasm_sign_ext__ 1{{$}}
146+
// MVP-NOT: #define __wasm_simd128__ 1{{$}}
147+
// MVP-NOT: #define __wasm_tail_call__ 1{{$}}
148148

149+
// RUN: %clang -E -dM %s -o - 2>&1 \
150+
// RUN: -target wasm32-unknown-unknown -mcpu=generic \
151+
// RUN: | FileCheck %s -check-prefix=GENERIC-INCLUDE
152+
// RUN: %clang -E -dM %s -o - 2>&1 \
153+
// RUN: -target wasm64-unknown-unknown -mcpu=generic \
154+
// RUN: | FileCheck %s -check-prefix=GENERIC-INCLUDE
155+
//
156+
// GENERIC-INCLUDE-DAG: #define __wasm_mutable_globals__ 1{{$}}
157+
// GENERIC-INCLUDE-DAG: #define __wasm_sign_ext__ 1{{$}}
158+
//
149159
// RUN: %clang -E -dM %s -o - 2>&1 \
150160
// RUN: -target wasm32-unknown-unknown -mcpu=generic \
151161
// RUN: | FileCheck %s -check-prefix=GENERIC
152162
// RUN: %clang -E -dM %s -o - 2>&1 \
153163
// RUN: -target wasm64-unknown-unknown -mcpu=generic \
154164
// RUN: | FileCheck %s -check-prefix=GENERIC
155165
//
156-
// GENERIC-DAG:#define __wasm_sign_ext__ 1{{$}}
157-
// GENERIC-DAG:#define __wasm_mutable_globals__ 1{{$}}
158-
// GENERIC-NOT:#define __wasm_nontrapping_fptoint__ 1{{$}}
159-
// GENERIC-NOT:#define __wasm_bulk_memory__ 1{{$}}
160-
// GENERIC-NOT:#define __wasm_simd128__ 1{{$}}
161-
// GENERIC-NOT:#define __wasm_atomics__ 1{{$}}
162-
// GENERIC-NOT:#define __wasm_tail_call__ 1{{$}}
163-
// GENERIC-NOT:#define __wasm_multimemory__ 1{{$}}
164-
// GENERIC-NOT:#define __wasm_exception_handling__ 1{{$}}
165-
// GENERIC-NOT:#define __wasm_multivalue__ 1{{$}}
166-
// GENERIC-NOT:#define __wasm_reference_types__ 1{{$}}
167-
// GENERIC-NOT:#define __wasm_extended_const__ 1{{$}}
166+
// GENERIC-NOT: #define __wasm_atomics__ 1{{$}}
167+
// GENERIC-NOT: #define __wasm_bulk_memory__ 1{{$}}
168+
// GENERIC-NOT: #define __wasm_exception_handling__ 1{{$}}
169+
// GENERIC-NOT: #define __wasm_extended_const__ 1{{$}}
170+
// GENERIC-NOT: #define __wasm_multimemory__ 1{{$}}
171+
// GENERIC-NOT: #define __wasm_multivalue__ 1{{$}}
172+
// GENERIC-NOT: #define __wasm_nontrapping_fptoint__ 1{{$}}
173+
// GENERIC-NOT: #define __wasm_reference_types__ 1{{$}}
174+
// GENERIC-NOT: #define __wasm_relaxed_simd__ 1{{$}}
175+
// GENERIC-NOT: #define __wasm_simd128__ 1{{$}}
176+
// GENERIC-NOT: #define __wasm_tail_call__ 1{{$}}
168177

178+
// RUN: %clang -E -dM %s -o - 2>&1 \
179+
// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge \
180+
// RUN: | FileCheck %s -check-prefix=BLEEDING-EDGE-INCLUDE
181+
// RUN: %clang -E -dM %s -o - 2>&1 \
182+
// RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge \
183+
// RUN: | FileCheck %s -check-prefix=BLEEDING-EDGE-INCLUDE
184+
//
185+
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_atomics__ 1{{$}}
186+
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_bulk_memory__ 1{{$}}
187+
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_multimemory__ 1{{$}}
188+
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_mutable_globals__ 1{{$}}
189+
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_nontrapping_fptoint__ 1{{$}}
190+
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_reference_types__ 1{{$}}
191+
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_sign_ext__ 1{{$}}
192+
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_simd128__ 1{{$}}
193+
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_tail_call__ 1{{$}}
194+
//
169195
// RUN: %clang -E -dM %s -o - 2>&1 \
170196
// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge \
171197
// RUN: | FileCheck %s -check-prefix=BLEEDING-EDGE
172198
// RUN: %clang -E -dM %s -o - 2>&1 \
173199
// RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge \
174200
// RUN: | FileCheck %s -check-prefix=BLEEDING-EDGE
175201
//
176-
// BLEEDING-EDGE-DAG:#define __wasm_nontrapping_fptoint__ 1{{$}}
177-
// BLEEDING-EDGE-DAG:#define __wasm_sign_ext__ 1{{$}}
178-
// BLEEDING-EDGE-DAG:#define __wasm_bulk_memory__ 1{{$}}
179-
// BLEEDING-EDGE-DAG:#define __wasm_simd128__ 1{{$}}
180-
// BLEEDING-EDGE-DAG:#define __wasm_atomics__ 1{{$}}
181-
// BLEEDING-EDGE-DAG:#define __wasm_mutable_globals__ 1{{$}}
182-
// BLEEDING-EDGE-DAG:#define __wasm_tail_call__ 1{{$}}
183-
// BLEEDING-EDGE-DAG:#define __wasm_multimemory__ 1{{$}}
184-
// BLEEDING-EDGE-NOT:#define __wasm_exception_handling__ 1{{$}}
185-
// BLEEDING-EDGE-NOT:#define __wasm_multivalue__ 1{{$}}
186-
// BLEEDING-EDGE-NOT:#define __wasm_reference_types__ 1{{$}}
187-
// BLEEDING-EDGE-NOT:#define __wasm_extended_const__ 1{{$}}
188-
// BLEEDING-EDGE-NOT:#define __wasm_relaxed_simd__ 1{{$}}
202+
// BLEEDING-EDGE-NOT: #define __wasm_exception_handling__ 1{{$}}
203+
// BLEEDING-EDGE-NOT: #define __wasm_extended_const__ 1{{$}}
204+
// BLEEDING-EDGE-NOT: #define __wasm_multivalue__ 1{{$}}
205+
// BLEEDING-EDGE-NOT: #define __wasm_relaxed_simd__ 1{{$}}
189206

190207
// RUN: %clang -E -dM %s -o - 2>&1 \
191208
// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge -mno-simd128 \

0 commit comments

Comments
 (0)