summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/help/wasm-opt.test3
-rw-r--r--test/lit/help/wasm2js.test3
-rw-r--r--test/lit/passes/reorder-functions-by-name.wast107
3 files changed, 113 insertions, 0 deletions
diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test
index 30369e62f..d57e5fd1d 100644
--- a/test/lit/help/wasm-opt.test
+++ b/test/lit/help/wasm-opt.test
@@ -373,6 +373,9 @@
;; CHECK-NEXT: --reorder-functions sorts functions by access
;; CHECK-NEXT: frequency
;; CHECK-NEXT:
+;; CHECK-NEXT: --reorder-functions-by-name sorts functions by name (useful
+;; CHECK-NEXT: for debugging)
+;; CHECK-NEXT:
;; CHECK-NEXT: --reorder-globals sorts globals by access
;; CHECK-NEXT: frequency
;; CHECK-NEXT:
diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test
index 916dbbb4d..2994a1f59 100644
--- a/test/lit/help/wasm2js.test
+++ b/test/lit/help/wasm2js.test
@@ -332,6 +332,9 @@
;; CHECK-NEXT: --reorder-functions sorts functions by access
;; CHECK-NEXT: frequency
;; CHECK-NEXT:
+;; CHECK-NEXT: --reorder-functions-by-name sorts functions by name (useful
+;; CHECK-NEXT: for debugging)
+;; CHECK-NEXT:
;; CHECK-NEXT: --reorder-globals sorts globals by access
;; CHECK-NEXT: frequency
;; CHECK-NEXT:
diff --git a/test/lit/passes/reorder-functions-by-name.wast b/test/lit/passes/reorder-functions-by-name.wast
new file mode 100644
index 000000000..ab5b35bc2
--- /dev/null
+++ b/test/lit/passes/reorder-functions-by-name.wast
@@ -0,0 +1,107 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+;; RUN: foreach %s %t wasm-opt -all --reorder-functions-by-name -S -o - | filecheck %s
+
+(module
+ ;; CHECK: (type $none_=>_i32 (func (result i32)))
+
+ ;; CHECK: (func $a (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 10)
+ ;; CHECK-NEXT: )
+
+ ;; CHECK: (func $b (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 20)
+ ;; CHECK-NEXT: )
+
+ ;; CHECK: (func $c (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 30)
+ ;; CHECK-NEXT: )
+ (func $c (result i32)
+ (i32.const 30)
+ )
+
+ (func $b (result i32)
+ (i32.const 20)
+ )
+
+ (func $a (result i32)
+ (i32.const 10)
+ )
+)
+
+(module
+ ;; CHECK: (type $none_=>_i32 (func (result i32)))
+
+ ;; CHECK: (func $a (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 10)
+ ;; CHECK-NEXT: )
+ (func $a (result i32)
+ (i32.const 10)
+ )
+
+ ;; CHECK: (func $b (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 20)
+ ;; CHECK-NEXT: )
+ (func $b (result i32)
+ (i32.const 20)
+ )
+
+ ;; CHECK: (func $c (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 30)
+ ;; CHECK-NEXT: )
+ (func $c (result i32)
+ (i32.const 30)
+ )
+)
+
+(module
+ ;; CHECK: (type $none_=>_i32 (func (result i32)))
+
+ ;; CHECK: (func $a (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 10)
+ ;; CHECK-NEXT: )
+
+ ;; CHECK: (func $b (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 20)
+ ;; CHECK-NEXT: )
+ (func $b (result i32)
+ (i32.const 20)
+ )
+
+ (func $a (result i32)
+ (i32.const 10)
+ )
+
+ ;; CHECK: (func $c (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 30)
+ ;; CHECK-NEXT: )
+ (func $c (result i32)
+ (i32.const 30)
+ )
+)
+
+(module
+ ;; CHECK: (type $none_=>_i32 (func (result i32)))
+
+ ;; CHECK: (func $a (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 10)
+ ;; CHECK-NEXT: )
+
+ ;; CHECK: (func $b (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 20)
+ ;; CHECK-NEXT: )
+
+ ;; CHECK: (func $c (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 30)
+ ;; CHECK-NEXT: )
+ (func $c (result i32)
+ (i32.const 30)
+ )
+
+ (func $a (result i32)
+ (i32.const 10)
+ )
+
+ (func $b (result i32)
+ (i32.const 20)
+ )
+)