-
Notifications
You must be signed in to change notification settings - Fork 825
Ensure printed tuple.extract arity is valid #6487
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
Conversation
We previously printed the size of the tuple operand as the arity, but that printed `1` when the operand is unreachable. We don't allow our text input to use `1` as the arity, so don't print it, either. Instead, print the smallest valid arity, `2`, in this case.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
src/passes/Print.cpp
Outdated
| // not a valid tuple size. The size we print mostly doesn't matter if the | ||
| // tuple is unreachable, but it does have to be valid. | ||
| auto arity = curr->tuple->type.size(); | ||
| arity = arity < 2 ? 2 : arity; |
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.
| arity = arity < 2 ? 2 : arity; | |
| arity = std::min(arity, 2); |
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (tuple.extract 1 1 | ||
| ;; CHECK-NEXT: (tuple.extract 2 1 | ||
| ;; CHECK-NEXT: (local.tee $tuple |
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.
Doesn't this depend on the type of $tuple, which happens to be of size 2? That is, if line 571 changed to have 17 items in the tuple, would this still validate?
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.
Yes, it would still validate because we do not store the expected arity of TupleExtract in the IR, so the validator would not know what the expected arity is, just that the tuple value is unreachable.

We previously printed the size of the tuple operand as the arity, but that
printed
1when the operand is unreachable. We don't allow our text input touse
1as the arity, so don't print it, either. Instead, print the smallestvalid arity,
2, in this case.