-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
The opt, as written today, will miscompile something that looks like this:
slice_ptr = Cast(array_ptr);
r = &mut slice_ptr;
*r = something_else;
Len(slice_ptr)
The bug is roughly on this line:
state.remove(&place.local); |
This makes an attempt to detect other writes to the slice_ptr
local, but it misses a lot of cases. Taking a reference like in the example above is an easy one, but SetDiscriminant
is also missed, as well as writes to any aliasing pointers.
As far as I can tell this needs Rvalue::Cast
support in custom MIR to reproduce.
@rustbot label A-mir-opt T-compiler requires-nightly
Metadata
Metadata
Assignees
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
NormalizeArrayLen
#105930shamatar commentedon Dec 20, 2022
This optimization is more a workaround of unwillingness to add "len()" function to arrays, so method resolution would not need to use coercion to slice, but I'll check what can be done to fix it
Rollup merge of rust-lang#105930 - JakobDegen:nal-unsound, r=oli-obk
Rollup merge of rust-lang#107172 - cjgillot:no-nal, r=nagisa