Skip to content

Commit

Permalink
Emit source map information for control flow structures (#5524)
Browse files Browse the repository at this point in the history
With this, the sourcemap testcase outputs the exact same thing as the input.

Followup to #5504
  • Loading branch information
kripken authored Feb 28, 2023
1 parent edc2784 commit 62e0b2f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/wasm-stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ void BinaryenIRWriter<SubType>::visit(Expression* curr) {
// `curr` is not reachable, so don't emit it.
return;
}
emitDebugLocation(curr);
// Control flow requires special handling, but most instructions can be
// emitted directly after their children.
if (Properties::isControlFlowStructure(curr)) {
Visitor<BinaryenIRWriter>::visit(curr);
} else {
emitDebugLocation(curr);
emit(curr);
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/lit/source-map.wast
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
)

;; CHECK: (func $foo (param $x i32) (param $y i32)
;; CHECK-NEXT: ;;@ src.cpp:20:1
;; CHECK-NEXT: ;;@ src.cpp:10:1
;; CHECK-NEXT: (if
;; CHECK-NEXT: ;;@ src.cpp:20:1
;; CHECK-NEXT: (i32.add
;; CHECK-NEXT: ;;@ src.cpp:30:1
;; CHECK-NEXT: (local.get $x)
Expand Down

0 comments on commit 62e0b2f

Please sign in to comment.