summaryrefslogtreecommitdiff
path: root/test/lit/wasm-split
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-06-11 14:14:54 -0700
committerGitHub <noreply@github.com>2024-06-11 14:14:54 -0700
commit425ecc65dea1a26c5b3667a46926a9834834b5cc (patch)
tree21b3e6db639aff4fb732e976d48ac11741b34451 /test/lit/wasm-split
parent2dcf67049ef4d2cbcb2a65d367be97ae675f9d8a (diff)
downloadbinaryen-425ecc65dea1a26c5b3667a46926a9834834b5cc.tar.gz
binaryen-425ecc65dea1a26c5b3667a46926a9834834b5cc.tar.bz2
binaryen-425ecc65dea1a26c5b3667a46926a9834834b5cc.zip
Fix wasm-split bug in absence of active element segments (#6651)
The module splitting code incorrectly assumed that there would be at least one active element segment and failed to initialize the table slot manager with a function table if that was not the case. Fix the bug by setting the table even when there are no active segments and add a test. Fixes #6572 and #6637.
Diffstat (limited to 'test/lit/wasm-split')
-rw-r--r--test/lit/wasm-split/no-active-segment.wast41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/lit/wasm-split/no-active-segment.wast b/test/lit/wasm-split/no-active-segment.wast
new file mode 100644
index 000000000..ad83b0480
--- /dev/null
+++ b/test/lit/wasm-split/no-active-segment.wast
@@ -0,0 +1,41 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+
+;; Test that splitting succeeds even if there are no active segments for the function table.
+
+;; RUN: wasm-split %s --split-funcs=foo -g -o1 %t.1.wasm -o2 %t.2.wasm
+;; RUN: wasm-dis %t.1.wasm | filecheck %s --check-prefix PRIMARY
+;; RUN: wasm-dis %t.2.wasm | filecheck %s --check-prefix SECONDARY
+
+(module
+ (table 0 funcref)
+ (export "foo" (func $foo))
+ ;; SECONDARY: (type $0 (func))
+
+ ;; SECONDARY: (import "primary" "table" (table $timport$0 1 funcref))
+
+ ;; SECONDARY: (elem $0 (i32.const 0) $foo)
+
+ ;; SECONDARY: (func $foo
+ ;; SECONDARY-NEXT: (nop)
+ ;; SECONDARY-NEXT: )
+ (func $foo
+ (nop)
+ )
+)
+;; PRIMARY: (type $0 (func))
+
+;; PRIMARY: (import "placeholder" "0" (func $placeholder_0))
+
+;; PRIMARY: (table $0 1 funcref)
+
+;; PRIMARY: (elem $0 (i32.const 0) $placeholder_0)
+
+;; PRIMARY: (export "foo" (func $0))
+
+;; PRIMARY: (export "table" (table $0))
+
+;; PRIMARY: (func $0
+;; PRIMARY-NEXT: (call_indirect (type $0)
+;; PRIMARY-NEXT: (i32.const 0)
+;; PRIMARY-NEXT: )
+;; PRIMARY-NEXT: )