-
Notifications
You must be signed in to change notification settings - Fork 737
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
Conversation
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: ) |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.