summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-06-11 21:12:48 -0400
committerGitHub <noreply@github.com>2021-06-12 01:12:48 +0000
commitaec8d12282b5279b80e79f21d54491db5d55278e (patch)
tree4f0325893fda3aa98ab970757e9d3cd2288f6603 /test
parent446634a503116186a025d23375c430cb837e00f0 (diff)
downloadbinaryen-aec8d12282b5279b80e79f21d54491db5d55278e.tar.gz
binaryen-aec8d12282b5279b80e79f21d54491db5d55278e.tar.bz2
binaryen-aec8d12282b5279b80e79f21d54491db5d55278e.zip
[wasm-split] Add an option to emit a placeholder map (#3931)
The new instruction emits a file containing a map between placeholder index and the name of the split out function that placeholder is replacing in the table. This map is intended to be useful for debugging, as discussed in https://github.com/emscripten-core/emscripten/issues/14330.
Diffstat (limited to 'test')
-rw-r--r--test/example/module-splitting.cpp4
-rw-r--r--test/lit/wasm-split/help.test2
-rw-r--r--test/lit/wasm-split/placeholdermap.wast24
3 files changed, 28 insertions, 2 deletions
diff --git a/test/example/module-splitting.cpp b/test/example/module-splitting.cpp
index 2aa67d6d5..9ff2818be 100644
--- a/test/example/module-splitting.cpp
+++ b/test/example/module-splitting.cpp
@@ -50,7 +50,7 @@ void do_test(const std::set<Name>& keptFuncs, std::string&& module) {
ModuleSplitting::Config config;
config.primaryFuncs = keptFuncs;
config.newExportPrefix = "%";
- auto secondary = splitFunctions(*primary, config);
+ auto secondary = splitFunctions(*primary, config).secondary;
std::cout << "After:\n";
std::cout << *primary.get();
@@ -476,7 +476,7 @@ void test_minimized_exports() {
config.newExportPrefix = "%";
config.minimizeNewExportNames = true;
- auto secondary = splitFunctions(primary, config);
+ auto secondary = splitFunctions(primary, config).secondary;
std::cout << "Minimized names primary:\n";
std::cout << primary << "\n";
std::cout << "Minimized names secondary:\n";
diff --git a/test/lit/wasm-split/help.test b/test/lit/wasm-split/help.test
index de789a362..8159e66db 100644
--- a/test/lit/wasm-split/help.test
+++ b/test/lit/wasm-split/help.test
@@ -34,6 +34,8 @@ CHECK-NEXT: --secondary-output,-o2 [split] Output file for the s
CHECK-NEXT: module.
CHECK-NEXT: --symbolmap [split] Write a symbol map file for each
CHECK-NEXT: of the output modules.
+CHECK-NEXT: --placeholdermap [split] Write a file mapping placeholder
+CHECK-NEXT: indices to the function names.
CHECK-NEXT: --import-namespace [split] The namespace from which to
CHECK-NEXT: import objects from the primary module
CHECK-NEXT: into the secondary module.
diff --git a/test/lit/wasm-split/placeholdermap.wast b/test/lit/wasm-split/placeholdermap.wast
new file mode 100644
index 000000000..dd8598b0b
--- /dev/null
+++ b/test/lit/wasm-split/placeholdermap.wast
@@ -0,0 +1,24 @@
+;; RUN: wasm-split %s --keep-funcs=bar -o1 %t.1.wasm -o2 %t.2.wasm --placeholdermap
+;; RUN: filecheck %s --check-prefix MAP < %t.1.wasm.placeholders
+;; RUN: wasm-dis %t.1.wasm | filecheck %s --check-prefix PRIMARY
+
+;; MAP: 0:foo
+;; MAP-NEXT: 2:baz
+;; MAP-NOT: bar
+
+;; Check that the names have been stripped.
+;; PRIMARY: (func $0
+
+(module
+ (table $table 3 3 funcref)
+ (elem $table (i32.const 0) $foo $bar $baz)
+ (func $foo
+ (nop)
+ )
+ (func $bar
+ (nop)
+ )
+ (func $baz
+ (nop)
+ )
+)