diff options
author | Alon Zakai <azakai@google.com> | 2023-10-19 09:11:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-19 16:11:36 +0000 |
commit | be6a3393c36ccc1a0cb0d79b116cbe48e169f93b (patch) | |
tree | 8240468a78e62b6d18d747c865557d69f01b4b9f /test/passes | |
parent | f79b5aa26b1fc722853e56b541cd35128786ef6b (diff) | |
download | binaryen-be6a3393c36ccc1a0cb0d79b116cbe48e169f93b.tar.gz binaryen-be6a3393c36ccc1a0cb0d79b116cbe48e169f93b.tar.bz2 binaryen-be6a3393c36ccc1a0cb0d79b116cbe48e169f93b.zip |
RemoveUnusedModuleElements: Make exports skip trampolines (#6026)
If we export a function that just calls another function, we can export that one
instead. Then the one in the middle may be unused,
function foo() {
return bar();
}
export foo; // can be an export of bar
This saves a few bytes in rare cases, but probably more important is that it saves
the trampoline, so if this is on a hot path, we save a call.
Context: emscripten-core/emscripten#20478 (comment)
In general this is not needed as inlining helps us out by inlining foo() into the
caller (since foo is tiny, that always ends up happening). But exports are a case
the inliner cannot handle, so we do it here.
Diffstat (limited to 'test/passes')
-rw-r--r-- | test/passes/remove-unused-nonfunction-module-elements_all-features.txt | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/passes/remove-unused-nonfunction-module-elements_all-features.txt b/test/passes/remove-unused-nonfunction-module-elements_all-features.txt index d19fcc514..186bdd69b 100644 --- a/test/passes/remove-unused-nonfunction-module-elements_all-features.txt +++ b/test/passes/remove-unused-nonfunction-module-elements_all-features.txt @@ -6,7 +6,7 @@ (table $0 1 1 funcref) (elem $0 (i32.const 0) $called_indirect) (export "memory" (memory $0)) - (export "exported" (func $exported)) + (export "exported" (func $called2)) (export "other1" (func $other1)) (export "other2" (func $other2)) (start $start) @@ -240,8 +240,8 @@ (global $int (mut i32) (global.get $imported)) (global $set (mut i32) (i32.const 100)) (global $exp_glob i32 (i32.const 600)) - (export "one" (func $one)) - (export "three" (func $three)) + (export "one" (func $two)) + (export "three" (func $four)) (export "exp_glob" (global $exp_glob)) (func $one (type $1) (result i32) (call $two) |