diff options
author | Alon Zakai <azakai@google.com> | 2023-02-01 10:01:08 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-01 10:01:08 -0800 |
commit | 71b4ba4711189a26b699061e5b2af665ccc93114 (patch) | |
tree | 7fb045fe4b3889c08e4ac3153b4a4d384099f751 /scripts/clang-format-diff.sh | |
parent | a6f4b00141c994c744c6cb148d3ae60f271977f6 (diff) | |
download | binaryen-71b4ba4711189a26b699061e5b2af665ccc93114.tar.gz binaryen-71b4ba4711189a26b699061e5b2af665ccc93114.tar.bz2 binaryen-71b4ba4711189a26b699061e5b2af665ccc93114.zip |
RemoveUnusedModuleElements: Optimize unread struct.new fields (#5445)
This is similar to the existing optimization for function references: a RefFunc is
just a reference, and we do not consider the function actually used unless some
CallRef can actually call it. Here we optimize StructNew fields by tracking if they
are read. Consider this object:
(struct.new $object
(global.get $vtable)
)
Before this PR, when we saw that StructNew we'd make that global used, and
process all of its contents, which look like this:
(global $vtable
(struct.new $object
(ref.func $foo)
)
)
With this PR we track which fields on the struct types are even read. If they
are not then we do not add uses of the things they refer to. In this example,
the global vtable would be referenced, but not used, and likewise the RefFunc
inside it.
The technical way we handle this is to walk StructNews carefully: when we see
a field that has been read, we can just read it normally, but if it has not been
read then we note it on the side, and only process it later if we see a read.
Diffstat (limited to 'scripts/clang-format-diff.sh')
0 files changed, 0 insertions, 0 deletions