Skip to content

Conversation

@vouillon
Copy link
Contributor

The comment ;;@ with nothing else can be used to specify that the following expression does not have any debug info associated to it. This can be used to stop the automatic propagation of debug info in the text parsers.

The text printer has also been updated to output this comment when needed.

Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

Isn't 0,0,0 a valid debug location? I think it would be better to use an empty std::optional to signify the absence of a debug location.

@vouillon vouillon force-pushed the absent-locs branch 4 times, most recently from 9ddf666 to 909c3df Compare April 23, 2024 17:12
Function* func;
Builder builder;
std::optional<Function::DebugLocation> debugLoc;
std::optional<std::optional<Function::DebugLocation>> debugLoc;
Copy link
Member

Choose a reason for hiding this comment

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

Worth a comment here too I think.

Copy link
Member

Choose a reason for hiding this comment

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

Reading the comment, it's not immediately obvious how those three modes are represented in the data structure. Not hard to figure out but it might be better to be explicit, that is, "we explicitly specified that this instruction has no debug location" could be followed by "(the internal optional is nullopt)".

But reading this another time now, maybe we can do better than nested optionals. How about

  // The location lacks debug info as it was marked as not having it.
  struct NoDebug : public std::monostate {};
  // The location lacks debug info, but was not marked as not having it, and it
  // can receive it from the parent (if the parent has it).
  struct CanReceiveDebug : public std::monostate {};
  using DebugVariant = std::variant<NoDebug, CanReceiveDebug, Function::DebugLocation>;

See e.g. src/ir/possible-contents.h for example code that uses that variant pattern.

if (debugLocEnd == debugLoc) {
loc = nullptr;
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

How does this relate to the PR - is it necessary because of something, or necessary for a new test, or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just parsing ;;@ with nothing after.

(br $label$4)
)
)
;;@
Copy link
Member

Choose a reason for hiding this comment

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

I tried to look for this in the binary. What I did is add a printf here:

// This is a 1-length entry, so the next location has no debug info.

I believe that is the right place for reading a source map entry that says "this has no debug info, explicitly". But I don't see it reached. Am I doing something wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you are right. One should probably not clear the debug location here:

debugLocation.clear();

@vouillon
Copy link
Contributor Author

I have opened a separate PR #6550 that include the source map fixes. I'll rebase this PR once the other is merged.

@vouillon vouillon force-pushed the absent-locs branch 7 times, most recently from f91c476 to 6d744c4 Compare May 2, 2024 14:13
vouillon and others added 7 commits May 2, 2024 20:12
… text parsers

The comment `;;@` with nothing else can be used to specify that the
following expression does not have any debug info associated to it. This
can be used to stop the automatic propagation of debug info in the text
parsers.

The text printer has also been updated to output this comment when needed.
This is not supported anyway, since this relies on the indentation
information, which is not updated when minifying.
@kripken
Copy link
Member

kripken commented May 6, 2024

Is this ready for review after the other PR landed?

@vouillon
Copy link
Contributor Author

vouillon commented May 7, 2024

Yes, this is ready

;; CHECK-NEXT: ;;@
;; CHECK-NEXT: (i32.add
;; CHECK-NEXT: (local.get $x)
;; CHECK-NEXT: (local.get $y)
Copy link
Member

Choose a reason for hiding this comment

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

To make sure I understand, these local.get have no debug annotation, like their parent, and so we did not print anything for them? That is, "nothing" propagates to children just like an actual debug location does?

Copy link
Member

Choose a reason for hiding this comment

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

This might be worth clarifying in the README.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. I have updated the README.

@kripken kripken merged commit 140386e into WebAssembly:main May 14, 2024
@vouillon vouillon deleted the absent-locs branch May 14, 2024 20:36
@gkdn gkdn mentioned this pull request Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants