summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tools/wasm-opt.cpp5
-rw-r--r--test/merge/dylib.wasmbin364 -> 386 bytes
-rw-r--r--test/merge/dylib.wasm.combined70
-rw-r--r--test/merge/dylib.wasm.combined.finalized70
-rw-r--r--test/merge/dylib.wasm.combined.finalized.opt54
-rw-r--r--test/merge/dylib.wasm.combined.opt62
-rw-r--r--test/merge/dylib.wasm.toMergebin318 -> 340 bytes
7 files changed, 153 insertions, 108 deletions
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp
index 93d8f5baa..a663b1a04 100644
--- a/src/tools/wasm-opt.cpp
+++ b/src/tools/wasm-opt.cpp
@@ -41,6 +41,7 @@ int main(int argc, const char* argv[]) {
bool runOptimizationPasses = false;
PassOptions passOptions;
bool emitBinary = true;
+ bool debugInfo = false;
Options options("wasm-opt", "Optimize .wast files");
options
@@ -54,6 +55,9 @@ int main(int argc, const char* argv[]) {
.add("--emit-text", "-S", "Emit text instead of binary for the output file",
Options::Arguments::Zero,
[&](Options *o, const std::string &argument) { emitBinary = false; })
+ .add("--debuginfo", "-g", "Emit names section and debug info",
+ Options::Arguments::Zero,
+ [&](Options *o, const std::string &arguments) { debugInfo = true; })
.add_positional("INFILE", Options::Arguments::One,
[](Options* o, const std::string& argument) {
o->extra["infile"] = argument;
@@ -113,6 +117,7 @@ int main(int argc, const char* argv[]) {
ModuleWriter writer;
writer.setDebug(options.debug);
writer.setBinary(emitBinary);
+ writer.setDebugInfo(debugInfo);
writer.write(wasm, options.extra["output"]);
}
}
diff --git a/test/merge/dylib.wasm b/test/merge/dylib.wasm
index 4d86a9483..8df894a74 100644
--- a/test/merge/dylib.wasm
+++ b/test/merge/dylib.wasm
Binary files differ
diff --git a/test/merge/dylib.wasm.combined b/test/merge/dylib.wasm.combined
index 0133476a9..92712abcf 100644
--- a/test/merge/dylib.wasm.combined
+++ b/test/merge/dylib.wasm.combined
@@ -27,64 +27,76 @@
(export "_foo" (func $_foo))
(func $_main (type $2) (result i32)
(block $label$0 i32
- (drop
- (call $import$1
- (get_global $import$0)
+ (block $label$1 i32
+ (drop
+ (call $import$1
+ (get_global $import$0)
+ )
)
+ (i32.const 0)
)
- (i32.const 0)
)
)
(func $runPostSets (type $3)
- (nop)
+ (block $label$0
+ (nop)
+ )
)
(func $__post_instantiate (type $3)
(call $__post_instantiate$0)
(block
(block $label$0
- (set_global $global$0
- (i32.add
- (get_global $import$0)
- (i32.const 16)
+ (block $label$1
+ (set_global $global$0
+ (i32.add
+ (get_global $import$0)
+ (i32.const 16)
+ )
)
- )
- (set_global $global$1
- (i32.add
- (get_global $global$0)
- (i32.const 32)
+ (set_global $global$1
+ (i32.add
+ (get_global $global$0)
+ (i32.const 32)
+ )
)
+ (call $runPostSets)
)
- (call $runPostSets)
)
)
)
(func $_foo (type $1$0) (result i32)
(local $var$0 i32)
(block $label$0 i32
- (set_local $var$0
- (call $_main)
+ (block $label$1 i32
+ (set_local $var$0
+ (call $_main)
+ )
+ (get_local $var$0)
)
- (get_local $var$0)
)
)
(func $runPostSets$0 (type $2$0)
- (nop)
+ (block $label$0
+ (nop)
+ )
)
(func $__post_instantiate$0 (type $2$0)
(block $label$0
- (set_global $global$0$0
- (i32.add
- (get_global $import$0$0)
- (i32.const 48)
+ (block $label$1
+ (set_global $global$0$0
+ (i32.add
+ (get_global $import$0$0)
+ (i32.const 48)
+ )
)
- )
- (set_global $global$1$0
- (i32.add
- (get_global $global$0$0)
- (i32.const 10)
+ (set_global $global$1$0
+ (i32.add
+ (get_global $global$0$0)
+ (i32.const 10)
+ )
)
+ (call $runPostSets$0)
)
- (call $runPostSets$0)
)
)
;; custom section "dylink", size 2
diff --git a/test/merge/dylib.wasm.combined.finalized b/test/merge/dylib.wasm.combined.finalized
index c3f64a0b5..53f458e7b 100644
--- a/test/merge/dylib.wasm.combined.finalized
+++ b/test/merge/dylib.wasm.combined.finalized
@@ -27,64 +27,76 @@
(export "_foo" (func $_foo))
(func $_main (type $2) (result i32)
(block $label$0 i32
- (drop
- (call $import$1
- (i32.const 1024)
+ (block $label$1 i32
+ (drop
+ (call $import$1
+ (i32.const 1024)
+ )
)
+ (i32.const 0)
)
- (i32.const 0)
)
)
(func $runPostSets (type $3)
- (nop)
+ (block $label$0
+ (nop)
+ )
)
(func $__post_instantiate (type $3)
(call $__post_instantiate$0)
(block
(block $label$0
- (set_global $global$0
- (i32.add
- (i32.const 1024)
- (i32.const 16)
+ (block $label$1
+ (set_global $global$0
+ (i32.add
+ (i32.const 1024)
+ (i32.const 16)
+ )
)
- )
- (set_global $global$1
- (i32.add
- (get_global $global$0)
- (i32.const 32)
+ (set_global $global$1
+ (i32.add
+ (get_global $global$0)
+ (i32.const 32)
+ )
)
+ (call $runPostSets)
)
- (call $runPostSets)
)
)
)
(func $_foo (type $1$0) (result i32)
(local $var$0 i32)
(block $label$0 i32
- (set_local $var$0
- (call $_main)
+ (block $label$1 i32
+ (set_local $var$0
+ (call $_main)
+ )
+ (get_local $var$0)
)
- (get_local $var$0)
)
)
(func $runPostSets$0 (type $2$0)
- (nop)
+ (block $label$0
+ (nop)
+ )
)
(func $__post_instantiate$0 (type $2$0)
(block $label$0
- (set_global $global$0$0
- (i32.add
- (i32.const 1024)
- (i32.const 48)
+ (block $label$1
+ (set_global $global$0$0
+ (i32.add
+ (i32.const 1024)
+ (i32.const 48)
+ )
)
- )
- (set_global $global$1$0
- (i32.add
- (get_global $global$0$0)
- (i32.const 10)
+ (set_global $global$1$0
+ (i32.add
+ (get_global $global$0$0)
+ (i32.const 10)
+ )
)
+ (call $runPostSets$0)
)
- (call $runPostSets$0)
)
)
;; custom section "dylink", size 2
diff --git a/test/merge/dylib.wasm.combined.finalized.opt b/test/merge/dylib.wasm.combined.finalized.opt
index 2d40fb83c..eda229e34 100644
--- a/test/merge/dylib.wasm.combined.finalized.opt
+++ b/test/merge/dylib.wasm.combined.finalized.opt
@@ -23,12 +23,14 @@
(export "_foo" (func $_foo))
(func $_main (type $2) (result i32)
(block $label$0 i32
- (drop
- (call $import$1
- (i32.const 1024)
+ (block $label$1 i32
+ (drop
+ (call $import$1
+ (i32.const 1024)
+ )
)
+ (i32.const 0)
)
- (i32.const 0)
)
)
(func $runPostSets (type $3)
@@ -38,26 +40,30 @@
(call $__post_instantiate$0)
(block
(block $label$0
- (set_global $global$0
- (i32.const 1040)
- )
- (set_global $global$1
- (i32.add
- (get_global $global$0)
- (i32.const 32)
+ (block $label$1
+ (set_global $global$0
+ (i32.const 1040)
)
+ (set_global $global$1
+ (i32.add
+ (get_global $global$0)
+ (i32.const 32)
+ )
+ )
+ (call $runPostSets)
)
- (call $runPostSets)
)
)
)
(func $_foo (type $1$0) (result i32)
(local $var$0 i32)
(block $label$0 i32
- (set_local $var$0
- (call $_main)
+ (block $label$1 i32
+ (set_local $var$0
+ (call $_main)
+ )
+ (get_local $var$0)
)
- (get_local $var$0)
)
)
(func $runPostSets$0 (type $2$0)
@@ -65,16 +71,18 @@
)
(func $__post_instantiate$0 (type $2$0)
(block $label$0
- (set_global $global$0$0
- (i32.const 1072)
- )
- (set_global $global$1$0
- (i32.add
- (get_global $global$0$0)
- (i32.const 10)
+ (block $label$1
+ (set_global $global$0$0
+ (i32.const 1072)
+ )
+ (set_global $global$1$0
+ (i32.add
+ (get_global $global$0$0)
+ (i32.const 10)
+ )
)
+ (call $runPostSets$0)
)
- (call $runPostSets$0)
)
)
;; custom section "dylink", size 2
diff --git a/test/merge/dylib.wasm.combined.opt b/test/merge/dylib.wasm.combined.opt
index 8c354e34d..404281cda 100644
--- a/test/merge/dylib.wasm.combined.opt
+++ b/test/merge/dylib.wasm.combined.opt
@@ -26,12 +26,14 @@
(export "_foo" (func $_foo))
(func $_main (type $2) (result i32)
(block $label$0 i32
- (drop
- (call $import$1
- (get_global $import$0)
+ (block $label$1 i32
+ (drop
+ (call $import$1
+ (get_global $import$0)
+ )
)
+ (i32.const 0)
)
- (i32.const 0)
)
)
(func $runPostSets (type $3)
@@ -41,29 +43,33 @@
(call $__post_instantiate$0)
(block
(block $label$0
- (set_global $global$0
- (i32.add
- (get_global $import$0)
- (i32.const 16)
+ (block $label$1
+ (set_global $global$0
+ (i32.add
+ (get_global $import$0)
+ (i32.const 16)
+ )
)
- )
- (set_global $global$1
- (i32.add
- (get_global $global$0)
- (i32.const 32)
+ (set_global $global$1
+ (i32.add
+ (get_global $global$0)
+ (i32.const 32)
+ )
)
+ (call $runPostSets)
)
- (call $runPostSets)
)
)
)
(func $_foo (type $1$0) (result i32)
(local $var$0 i32)
(block $label$0 i32
- (set_local $var$0
- (call $_main)
+ (block $label$1 i32
+ (set_local $var$0
+ (call $_main)
+ )
+ (get_local $var$0)
)
- (get_local $var$0)
)
)
(func $runPostSets$0 (type $2$0)
@@ -71,19 +77,21 @@
)
(func $__post_instantiate$0 (type $2$0)
(block $label$0
- (set_global $global$0$0
- (i32.add
- (get_global $import$0$0)
- (i32.const 48)
+ (block $label$1
+ (set_global $global$0$0
+ (i32.add
+ (get_global $import$0$0)
+ (i32.const 48)
+ )
)
- )
- (set_global $global$1$0
- (i32.add
- (get_global $global$0$0)
- (i32.const 10)
+ (set_global $global$1$0
+ (i32.add
+ (get_global $global$0$0)
+ (i32.const 10)
+ )
)
+ (call $runPostSets$0)
)
- (call $runPostSets$0)
)
)
;; custom section "dylink", size 2
diff --git a/test/merge/dylib.wasm.toMerge b/test/merge/dylib.wasm.toMerge
index c9953956b..63ff1fd0a 100644
--- a/test/merge/dylib.wasm.toMerge
+++ b/test/merge/dylib.wasm.toMerge
Binary files differ