Skip to content
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
5 changes: 4 additions & 1 deletion src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {

std::vector<HeapType> heapTypes;

unsigned lastPrintIndent = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining the motivation for tracking the print indent, maybe with an example? I am imagining something like this:

//  Track the print indent so that we can see when it changes. That affects how we print debug annotations. In particular, we don't want to print repeated debug locations for children, like this:
//
//  ;;@ file.cpp:20:4
// (block
//    ;; no need to annotate here
//    (nop)
//
// But we do want to print an annotation even if it repeats if it is not a child:
//
//  ;;@ file.cpp:20:4
// (block
// )
// ;;@ file.cpp:20:4 - this is worth annotating
// (nop)


// Print type names by saved name or index if we have a module, or otherwise
// by generating minimalist names. TODO: Handle conflicts between
// user-provided names and the fallback indexed names.
Expand Down Expand Up @@ -2375,10 +2377,11 @@ std::ostream& PrintSExpression::printPrefixedTypes(const char* prefix,

void PrintSExpression::printDebugLocation(
const Function::DebugLocation& location) {
if (lastPrintedLocation == location) {
if (lastPrintedLocation == location && indent > lastPrintIndent) {
return;
}
lastPrintedLocation = location;
lastPrintIndent = indent;
auto fileName = currModule->debugInfoFileNames[location.fileIndex];
o << ";;@ " << fileName << ":" << location.lineNumber << ":"
<< location.columnNumber << '\n';
Expand Down
5 changes: 5 additions & 0 deletions test/fib-dbg.wasm.fromBinary
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
(i32.const 0)
)
)
;;@ fib.c:3:0
(if
(local.get $6)
(block
Expand All @@ -156,6 +157,7 @@
)
)
)
;;@ fib.c:8:0
(loop $label$4
(block $label$5
;;@ fib.c:4:0
Expand All @@ -172,12 +174,14 @@
(i32.const 1)
)
)
;;@ fib.c:3:0
(local.set $7
(i32.eq
(local.get $9)
(local.get $0)
)
)
;;@ fib.c:3:0
(if
(local.get $7)
(block
Expand All @@ -201,6 +205,7 @@
)
)
)
;;@ fib.c:3:0
(br $label$4)
)
)
Expand Down