-
Notifications
You must be signed in to change notification settings - Fork 12.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
Storage liveness is generated incorrectly for this code snippet #38669
Comments
/cc @rust-lang/compiler |
It seems like this could possibly be the cause of #39455 |
Related: #39685 |
This has to be fixed for MIR borrowck and the fix should not be that hard. |
@arielb1 I forget -- did we have a planned fix? =) It seems like adopting the "extended basic block" formulation might help here, but given that |
As discussed in @rust-lang/compiler meeting, the plan would be to introduce a fresh temporary with the value being tested. This temporary would have no storage-live/storage-dead, so it technically "lives forever", but since it's never borrowed, its lifetime can be trivially analyzed. In LLVM terms, it'd be represented as an SSA value. |
One other point is that we would want to be careful around constants (like |
|
In MIR construction, operands need to live exactly until they are used, which is during the (sub)expression that made the call to `as_operand`. Before this PR, operands lived until the end of the temporary scope, which was sometimes unnecessarily longer and sometimes too short. Fixes rust-lang#38669.
It looks like this fixed #39455. Is it possible to get this uplifted all the way to stable? It seems like it can cause some pretty insidious problems. |
No. We do not release point stable releases, except for very exceptional cases. The fix seems non-trivial, so I doubt we’d backport it to beta either, especially given the fact that train rollover is near. |
Do we have a good idea of how much code will be miscompiled without this fix? |
Not much at all. There’s a number of conditions that are necessary to reproduce this issue and |
has
as the generated MIR. The LLVM IR ends up being generated correctly, because
_4
is determined to be an SSA-like lvalue, but I fear that there may also be cases where equivalent of_4
would be forced into an alloca (and generate incorrect IR, after some compiler change maybe?) and would certainly interfere with MIR optimisations and MIR borrowck.The text was updated successfully, but these errors were encountered: