Skip to content
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

Match names more precisely in update_lit_checks.py #6190

Merged
merged 2 commits into from
Jan 2, 2024
Merged

Conversation

tlively
Copy link
Member

@tlively tlively commented Dec 20, 2023

Previously the lit test update script interpreted module names as the names of
import items and export names as the names of export items, but it is more
precise to use the actual identifiers of the imported or exported items as the
names instead.

Update update_lit_checks.py to use a more correct regex to match names and to
correctly use the identifiers of import and export items as their names. In some
cases this can improve the readability of test output.

@tlively tlively requested a review from kripken December 20, 2023 22:29
@tlively
Copy link
Member Author

tlively commented Dec 20, 2023


;; CHECK-BIN-NODEBUG: (export "test1" (func $fimport$0))

;; CHECK-BIN-NODEBUG: (export "test2" (global $gimport$0))
Copy link
Member

Choose a reason for hiding this comment

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

Looks less readable here, as it emits it out past the end of the module for some reason?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is because round-tripping through the binary does not preserve the names we are now correctly matching against. That's not a new problem with this change, although it now correctly shows up in this case.

Copy link
Member

@kripken kripken Dec 20, 2023

Choose a reason for hiding this comment

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

But before it looks like it was just in the right place? I mean, before we had this:

 ;; CHECK-BIN: (import "env" "test1" (func $test1 (type $v)))
 ;; CHECK-BIN-NODEBUG:      (import "env" "test1" (func $fimport$0 (type $0)))

So yeah, we didn't round-trip the name $test1 but still the imports were perfectly aligned?

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 was in a nice place for the wrong reasons. If the input had more imports from "env", then they would all be bunched up together in the output rather than actually matched up with their corresponding input.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I actually think grouping all imports that are identical in module and name makes sense - do you disagree? In the quote from my last comment, env and test1 are identical in both lines, so it's nice to keep them together.

I can see how a more strict approach can justify moving them away, but I think it's a loss for readability. Could we perhaps both match names more precisely and also secondarily keep imports/exports with identical external names close together? Then there would not be a regression here from my perspective.

But if that's very difficult to do I won't insist.

Copy link
Member Author

Choose a reason for hiding this comment

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

There are other cases (such as in the next PR) where this improves readability by correctly matching imports with their inputs where they would not have otherwise been grouped together.

The update script never reorders the input or the output, so in that sense all the output imports will always be grouped together, but now the way they are interleaved with the input is more consistent and the result is more readable in some cases, but not all cases.

Doing better than making the interleaving consistent would require reordering things, and that's not possible or desirable right now.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Fair enough, lgtm.

Previously the lit test update script interpreted module names as the names of
import items and export names as the names of export items, but it is more
precise to use the actual identifiers of the imported or exported items as the
names instead.

Update update_lit_checks.py to use a more correct regex to match names and to
correctly use the identifiers of import and export items as their names. In some
cases this can improve the readability of test output.
@tlively tlively force-pushed the regex-improvements branch from 62b668c to b5a1ed8 Compare January 2, 2024 19:33
@tlively
Copy link
Member Author

tlively commented Jan 2, 2024

Merge activity

@tlively tlively merged commit 95ed4f3 into main Jan 2, 2024
@tlively tlively deleted the regex-improvements branch January 2, 2024 20:08
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
Previously the lit test update script interpreted module names as the names of
import items and export names as the names of export items, but it is more
precise to use the actual identifiers of the imported or exported items as the
names instead.

Update update_lit_checks.py to use a more correct regex to match names and to
correctly use the identifiers of import and export items as their names. In some
cases this can improve the readability of test output.
@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.

2 participants