Skip to content

Commit cfb9ff1

Browse files
authored
[SIMD] wasm-ctor-eval: Fix relaxed SIMD in expressions (#7508)
The previous fix #7495 handled functions computing something with relaxed SIMD, in which case an exception is thrown, but we also need to handle relaxed SIMD inside a function, since wasm-ctor-eval can partially-evaluate code. In that case we get NONCONSTANT_FLOW. Turns out adding --kept-exports is enough to test this, as keeping the exports around forces partial evaluation of their contents.
1 parent 4e1eaa7 commit cfb9ff1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/tools/wasm-ctor-eval.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,14 @@ EvalCtorOutcome evalCtor(EvallingModuleRunner& instance,
11151115
break;
11161116
} catch (NonconstantException& fail) {
11171117
if (!quiet) {
1118-
std::cout << " ...stopping due to non-constant code\n";
1118+
std::cout << " ...stopping due to non-constant func\n";
1119+
}
1120+
break;
1121+
}
1122+
1123+
if (flow.breakTo == NONCONSTANT_FLOW) {
1124+
if (!quiet) {
1125+
std::cout << " ...stopping due to non-constant flow\n";
11191126
}
11201127
break;
11211128
}

test/lit/ctor-eval/relaxed.wast

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
2-
;; RUN: wasm-ctor-eval %s --ctors=return,drop,passthrough --quiet -all -S -o - | filecheck %s
2+
;; RUN: wasm-ctor-eval %s --ctors=return,drop,passthrough --kept-exports=return,drop,passthrough --quiet -all -S -o - | filecheck %s
33

44
;; The relaxed SIMD operation here cannot be optimized by wasm-ctor-eval, as we
55
;; do not know how the VM that the code will run on should execute it. We can
@@ -10,6 +10,8 @@
1010

1111
;; CHECK: (type $1 (func))
1212

13+
;; CHECK: (export "return" (func $return))
14+
1315
;; CHECK: (export "drop" (func $drop))
1416

1517
;; CHECK: (export "passthrough" (func $passthrough))

0 commit comments

Comments
 (0)