Skip to content

Conversation

@kripken
Copy link
Member

@kripken kripken commented Feb 3, 2026

This is the first function-level annotation, so this includes some
necessary fixes for that.

Diff without whitespace is smaller.

@kripken kripken requested a review from tlively February 3, 2026 22:46
auto offset = exprOffset - funcDeclarationsOffset;
// Compute the offset: it should be relative to the start of the
// function locals (i.e. the function declarations).
offset = exprOffset - funcDeclarationsOffset;
Copy link
Member

Choose a reason for hiding this comment

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

Does this expression offset ever end up being 0 as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

It can't be 0 - the function has something at offset 0 (the number of locals, even if has no locals, that will take a byte for "0"). This is why we decided it was safe to use offset 0 in the spec.

Comment on lines 11 to 12
;; RUN: wasm-opt -all %s -S -o - | filecheck %s
;; RUN: wasm-opt -all --roundtrip %s -S -o - | filecheck %s
Copy link
Member

Choose a reason for hiding this comment

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

Can we move the RUN lines to the top of the file for consistency with other tests? I was about to leave a comment asking how it was possible that there were no RUN lines here before I found them 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, moved.

(@metadata.code.inline "\12")
(func $func-annotation
;; The annotation here is on the function.
(drop
Copy link
Member

Choose a reason for hiding this comment

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

Related to my question about the offsets, can we properly roundtrip an annotation on the first expression in a function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, and we test that, see e.g.

(@metadata.code.inline "\00")

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.

2 participants