summaryrefslogtreecommitdiff
path: root/test/passes/extract-function_pass-arg=extract@foo.wast
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-05-11 12:29:46 -0700
committerGitHub <noreply@github.com>2021-05-11 12:29:46 -0700
commited92a8d5e493c839687c2f2d56cdc5123e6e3a47 (patch)
treeb947cb02acae0097fe635be6f4069ba86d48ad58 /test/passes/extract-function_pass-arg=extract@foo.wast
parent09052c055c07ec5a1385cd5c142ff4d8534f1d1c (diff)
downloadbinaryen-ed92a8d5e493c839687c2f2d56cdc5123e6e3a47.tar.gz
binaryen-ed92a8d5e493c839687c2f2d56cdc5123e6e3a47.tar.bz2
binaryen-ed92a8d5e493c839687c2f2d56cdc5123e6e3a47.zip
ExtractFunction: Do not always remove the memory and table (#3877)
Instead, run RemoveUnusedModuleElements, which does that sort of thing. That is, this pass just "extracts" the function by turning all others into imports, and then they should almost all be removable via RemoveUnusedModuleElements, depending on whether they are used in the table or not, whether the extracted function calls them, etc. Without this, we would error if a function was in the table, and so this fixes #3876
Diffstat (limited to 'test/passes/extract-function_pass-arg=extract@foo.wast')
-rw-r--r--test/passes/extract-function_pass-arg=extract@foo.wast26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/passes/extract-function_pass-arg=extract@foo.wast b/test/passes/extract-function_pass-arg=extract@foo.wast
index 876910300..ab1d8b269 100644
--- a/test/passes/extract-function_pass-arg=extract@foo.wast
+++ b/test/passes/extract-function_pass-arg=extract@foo.wast
@@ -9,4 +9,28 @@
(drop (i32.const 1))
)
)
-
+(module
+ ;; Use another function in the table, but the table is not used in the
+ ;; extracted function
+ (table $t 10 funcref)
+ (elem $0 (table $t) (i32.const 0) func $other)
+ (func $foo
+ )
+ (func $other
+ (drop (i32.const 1))
+ )
+)
+(module
+ ;; Use another function in the table, and the table *is* used. As a result,
+ ;; the table and its elements will remain. The called function, $other, will
+ ;; remain as an import that is placed in the table.
+ (type $none (func))
+ (table $t 10 funcref)
+ (elem $0 (table $t) (i32.const 0) func $other)
+ (func $foo
+ (call_indirect (type $none) (i32.const 10))
+ )
+ (func $other
+ (drop (i32.const 1))
+ )
+)