Skip to content

Disallow --nominal with GC #4758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2022
Merged

Disallow --nominal with GC #4758

merged 2 commits into from
Jun 29, 2022

Conversation

tlively
Copy link
Member

@tlively tlively commented Jun 29, 2022

Nominal types don't make much sense without GC, and in particular trying to emit
them with typed function references but not GC enabled can result in invalid
binaries because nominal types do not respect the type ordering constraints
required by the typed function references proposal. Making this change was
mostly straightforward, but required fixing the fuzzer to use --nominal only
when GC is enabled and required exiting early from nominal-only optimizations
when GC was not enabled.

Fixes #4756.

Nominal types don't make much sense without GC, and in particular trying to emit
them with typed function references but not GC enabled can result in invalid
binaries because nominal types do not respect the type ordering constraints
required by the typed function references proposal. Making this change was
mostly straightforward, but required fixing the fuzzer to use --nominal only
when GC is enabled and required exiting early from nominal-only optimizations
when GC was not enabled.

Fixes #4756.
@tlively tlively requested a review from kripken June 29, 2022 00:31
@tlively
Copy link
Member Author

tlively commented Jun 29, 2022

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with those comments addressed

@@ -120,6 +119,9 @@ def randomize_feature_opts():
if possible in IMPLIED_FEATURE_OPTS:
FEATURE_OPTS.extend(IMPLIED_FEATURE_OPTS[possible])
print('randomized feature opts:', '\n ' + '\n '.join(FEATURE_OPTS))
# Type system flags only make sense when GC is enabled
if "--disable-gc" not in FEATURE_OPTS:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if "--disable-gc" not in FEATURE_OPTS:
if '--disable-gc' not in FEATURE_OPTS:

@@ -176,6 +176,9 @@ struct PCVScanner

struct ConstantFieldPropagation : public Pass {
void run(PassRunner* runner, Module* module) override {
if (!module->features.hasGC()) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is needed now because the fuzzer may call this pass without --nominal, and we want to avoid the Fatal below? It is odd though to silently return on not having GC but error on nominal. How about making the fuzzer not run these passes? We could move the relevant passes from opt_choices to gc_opt_choices and only pick from the latter when gc (+ nominal) is enabled?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that would be another good solution. I slightly prefer keeping these early returns because they seem like what we will want to do in the long term; if running GC optimization passes on non-GC modules gracefully does nothing, then we can run GC optimization passes by default without a problem. I hope that the fatal errors on nonsupported type systems are more temporary and that we eventually update the passes to do what they can with whatever type systems we choose to permanently maintain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess both are reasonable. I'd prefer to not run GC passes by default, though, as they add clutter - for example in debug mode they'd get printed out in the list. Seems nicer to only print out the relevant passes, which we do now. Maybe we can add a mechanism to avoid that, though, like a hook "canRun" that would avoid even adding the pass - that would avoid needing to skip the pass both in pass.cpp and in the fuzzer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyhow, this lgtm + filing an issue to figure out a better solution later.

@tlively tlively merged commit 9dbe457 into main Jun 29, 2022
@tlively tlively deleted the disallow-no-gc-nominal branch June 29, 2022 04:11
kripken added a commit that referenced this pull request Jul 7, 2022
#4758 regressed the determinism fuzzer. First, FEATURE_OPTS is not a
list but a string. Second, as a hack another location would add --strip-dwarf
to that list, but that only works in wasm-opt. To fix that, remove the hack
and instead just ignore DWARF-containing files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fuzz bug on type emitting
2 participants