summaryrefslogtreecommitdiff
path: root/test/metadce
diff options
context:
space:
mode:
authorJérôme Vouillon <jerome.vouillon@gmail.com>2023-06-29 22:20:53 +0200
committerGitHub <noreply@github.com>2023-06-29 13:20:53 -0700
commit5f6594c52d1a9a285f7bfcfd31c46f5062c24b19 (patch)
treed8bdb42ea6dc47c507a58bf25e69bd1107aca96f /test/metadce
parent7b2e06aa3a0b6cef9568c3eab010a7187b9b6803 (diff)
downloadbinaryen-5f6594c52d1a9a285f7bfcfd31c46f5062c24b19.tar.gz
binaryen-5f6594c52d1a9a285f7bfcfd31c46f5062c24b19.tar.bz2
binaryen-5f6594c52d1a9a285f7bfcfd31c46f5062c24b19.zip
[wasm-metadce] Note ref.func connections + fix rooting of segment offsets (#5791)
Diffstat (limited to 'test/metadce')
-rw-r--r--test/metadce/ref-func.wast11
-rw-r--r--test/metadce/ref-func.wast.dced13
-rw-r--r--test/metadce/ref-func.wast.dced.stdout0
-rw-r--r--test/metadce/ref-func.wast.graph.txt23
-rw-r--r--test/metadce/segments.wast14
-rw-r--r--test/metadce/segments.wast.dced18
-rw-r--r--test/metadce/segments.wast.dced.stdout0
-rw-r--r--test/metadce/segments.wast.graph.txt19
8 files changed, 98 insertions, 0 deletions
diff --git a/test/metadce/ref-func.wast b/test/metadce/ref-func.wast
new file mode 100644
index 000000000..b7d2b8ac7
--- /dev/null
+++ b/test/metadce/ref-func.wast
@@ -0,0 +1,11 @@
+(module
+ (import "env" "f1" (func $f1))
+ (import "env" "f2" (func $f2))
+
+ (export "g" (global $g))
+ (export "f" (func $f))
+
+ (global $g funcref (ref.func $f1))
+
+ (func $f (result funcref) (ref.func $f2))
+)
diff --git a/test/metadce/ref-func.wast.dced b/test/metadce/ref-func.wast.dced
new file mode 100644
index 000000000..3117c4978
--- /dev/null
+++ b/test/metadce/ref-func.wast.dced
@@ -0,0 +1,13 @@
+(module
+ (type $none_=>_none (func))
+ (type $none_=>_funcref (func (result funcref)))
+ (import "env" "f2" (func $f2 (type $none_=>_none)))
+ (import "env" "f1" (func $f1 (type $none_=>_none)))
+ (global $g funcref (ref.func $f1))
+ (elem declare func $f2)
+ (export "g" (global $g))
+ (export "f" (func $f))
+ (func $f (type $none_=>_funcref) (result funcref)
+ (ref.func $f2)
+ )
+)
diff --git a/test/metadce/ref-func.wast.dced.stdout b/test/metadce/ref-func.wast.dced.stdout
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test/metadce/ref-func.wast.dced.stdout
diff --git a/test/metadce/ref-func.wast.graph.txt b/test/metadce/ref-func.wast.graph.txt
new file mode 100644
index 000000000..89adf046f
--- /dev/null
+++ b/test/metadce/ref-func.wast.graph.txt
@@ -0,0 +1,23 @@
+[
+ {
+ "name": "root",
+ "reaches": ["f", "g"],
+ "root": true
+ },
+ {
+ "name": "f",
+ "export": "f"
+ },
+ {
+ "name": "g",
+ "export": "g"
+ },
+ {
+ "name": "f1",
+ "import": ["env", "f1"]
+ },
+ {
+ "name": "f2",
+ "import": ["env", "f2"]
+ },
+]
diff --git a/test/metadce/segments.wast b/test/metadce/segments.wast
new file mode 100644
index 000000000..96e0088e8
--- /dev/null
+++ b/test/metadce/segments.wast
@@ -0,0 +1,14 @@
+(module
+ (import "env" "g1" (global $g1 i32))
+ (import "env" "g2" (global $g2 i32))
+
+ (table $tbl funcref)
+ (elem (offset (global.get $g1)) funcref (ref.func $f))
+
+ (memory 3)
+ (data (offset (global.get $g2)) "xxx")
+
+ (export "f" (func $f))
+ (func $f (param i32)
+ (call_indirect (param i32) (local.get 0) (i32.load8_u (i32.const 0))))
+)
diff --git a/test/metadce/segments.wast.dced b/test/metadce/segments.wast.dced
new file mode 100644
index 000000000..944614bc2
--- /dev/null
+++ b/test/metadce/segments.wast.dced
@@ -0,0 +1,18 @@
+(module
+ (type $i32_=>_none (func (param i32)))
+ (import "env" "g1" (global $g1 i32))
+ (import "env" "g2" (global $g2 i32))
+ (memory $0 3)
+ (data $0 (global.get $g2) "xxx")
+ (table $tbl 0 funcref)
+ (elem $0 (global.get $g1) $f)
+ (export "f" (func $f))
+ (func $f (type $i32_=>_none) (param $0 i32)
+ (call_indirect $tbl (type $i32_=>_none)
+ (local.get $0)
+ (i32.load8_u
+ (i32.const 0)
+ )
+ )
+ )
+)
diff --git a/test/metadce/segments.wast.dced.stdout b/test/metadce/segments.wast.dced.stdout
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test/metadce/segments.wast.dced.stdout
diff --git a/test/metadce/segments.wast.graph.txt b/test/metadce/segments.wast.graph.txt
new file mode 100644
index 000000000..eed62cced
--- /dev/null
+++ b/test/metadce/segments.wast.graph.txt
@@ -0,0 +1,19 @@
+[
+ {
+ "name": "root",
+ "reaches": ["f"],
+ "root": true
+ },
+ {
+ "name": "f",
+ "export": "f"
+ },
+ {
+ "name": "g1",
+ "import": ["env", "g1"]
+ },
+ {
+ "name": "g2",
+ "import": ["env", "g2"]
+ },
+]