Skip to content

Fix Branch Hinting iostream printing #7603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2679,11 +2679,11 @@ void PrintSExpression::printCodeAnnotations(Expression* curr) {
if (annotation.inline_) {
Colors::grey(o);
std::ofstream saved;
saved.copyfmt(std::cout);
saved.copyfmt(o);
o << "(@" << Annotations::InlineHint << " \"\\" << std::hex
<< std::setfill('0') << std::setw(2) << int(*annotation.inline_)
<< "\")\n";
std::cout.copyfmt(saved);
o.copyfmt(saved);
restoreNormalColor(o);
doIndent(o, indent);
}
Expand Down
21 changes: 21 additions & 0 deletions test/lit/branch-hinting-printing.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
;; The branch hint should not cause the later constant to print incorrectly
;; (branch hints are printed in hex, and we should clear that state so later
;; things are not affected).

(module
(type $0 (func))
(func $0 (type $0)
(@metadata.code.inline "\00")
(call $0)
)
(func $1 (type $0)
(drop
(i32.const -18428)
)
)
)

;; RUN: wasm-opt %s -o %t.wasm -g
;; RUN: wasm-dis %t.wasm | filecheck %s

;; CHECK: (i32.const -18428)
Loading