Uh oh!
There was an error while loading. Please reload this page.
add subslice support in drop ladder for array - #46686
Conversation
rust-highfive
commented
Dec 12, 2017
(rust_highfive has picked a reviewer for you, use r? to override) |
mikhail-m1
commented
Dec 12, 2017
r? @arielb1 |
411c05d to
2decde6Compare| fn clear_drop_flag(&mut self, location: Location, path: Self::Path, mode: DropFlagMode); | ||
| fn get_drop_flags(&mut self, path: Self::Path) -> Option<Operand<'tcx>>; | ||
| fn clear_drop_flag(&mut self, | ||
| location: Location, path: |
There was a problem hiding this comment.
nit: path should go in the next line
There was a problem hiding this comment.
location: Location,
path: Self::Path
| fn array_subpaths(&self, path: Self::Path, size: u64) | ||
| -> Vec<(Place<'tcx>, Option<Self::Path>, Option<Local>)> { | ||
| if dataflow::move_path_children_matching(self.ctxt.move_data(), path, |_| { | ||
| assert!(size <= (u32::MAX as u64), |
There was a problem hiding this comment.
can you move the assertion out of the loop?
| } | ||
| let size = size as u32; | ||
| let flags = self.ctxt.array_items_drop_flags.get(&path); |
There was a problem hiding this comment.
nit: stray double space
flags = self.ctxt
^^
arielb1
commented
Dec 13, 2017
Do you handle the case where either individual indexes or subslices are moved out, aka: fnsubslice_pattern_test(a:&Allocator,arg:bool){let a = [a.alloc(), a.alloc(), a.alloc(), a.alloc(), a.alloc()];if arg {let[.., _x, _] = a;}else{let[_, _y..] = a;}} |
| fn drop_style(&self, path: Self::Path, mode: DropFlagMode) -> DropStyle; | ||
| fn get_drop_flag(&mut self, path: Self::Path) -> Option<Operand<'tcx>>; | ||
| fn clear_drop_flag(&mut self, location: Location, path: Self::Path, mode: DropFlagMode); | ||
| fn get_drop_flags(&mut self, path: Self::Path) -> Option<Operand<'tcx>>; |
There was a problem hiding this comment.
this still can't return multiple drop flags, so why did you rename it?
arielb1
commented
Dec 13, 2017
Another test: fnsubslice_pattern_test(a:&Allocator,arg:bool,arg2:bool){let a = [a.alloc(), a.alloc(), a.alloc(), a.alloc(), a.alloc()];if arg2 {drop(a);return;}if arg {let[.., _x, _] = a;}else{let[_, _y..] = a;}} |
| } | ||
| }; | ||
| min_length: size, | ||
| from_end: false | ||
| }), | ||
| move_path, |
There was a problem hiding this comment.
So reading this, I'm afraid that this can cause a drop to be run with a "wrong" MovePath - a Subslice when the drop can also be accessed through a ConstantIndex (or vice versa), which might cause the "unconditional" drop code to trigger when it shouldn't, as in
letmut x = [a.alloc(), a.alloc(), a.alloc()];// The MP for x[1..3] is now initialized, x[2] is now uninitializedlet[_, _, _x] = x;// this shouldn't rely on any drop flags, and just drop x[0] & x[1]
x = [a.alloc(), a.alloc(), a.alloc()];let[_, .._x] = x;// The MP for x[1..3] is now uninitialized, x[2] is now initialized// end of scope drop for x - should drop x[0] without any drop flagsThere was a problem hiding this comment.
And in some cases you might need the drop flags:
let alloc = || (a.alloc().a.alloc());letmut x = [alloc(),alloc(),alloc()];// The MP for x[1..3] is now initialized, x[2].0 is now uninitializedlet[_, _,(_x,_)] = x;// this shouldn't rely on any drop flags, and just drop x[0], x[1], and x[2].1
x = [a.alloc(), a.alloc(), a.alloc()];let[_, .._x] = x;// The MP for x[1..3] is now uninitialized, x[1].1 is now initialized// end of scope drop for x - should drop x[0] without any drop flagsSo I think you do need to generate move paths for all the array elements when you see a subslice, to have a place to focus (similarly, you want to normalize the move paths so that an access to array[-2 of 3] is the same as an access to array[1 of 3])
There was a problem hiding this comment.
At least, this is how it appears to me. There might be a better solution but it eludes me.
There was a problem hiding this comment.
I'll go back to european time and no meetings in Monday (I'm currently in the US for the Mozilla All Hands), so if you need any help I'll go on IRC then.
| }) | ||
| fn array_subpaths(&self, path: Self::Path, size: u64) | ||
| -> Vec<(Place<'tcx>, Option<Self::Path>, Option<Local>)> { | ||
| if dataflow::move_path_children_matching(self.ctxt.move_data(), path, |
There was a problem hiding this comment.
Nit: speaking as someone who doesn't know this code that well, I'd appreciate some comments here. =)
I guess that this is just a "trivial case" check, however? i.e., if we never touched any of the indices in this array, then we there is nothing to do here?
arielb1
commented
Dec 25, 2017
I don't think I can finish handling this PR. |
arielb1
commented
Dec 25, 2017
@nikomatsakis could you try to get this working with @mikhail-m1 ? |
nikomatsakis
commented
Jan 3, 2018
@arielb1@mikhail-m1 yep! |
kennytm
commented
Jan 10, 2018
Hi @mikhail-m1, just to check if you're still working on this. Looks like @arielb1 has some questions for you too! |
mikhail-m1
commented
Jan 10, 2018
Cool! I'll be sure to review your PR when you get it done. |
shepmaster
commented
Jan 26, 2018
Ping from triage @mikhail-m1! It's been over a week since we last heard from you — will you still be able to make the needed revisions? |
mikhail-m1
commented
Jan 29, 2018
@shepmaster sorry, I am still working on it but don't have enough time to finish, hope I will do it in next few days |
bors
commented
Jan 29, 2018
☔ The latest upstream changes (presumably #47837) made this pull request unmergeable. Please resolve the merge conflicts. |
…omatsakis add transform for uniform array move out reworked second step for fix#34708 previous try #46686 r? @nikomatsakis
second step for fix#34708