Skip to content

Commit 2369824

Browse files
authored
[GC] Use cfp-reftest pass (#7905)
This pass has been used by j2wasm for a while, and is useful there, so enable it for general use. This pass can grow code size in some cases, if it emits a ref.test that is not later optimized out. For that reason only enable it in -O3+, that is, when optimizing aggressively for size. Also fuzz this pass more.
1 parent cf756c9 commit 2369824

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

scripts/fuzz_opt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,7 @@ def write_commands(commands, filename):
22282228
('-O1',), ('-O2',), ('-O3',), ('-O4',), ('-Os',), ('-Oz',),
22292229
("--abstract-type-refining",),
22302230
("--cfp",),
2231+
("--cfp-reftest",),
22312232
("--coalesce-locals",),
22322233
# XXX slow, non-default ("--coalesce-locals-learning",),
22332234
("--code-pushing",),

src/passes/pass.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,12 @@ void PassRunner::addDefaultGlobalOptimizationPrePasses() {
763763
addIfNoDWARFIssues("remove-unused-module-elements");
764764
if (options.closedWorld) {
765765
addIfNoDWARFIssues("remove-unused-types");
766-
addIfNoDWARFIssues("cfp");
766+
// Allow ref.tests in cfp if we are aggressively optimizing for speed.
767+
if (options.optimizeLevel >= 3) {
768+
addIfNoDWARFIssues("cfp-reftest");
769+
} else {
770+
addIfNoDWARFIssues("cfp");
771+
}
767772
addIfNoDWARFIssues("gsi");
768773
addIfNoDWARFIssues("abstract-type-refining");
769774
addIfNoDWARFIssues("unsubtyping");

0 commit comments

Comments
 (0)