summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/wasm-split/help.test14
-rw-r--r--test/lit/wasm-split/invalid-options.wast12
-rw-r--r--test/lit/wasm-split/merge-profiles.wast42
3 files changed, 62 insertions, 6 deletions
diff --git a/test/lit/wasm-split/help.test b/test/lit/wasm-split/help.test
index c473b28a1..de789a362 100644
--- a/test/lit/wasm-split/help.test
+++ b/test/lit/wasm-split/help.test
@@ -1,6 +1,6 @@
;; RUN: wasm-split --help | filecheck %s
-CHECK: wasm-split INFILE
+CHECK: wasm-split INFILES
CHECK-NEXT:
CHECK-NEXT: Split a module into a primary module and a secondary module, or instrument a
CHECK-NEXT: module to gather a profile that can inform future splitting, or manage such
@@ -16,6 +16,8 @@ CHECK-NEXT: modules. The default mode.
CHECK-NEXT: --instrument Instrument an input module to allow it to
CHECK-NEXT: generate a profile that can be used to
CHECK-NEXT: guide splitting.
+CHECK-NEXT: --merge-profiles Merge multiple profiles for the same
+CHECK-NEXT: module into a single profile.
CHECK-NEXT: --profile [split] The profile to use to guide
CHECK-NEXT: splitting.
CHECK-NEXT: --keep-funcs [split] Comma-separated list of functions
@@ -41,7 +43,6 @@ CHECK-NEXT: primary module.
CHECK-NEXT: --export-prefix [split] An identifying prefix to prepend
CHECK-NEXT: to new export names created by module
CHECK-NEXT: splitting.
-CHECK-NEXT: --output,-o [instrument] Output file.
CHECK-NEXT: --profile-export [instrument] The export name of the
CHECK-NEXT: function the embedder calls to write the
CHECK-NEXT: profile into memory. Defaults to
@@ -59,10 +60,11 @@ CHECK-NEXT: same table size when using Em
CHECK-NEXT: SPLIT_MODULE mode with dynamic linking.
CHECK-NEXT: TODO: Figure out a more elegant solution
CHECK-NEXT: for that use case and remove this.
+CHECK-NEXT: --emit-text,-S [split, instrument] Emit text instead of
+CHECK-NEXT: binary for the output file or files.
+CHECK-NEXT: --debuginfo,-g [split, instrument] Emit names section in
+CHECK-NEXT: wasm binary (or full debuginfo in wast)
+CHECK-NEXT: --output,-o [instrument, merge-profiles] Output file.
CHECK-NEXT: --verbose,-v Verbose output mode. Prints the functions
CHECK-NEXT: that will be kept and split out when
CHECK-NEXT: splitting a module.
-CHECK-NEXT: --emit-text,-S Emit text instead of binary for the
-CHECK-NEXT: output file or files.
-CHECK-NEXT: --debuginfo,-g Emit names section in wasm binary (or
-CHECK-NEXT: full debuginfo in wast)
diff --git a/test/lit/wasm-split/invalid-options.wast b/test/lit/wasm-split/invalid-options.wast
index 89a68e6aa..c77691ecc 100644
--- a/test/lit/wasm-split/invalid-options.wast
+++ b/test/lit/wasm-split/invalid-options.wast
@@ -45,6 +45,14 @@
;; RUN: not wasm-split %s --profile-export=foo 2>&1 \
;; RUN: | filecheck %s --check-prefix SPLIT-PROFILE-EXPORT
+;; -S cannot be used with --merge-profiles
+;; RUN: not wasm-split %s --merge-profiles -S 2>&1 \
+;; RUN: | filecheck %s --check-prefix MERGE-EMIT-TEXT
+
+;; -g cannot be used with --merge-profiles
+;; RUN: not wasm-split %s --merge-profiles -g 2>&1 \
+;; RUN: | filecheck %s --check-prefix MERGE-DEBUGINFO
+
;; INSTRUMENT-PROFILE: error: Option --profile cannot be used in instrument mode.
;; INSTRUMENT-OUT1: error: Option --primary-output cannot be used in instrument mode.
@@ -67,4 +75,8 @@
;; SPLIT-PROFILE-EXPORT: error: Option --profile-export cannot be used in split mode.
+;; MERGE-EMIT-TEXT: error: Option --emit-text cannot be used in merge-profiles mode.
+
+;; MERGE-DEBUGINFO: error: Option --debuginfo cannot be used in merge-profiles mode.
+
(module)
diff --git a/test/lit/wasm-split/merge-profiles.wast b/test/lit/wasm-split/merge-profiles.wast
new file mode 100644
index 000000000..fdaf6678e
--- /dev/null
+++ b/test/lit/wasm-split/merge-profiles.wast
@@ -0,0 +1,42 @@
+;; Instrument the module
+;; RUN: wasm-split --instrument %s -o %t.instrumented.wasm -g
+
+;; Generate profiles
+;; RUN: node %S/call_exports.mjs %t.instrumented.wasm %t.foo.prof foo
+;; RUN: node %S/call_exports.mjs %t.instrumented.wasm %t.foo.bar.prof foo bar
+;; RUN: node %S/call_exports.mjs %t.instrumented.wasm %t.bar.baz.prof bar baz
+
+;; Merge profiles
+;; RUN: wasm-split --merge-profiles -v %t.foo.prof %t.foo.bar.prof %t.bar.baz.prof -o %t.merged.prof 2>&1 \
+;; RUN: | filecheck %s --check-prefix MERGE
+
+;; Split the module
+;; RUN: wasm-split %s --profile %t.merged.prof -o1 %t.1.wasm -o2 %t.2.wasm -g -v \
+;; RUN: | filecheck %s --check-prefix SPLIT
+
+;; MERGE: Profile {{.*}}foo.prof only includes functions included in other profiles.
+;; MERGE: Profile {{.*}}foo.bar.prof only includes functions included in other profiles.
+;; MERGE-NOT: Profile {{.*}}bar.baz.prof only includes functions included in other profiles.
+
+;; SPLIT: Keeping functions: bar, baz, foo{{$}}
+;; SPLIT-NEXT: Splitting out functions: qux{{$}}
+
+(module
+ (export "memory" (memory 0 0))
+ (export "foo" (func $foo))
+ (export "bar" (func $bar))
+ (export "baz" (func $baz))
+ (export "qux" (func $qux))
+ (func $foo
+ (nop)
+ )
+ (func $bar
+ (nop)
+ )
+ (func $baz
+ (nop)
+ )
+ (func $qux
+ (nop)
+ )
+)