summaryrefslogtreecommitdiff
path: root/src/passes/Monomorphize.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-11-17 15:00:28 -0800
committerGitHub <noreply@github.com>2022-11-17 23:00:28 +0000
commit977d653f9801b3eedc7dd667e4068573e73d2bb5 (patch)
tree8876e96e5f31d32b6a656a627b02e635db1314af /src/passes/Monomorphize.cpp
parent5f5c70255cfa917efee9855ce1f8340b017e0adb (diff)
downloadbinaryen-977d653f9801b3eedc7dd667e4068573e73d2bb5.tar.gz
binaryen-977d653f9801b3eedc7dd667e4068573e73d2bb5.tar.bz2
binaryen-977d653f9801b3eedc7dd667e4068573e73d2bb5.zip
[Wasm GC] Start an OptimizeCasts pass and reuse cast values there (#5263)
(some.operation (ref.cast .. (local.get $ref)) (local.get $ref) ) => (some.operation (local.tee $temp (ref.cast .. (local.get $ref)) ) (local.get $temp) ) This can help cases where we cast for some reason but happen to not use the cast value in all places. This occurs in j2wasm in itable calls sometimes: The this pointer is is refined, but the itable may be done with an unrefined pointer, which is less optimizable. So far this is just inside basic blocks, but that is enough for the cast of itable calls and other common patterns I see.
Diffstat (limited to 'src/passes/Monomorphize.cpp')
-rw-r--r--src/passes/Monomorphize.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/passes/Monomorphize.cpp b/src/passes/Monomorphize.cpp
index 80e908a83..f8ee4a6e6 100644
--- a/src/passes/Monomorphize.cpp
+++ b/src/passes/Monomorphize.cpp
@@ -214,6 +214,9 @@ struct Monomorphize : public Pass {
// expect to help. That would be faster, but we'd always run the risk of
// missing things, especially as new passes are added later and we don't
// think to add them here.
+ // Alternatively, perhaps we should have a mode that does use -O1 or
+ // even -O2 or above, as in theory any optimization could end up
+ // mattering a lot here.
void doMinimalOpts(Function* func) {
PassRunner runner(getPassRunner());
runner.options.optimizeLevel = 1;