diff options
author | Alon Zakai <azakai@google.com> | 2023-04-07 08:12:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-07 08:12:10 -0700 |
commit | e5be9ac2e2f22545ae02db43e9f94dd7d3dbceef (patch) | |
tree | de8eed7efbfa3e0d4361dbb08f03c534b0676fb9 /src/ir/possible-contents.cpp | |
parent | 4f91c6a569614275d906a825d3f495541aa8802d (diff) | |
download | binaryen-e5be9ac2e2f22545ae02db43e9f94dd7d3dbceef.tar.gz binaryen-e5be9ac2e2f22545ae02db43e9f94dd7d3dbceef.tar.bz2 binaryen-e5be9ac2e2f22545ae02db43e9f94dd7d3dbceef.zip |
[Wasm GC] Fix GUFA on ArrayInit (#5638)
Diffstat (limited to 'src/ir/possible-contents.cpp')
-rw-r--r-- | src/ir/possible-contents.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index 8ed2118fe..b2a0b417a 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -618,6 +618,7 @@ struct InfoCollector addRoot(curr); } void visitTableGet(TableGet* curr) { + // TODO: be more precise addRoot(curr); } void visitTableSet(TableSet* curr) {} @@ -992,6 +993,7 @@ struct InfoCollector if (curr->type == Type::unreachable) { return; } + // See ArrayCopy, above. Builder builder(*getModule()); auto* set = builder.makeArraySet(curr->ref, curr->index, curr->value); visitArraySet(set); @@ -1000,9 +1002,18 @@ struct InfoCollector if (curr->type == Type::unreachable) { return; } - // TODO: Modeling the write to the array can be similar to the above, but - // how should the read from the segment be modeled? - WASM_UNREACHABLE("unimplemented"); + // See ArrayCopy, above. Here an additional complexity is that we need to + // model the read from the segment. As in TableGet, for now we just assume + // any value is possible there (a root in the graph), which we set up + // manually here as a fake unknown value, using a fake local.get that we + // root. + // TODO: be more precise about what is in the table + auto valueType = curr->ref->type.getHeapType().getArray().element.type; + Builder builder(*getModule()); + auto* get = builder.makeLocalGet(-1, valueType); + addRoot(get); + auto* set = builder.makeArraySet(curr->ref, curr->index, get); + visitArraySet(set); } void visitStringNew(StringNew* curr) { if (curr->type == Type::unreachable) { |