diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index e0950b58c9c..9a834e7647d 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -2370,6 +2370,7 @@ def write_commands(commands, filename): ("--remove-unused-types",), ("--abstract-type-refining",), ("--cfp",), + ("--cfp-reftest",), ("--gsi",), ("--type-ssa",), ("--type-merging",)} diff --git a/src/passes/ConstantFieldPropagation.cpp b/src/passes/ConstantFieldPropagation.cpp index 26b3241d6fd..e2b75e88de8 100644 --- a/src/passes/ConstantFieldPropagation.cpp +++ b/src/passes/ConstantFieldPropagation.cpp @@ -549,6 +549,10 @@ struct ConstantFieldPropagation : public Pass { return; } + if (!getPassOptions().closedWorld) { + Fatal() << "CFP requires --closed-world"; + } + // Find and analyze all writes inside each function. PCVFunctionStructValuesMap functionNewInfos(*module), functionSetInfos(*module); diff --git a/test/lit/passes/cfp-desc.wast b/test/lit/passes/cfp-desc.wast index aeda747547a..6a2587d3709 100644 --- a/test/lit/passes/cfp-desc.wast +++ b/test/lit/passes/cfp-desc.wast @@ -1,6 +1,6 @@ ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. -;; RUN: foreach %s %t wasm-opt --cfp -all -S -o - | filecheck %s +;; RUN: foreach %s %t wasm-opt --cfp --closed-world -all -S -o - | filecheck %s (module (rec diff --git a/test/lit/passes/cfp-reftest-desc.wast b/test/lit/passes/cfp-reftest-desc.wast index 7064276f2b4..d53cc428759 100644 --- a/test/lit/passes/cfp-reftest-desc.wast +++ b/test/lit/passes/cfp-reftest-desc.wast @@ -1,6 +1,6 @@ ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. -;; RUN: foreach %s %t wasm-opt --cfp-reftest -all -S -o - | filecheck %s +;; RUN: foreach %s %t wasm-opt --cfp-reftest --closed-world -all -S -o - | filecheck %s ;; When a ref.get_desc can only read from two types, and those types have a ;; constant field, we can select between those two values using a ref.test. diff --git a/test/lit/passes/cfp-reftest.wast b/test/lit/passes/cfp-reftest.wast index 404f3147234..48cda2bc226 100644 --- a/test/lit/passes/cfp-reftest.wast +++ b/test/lit/passes/cfp-reftest.wast @@ -1,6 +1,6 @@ ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. -;; RUN: foreach %s %t wasm-opt --cfp-reftest -all -S -o - | filecheck %s +;; RUN: foreach %s %t wasm-opt --cfp-reftest --closed-world -all -S -o - | filecheck %s ;; When a struct.get can only read from two types, and those types have a ;; constant field, we can select between those two values using a ref.test. diff --git a/test/lit/passes/cfp-rmw.wast b/test/lit/passes/cfp-rmw.wast index 02266796a48..57af1e6bc73 100644 --- a/test/lit/passes/cfp-rmw.wast +++ b/test/lit/passes/cfp-rmw.wast @@ -1,6 +1,6 @@ ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. -;; RUN: foreach %s %t wasm-opt --cfp -all -S -o - | filecheck %s +;; RUN: foreach %s %t wasm-opt --cfp --closed-world -all -S -o - | filecheck %s ;; RMW ops are generally writes that inhibit optimization. (module diff --git a/test/lit/passes/cfp.wast b/test/lit/passes/cfp.wast index de34fb7f4c2..81946889b05 100644 --- a/test/lit/passes/cfp.wast +++ b/test/lit/passes/cfp.wast @@ -1,6 +1,6 @@ ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. -;; RUN: foreach %s %t wasm-opt --remove-unused-names --cfp -all -S -o - | filecheck %s +;; RUN: foreach %s %t wasm-opt --remove-unused-names --cfp --closed-world -all -S -o - | filecheck %s ;; (remove-unused-names is added to test fallthrough values without a block ;; name getting in the way)