-
Notifications
You must be signed in to change notification settings - Fork 12k
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
tailcallelim introduces write to readonly byval parameter #64289
tailcallelim introduces write to readonly byval parameter #64289
Comments
If Alive2 is correct, it is possible that LICM caused this error. |
Bisected: 01859da. |
Yes, I think we should be dropping Generally, changing function attributes during a (non-IPO) transform is very fishy, in particular because the attribute might have been propagated out to callers and used there. However, the situation with byval + readonly is quite special, as the note in LangRef indicates. From the perspective of a caller, byval is basically always "readonly", in that the memory passed to the argument will always be copied to the byval stack slot and never modified. The |
I try to submit a patch that removes |
Reopen and wait for the post CI to look ok then pick to 17. |
When eliminating a tail call, we modify the values of the arguments. Therefore, if the byval parameter has a readonly attribute, we have to remove it. It is safe because, from the perspective of a caller, the byval parameter is always treated as "readonly," even if the readonly attribute is removed. Fixes llvm#64289. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D156793 (cherry picked from commit c3f227e)
/branch llvm/llvm-project-release-prs/issue64289 |
/pull-request llvm/llvm-project-release-prs#556 |
When eliminating a tail call, we modify the values of the arguments. Therefore, if the byval parameter has a readonly attribute, we have to remove it. It is safe because, from the perspective of a caller, the byval parameter is always treated as "readonly," even if the readonly attribute is removed. Fixes #64289. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D156793 (cherry picked from commit c3f227e)
When eliminating a tail call, we modify the values of the arguments. Therefore, if the byval parameter has a readonly attribute, we have to remove it. It is safe because, from the perspective of a caller, the byval parameter is always treated as "readonly," even if the readonly attribute is removed. Fixes llvm#64289. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D156793 (cherry picked from commit c3f227e)
With the following IR:
opt -passes="tailcallelim"
results in (https://godbolt.org/z/9arGs5xhx):%x
is now written to, but it still has itsreadonly
attribute.LangRef seems to imply that this is illegal:
However, Alive2 is fine with writes to
readonly byval
arguments (but does flag identical IR withoutbyval
): https://alive2.llvm.org/ce/z/T6yxU-This leads to an end-to-end miscompile, where the following recursion (always terminating after one call):
is converted to an infinite loop with
opt -O3
(https://godbolt.org/z/9zbn6hno9):If LangRef is right, the bug is in tailcallelim. If Alive2 is right, the bug is in whatever other transforms assume that
readonly
is meaningful onbyval
arguments.Upstream issue: rust-lang/rust#114312
The text was updated successfully, but these errors were encountered: