diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index 0dbeb57772a..b503b0a818a 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -1485,11 +1485,16 @@ void evalCtors(Module& wasm, } } } catch (FailToEvalException& fail) { - // that's it, we failed to even create the instance + // That's it, we failed to even create the instance. if (!quiet) { std::cout << " ...stopping since could not create module instance: " << fail.why << "\n"; } + } catch (NonconstantException& fail) { + // We can also fail during start due to a non-constant operation. + if (!quiet) { + std::cout << " ...stopping since non-constant in start\n"; + } } catch (TopologicalSort::CycleException e) { // We use a topological sort for GC globals. If there is a non-breakable // cycle there, we will hit an error (we can break cycles in nullable and diff --git a/test/lit/ctor-eval/start-nonconstant.wast b/test/lit/ctor-eval/start-nonconstant.wast new file mode 100644 index 00000000000..4d6baa668ab --- /dev/null +++ b/test/lit/ctor-eval/start-nonconstant.wast @@ -0,0 +1,38 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; RUN: foreach %s %t wasm-ctor-eval --ctors=test --kept-exports=test --quiet -all -S -o - | filecheck %s + +;; A non-constant (relaxed SIMD) operation in the start function. We should not +;; error. +(module + ;; CHECK: (type $0 (func (param v128))) + + ;; CHECK: (type $1 (func)) + + ;; CHECK: (import "a" "b" (func $import (type $0) (param v128))) + (import "a" "b" (func $import (param v128))) + + ;; CHECK: (export "test" (func $0)) + (export "test" (func $0)) + + ;; CHECK: (start $0) + (start $0) + + ;; CHECK: (func $0 (type $1) + ;; CHECK-NEXT: (call $import + ;; CHECK-NEXT: (f32x4.relaxed_min + ;; CHECK-NEXT: (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) + ;; CHECK-NEXT: (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $0 + ;; The import avoids vacuum from removing the entire body. + (call $import + (f32x4.relaxed_min + (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) + (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) + ) + ) + ) +) +