diff options
author | Alon Zakai <azakai@google.com> | 2020-10-29 19:06:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-29 19:06:28 -0700 |
commit | 25e47f2c3e7ca8151377075432b34c95073acaca (patch) | |
tree | b806914422484795822dd9235dc22de89bb52796 | |
parent | eb81ca4f81a27eb2fa775b8246f24f3bc3ea4f4b (diff) | |
download | binaryen-25e47f2c3e7ca8151377075432b34c95073acaca.tar.gz binaryen-25e47f2c3e7ca8151377075432b34c95073acaca.tar.bz2 binaryen-25e47f2c3e7ca8151377075432b34c95073acaca.zip |
Inlining fix: Note the start function (#3301)
Without this, we might think a function has no global uses if the only
global use of it is the start.
-rw-r--r-- | src/passes/Inlining.cpp | 3 | ||||
-rw-r--r-- | test/passes/inlining_all-features.txt | 12 | ||||
-rw-r--r-- | test/passes/inlining_all-features.wast | 11 |
3 files changed, 26 insertions, 0 deletions
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp index 43addff8b..5c94755d1 100644 --- a/src/passes/Inlining.cpp +++ b/src/passes/Inlining.cpp @@ -343,6 +343,9 @@ struct Inlining : public Pass { } } } + if (module->start.is()) { + infos[module->start].usedGlobally = true; + } } bool iteration(PassRunner* runner, Module* module) { diff --git a/test/passes/inlining_all-features.txt b/test/passes/inlining_all-features.txt index 2141d3d34..e909239d2 100644 --- a/test/passes/inlining_all-features.txt +++ b/test/passes/inlining_all-features.txt @@ -59,3 +59,15 @@ ) ) ) +(module + (type $none_=>_none (func)) + (start $0) + (func $0 + (nop) + ) + (func $1 + (block $__inlined_func$0 + (nop) + ) + ) +) diff --git a/test/passes/inlining_all-features.wast b/test/passes/inlining_all-features.wast index f86ad8926..60093cb63 100644 --- a/test/passes/inlining_all-features.wast +++ b/test/passes/inlining_all-features.wast @@ -47,3 +47,14 @@ (call $0) ) ) +(module + ;; a function reference in the start should be noticed, and prevent us + ;; from removing an inlined function + (start $0) + (func $0 + (nop) + ) + (func $1 + (call $0) + ) +) |