summaryrefslogtreecommitdiff
path: root/test/lit/passes/optimize-instructions-call_ref.wast
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-06-12 11:05:28 -0700
committerGitHub <noreply@github.com>2024-06-12 11:05:28 -0700
commitac21c8cc9204e09fab070d2fd915e7ab583a5dac (patch)
tree190a13113804b3c6ea01dd71f44694e1b6111be0 /test/lit/passes/optimize-instructions-call_ref.wast
parent475841dd5f0c50d7072f6dfc26dffd66e02abc10 (diff)
downloadbinaryen-ac21c8cc9204e09fab070d2fd915e7ab583a5dac.tar.gz
binaryen-ac21c8cc9204e09fab070d2fd915e7ab583a5dac.tar.bz2
binaryen-ac21c8cc9204e09fab070d2fd915e7ab583a5dac.zip
[DebugInfo] Copy debug info in call-utils.h (#6652)
We automatically copy debuginfo in replaceCurrent(), but there are a few places that do other operations than simple replacements. call-utils.h will turn a call_ref with a select target into two direct calls, and we were missing the logic to copy debuginfo from the call_ref to the calls. To make this work, refactor out the copying logic from wasm-traversal, into debuginfo.h, and use it in call-utils.h. debuginfo.h itself is renamed from debug.h (as now this needs to be included from wasm-traversal, which nearly everything does, and it turns out some files have internal stuff like a debug() helper that ends up conflicing with the old debug namespace). Also rename the old copyDebugInfo function to copyDebugInfoBetweenFunctions which is more explicit. That is also moved from the header to a cpp file because it depends on wasm-traversal (so we'd end up with recursive headers otherwise). That is fine, as that method is called after copying a function, which is not that frequent. The new copyDebugInfoToReplacement (which was refactored out of wasm-traversal) is in the header because it can be called very frequently (every single instruction we optimize) and we want it to get inlined.
Diffstat (limited to 'test/lit/passes/optimize-instructions-call_ref.wast')
-rw-r--r--test/lit/passes/optimize-instructions-call_ref.wast25
1 files changed, 23 insertions, 2 deletions
diff --git a/test/lit/passes/optimize-instructions-call_ref.wast b/test/lit/passes/optimize-instructions-call_ref.wast
index 94c61433f..91aba5fed 100644
--- a/test/lit/passes/optimize-instructions-call_ref.wast
+++ b/test/lit/passes/optimize-instructions-call_ref.wast
@@ -44,13 +44,16 @@
)
;; CHECK: (func $call_ref-to-direct (type $i32_i32_=>_none) (param $x i32) (param $y i32)
+ ;; CHECK-NEXT: ;;@ file.cpp:10:1
;; CHECK-NEXT: (call $foo
;; CHECK-NEXT: (local.get $x)
;; CHECK-NEXT: (local.get $y)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $call_ref-to-direct (param $x i32) (param $y i32)
- ;; This call_ref should become a direct call.
+ ;; This call_ref should become a direct call. The debuginfo should transfer as
+ ;; well.
+ ;;@ file.cpp:10:1
(call_ref $i32_i32_=>_none
(local.get $x)
(local.get $y)
@@ -253,29 +256,42 @@
;; CHECK: (func $call_ref-to-select (type $5) (param $x i32) (param $y i32) (param $z i32) (param $f (ref $i32_i32_=>_none))
;; CHECK-NEXT: (local $4 i32)
;; CHECK-NEXT: (local $5 i32)
+ ;; CHECK-NEXT: ;;@ file.cpp:20:2
;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: ;;@
;; CHECK-NEXT: (local.set $4
+ ;; CHECK-NEXT: ;;@ file.cpp:20:2
;; CHECK-NEXT: (local.get $x)
;; CHECK-NEXT: )
+ ;; CHECK-NEXT: ;;@
;; CHECK-NEXT: (local.set $5
+ ;; CHECK-NEXT: ;;@ file.cpp:20:2
;; CHECK-NEXT: (local.get $y)
;; CHECK-NEXT: )
+ ;; CHECK-NEXT: ;;@
;; CHECK-NEXT: (if
+ ;; CHECK-NEXT: ;;@ file.cpp:20:2
;; CHECK-NEXT: (local.get $z)
;; CHECK-NEXT: (then
;; CHECK-NEXT: (call $foo
+ ;; CHECK-NEXT: ;;@
;; CHECK-NEXT: (local.get $4)
+ ;; CHECK-NEXT: ;;@
;; CHECK-NEXT: (local.get $5)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (else
+ ;; CHECK-NEXT: ;;@ file.cpp:20:2
;; CHECK-NEXT: (call $bar
+ ;; CHECK-NEXT: ;;@
;; CHECK-NEXT: (local.get $4)
+ ;; CHECK-NEXT: ;;@
;; CHECK-NEXT: (local.get $5)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
+ ;; CHECK-NEXT: ;;@ file.cpp:30:3
;; CHECK-NEXT: (call_ref $i32_i32_=>_none
;; CHECK-NEXT: (local.get $x)
;; CHECK-NEXT: (local.get $y)
@@ -287,7 +303,11 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $call_ref-to-select (param $x i32) (param $y i32) (param $z i32) (param $f (ref $i32_i32_=>_none))
- ;; This call_ref should become an if over two direct calls.
+ ;; This call_ref should become an if over two direct calls. The debuginfo
+ ;; should transfer as well to the two new calls (and some of the new helper
+ ;; code that is generated, but the critical part is the call_ref is being
+ ;; replaced by two calls, which should have the same info).
+ ;;@ file.cpp:20:2
(call_ref $i32_i32_=>_none
(local.get $x)
(local.get $y)
@@ -299,6 +319,7 @@
)
;; But here one arm is not constant, so we do not optimize.
+ ;;@ file.cpp:30:3
(call_ref $i32_i32_=>_none
(local.get $x)
(local.get $y)