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

[NFC-ish] Eagerly create Functions in binary parser #6957

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

tlively
Copy link
Member

@tlively tlively commented Sep 19, 2024

In preparation for using IRBuilder in the binary parser, eagerly create
Functions when parsing the function section so that they are already
created once we parse the code section. IRBuilder will require the
functions to exist when parsing calls so it can figure out what type
each call should have, even when there is a call to a function whose
body has not been parsed yet.

NFC except that some error messages change to include the new empty
functions.

In preparation for using IRBuilder in the binary parser, eagerly create
Functions when parsing the function section so that they are already
created once we parse the code section. IRBuilder will require the
functions to exist when parsing calls so it can figure out what type
each call should have, even when there is a call to a function whose
body has not been parsed yet.

NFC except that some error messages change to include the new empty
functions.
;; CHECK-NEXT: )
;; CHECK-NEXT: (func $2
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
Copy link
Member

Choose a reason for hiding this comment

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

This seems like it could be confusing for users and even for us when debugging, to see these unreachables in the function bodies. How about storing nullptr for the body, and making Print handle those (by printing "placeholder" or such)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was originally going that route, but Print isn't the only place that would need to change. ModuleUtils would need to update the type collection code not to trip over the nullptr, too.

Copy link
Member

Choose a reason for hiding this comment

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

Wait, how can we do type collection before the entire module is ready?

Copy link
Member Author

Choose a reason for hiding this comment

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

Collecting the types is a prerequisite for printing the module. Even when the module is not complete, it's still in a consistent enough state that we can walk it and collect types.

Copy link
Member

Choose a reason for hiding this comment

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

I see. If it's only in those two places, perhaps it makes sense to do? I'd lean that way myself.

@tlively tlively merged commit 2711d4f into main Sep 20, 2024
13 checks passed
@tlively tlively deleted the binary-parser-eager-funcs branch September 20, 2024 00:07
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