-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[mypyc] Merge yield_from_except_op #9660
Conversation
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.
Thanks -- this is a tricky one! I have some thoughts about potentially making this cleaner. It's kind of awkward to have to use casts from PyObject *
to PyObject **
.
@@ -45,7 +46,8 @@ def split_blocks_at_uninits(env: Environment, | |||
# initialized is an operand to something other than a | |||
# check that it is defined, insert a check. | |||
if (isinstance(src, Register) and src not in defined | |||
and not (isinstance(op, Branch) and op.op == Branch.IS_ERROR)): | |||
and not (isinstance(op, Branch) and op.op == Branch.IS_ERROR) | |||
and not isinstance(op, LoadAddress)): |
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.
Why do we need this? Add comment explaining this, since this is a bit surprising. I wonder if we can somehow get rid of this special case.
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.
We need this because we are taking the address of an uninitialized object, the automatically inserted initialization check will produce incorrect code, leading the control flow directly to uninitialized error rather than the following load address and other ops.
Can you check that there is some existing case that uses the primitive? If not, it makes sense to add one (but I assume that this is tested somewhere). |
yes, there's |
I've made some updates according to your review, including using |
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.
Thanks for the updates! Looks good.
I'd suggest dropping the test case (but even then it has been useful to see what sort of code is being generated).
relates mypyc/mypyc#753
This PR merges
yield_from_except_op
into the new IR, including several changes:LoadAddress
, allowing it to load local reg's address.uninit
pass, suppressing checks onLoadAddress