8000 Rollup of 7 pull requests by Mark-Simulacrum · Pull Request #67384 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 7 pull requests #67384

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3980342
Use structured suggestion for disambiguating method calls
estebank Dec 4, 2019
8c4f1d5
review comments
estebank Dec 12, 2019
6c7c512
Fix the configure.py TOML field for a couple LLVM options
cuviper Dec 13, 2019
094177e
Add Rvalue::AddressOf to MIR
matthewjasper Dec 23, 2018
12f3e24
Start generating AddressOf rvalues in MIR
matthewjasper Apr 20, 2019
623aa82
Make slice drop shims use AddressOf
matthewjasper Apr 20, 2019
e57096d
Add mir opt test for AddressOf
matthewjasper Apr 20, 2019
6f6b372
Check const-propagation of borrows of unsized places
matthewjasper Sep 17, 2019
5eb17c3
Update test now that reference to pointer casts have more checks
matthewjasper Sep 17, 2019
3594d8b
make htons const fn
tesuji Dec 15, 2019
68fed49
Add more tests for raw_ref_op
matthewjasper Sep 18, 2019
f9f85b1
Fix comment ordering
matthewjasper Dec 2, 2019
f365dbc
Set release channel on non-dist builders
Mark-Simulacrum Dec 16, 2019
985127c
Implement `finish_non_exhaustive` for `DebugStruct`.
richard-uk1 Nov 24, 2019
7f00a5f
Revert "Auto merge of #67362 - Mark-Simulacrum:par-4-default, r=alexc…
Mark-Simulacrum Dec 17, 2019
a50f440
Rollup merge of #64588 - matthewjasper:mir-address-of, r=oli-obk
Mark-Simulacrum Dec 18, 2019
624694d
Rollup merge of #66716 - derekdreery:debug_non_exhaustive, r=dtolnay
Mark-Simulacrum Dec 18, 2019
67d560b
Rollup merge of #67127 - estebank:disambiguate-suggestion, r=varkor
Mark-Simulacrum Dec 18, 2019
743869b
Rollup merge of #67286 - cuviper:configure-llvm, r=Dylan-DPC
Mark-Simulacrum Dec 18, 2019
8c05bb6
Rollup merge of #67321 - lzutao:htons, r=dtolnay
Mark-Simulacrum Dec 18, 2019
c31110d
Rollup merge of #67351 - Mark-Simulacrum:always-channel, r=pietroalbini
Mark-Simulacrum Dec 18, 2019
2e6b327
Rollup merge of #67379 - Mark-Simulacrum:revert-par-4-default, r=Mark…
Mark-Simulacrum Dec 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make slice drop shims use AddressOf
  • Loading branch information
matthewjasper committed Dec 14, 2019
commit 623aa829f99338e14a7de4fb89a916f6cef7bf1a
61 changes: 23 additions & 38 deletions src/librustc_mir/util/elaborate_drops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,10 @@ where
/// if can_go then succ else drop-block
/// drop-block:
/// if ptr_based {
/// ptr = &mut *cur
/// ptr = cur
/// cur = cur.offset(1)
/// } else {
/// ptr = &mut P[cur]
/// ptr = &raw mut P[cur]
/// cur = cur + 1
/// }
/// drop(ptr)
Expand All @@ -574,34 +574,28 @@ where
unwind: Unwind,
ptr_based: bool,
) -> BasicBlock {
let copy = |place: &Place<'tcx>| Operand::Copy(place.clone());
let move_ = |place: &Place<'tcx>| Operand::Move(place.clone());
let copy = |place: Place<'tcx>| Operand::Copy(place);
let move_ = |place: Place<'tcx>| Operand::Move(place);
let tcx = self.tcx();

let ref_ty = tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut {
let ptr_ty = tcx.mk_ptr(ty::TypeAndMut {
ty: ety,
mutbl: hir::Mutability::Mutable
});
let ptr = &Place::from(self.new_temp(ref_ty));
let can_go = &Place::from(self.new_temp(tcx.types.bool));
let ptr = &Place::from(self.new_temp(ptr_ty));
let can_go = Place::from(self.new_temp(tcx.types.bool));

let one = self.constant_usize(1);
let (ptr_next, cur_next) = if ptr_based {
(Rvalue::Ref(
tcx.lifetimes.re_erased,
BorrowKind::Mut { allow_two_phase_borrow: false },
Place {
base: PlaceBase::Local(cur),
projection: tcx.intern_place_elems(&vec![ProjectionElem::Deref]),
}
),
Rvalue::BinaryOp(BinOp::Offset, move_(&Place::from(cur)), one))
(
Rvalue::Use(copy(cur.into())),
Rvalue::BinaryOp(BinOp::Offset, move_(cur.into()), one),
)
} else {
(Rvalue::Ref(
tcx.lifetimes.re_erased,
BorrowKind::Mut { allow_two_phase_borrow: false },
tcx.mk_place_index(self.place.clone(), cur)),
Rvalue::BinaryOp(BinOp::Add, move_(&Place::from(cur)), one))
(
Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place.clone(), cur)),
Rvalue::BinaryOp(BinOp::Add, move_(cur.into()), one),
)
};

let drop_block = BasicBlockData {
Expand All @@ -620,9 +614,9 @@ where

let loop_block = BasicBlockData {
statements: vec![
self.assign(can_go, Rvalue::BinaryOp(BinOp::Eq,
copy(&Place::from(cur)),
copy(length_or_end)))
self.assign(&can_go, Rvalue::BinaryOp(BinOp::Eq,
copy(Place::from(cur)),
copy(length_or_end.clone())))
],
is_cleanup: unwind.is_cleanup(),
terminator: Some(Terminator {
Expand Down Expand Up @@ -725,8 +719,6 @@ where

let cur = self.new_temp(iter_ty);
let length_or_end = if ptr_based {
// FIXME check if we want to make it return a `Place` directly
// if all use sites want a `Place::Base` anyway.
Place::from(self.new_temp(iter_ty))
} else {
length.clone()
Expand All @@ -753,23 +745,16 @@ where
let drop_block_stmts = if ptr_based {
let tmp_ty = tcx.mk_mut_ptr(self.place_ty(self.place));
let tmp = Place::from(self.new_temp(tmp_ty));
// tmp = &mut P;
// tmp = &raw mut P;
// cur = tmp as *mut T;
// end = Offset(cur, len);
vec![
self.assign(&tmp, Rvalue::Ref(
tcx.lifetimes.re_erased,
BorrowKind::Mut { allow_two_phase_borrow: false },
self.place.clone()
)),
self.assign(
&cur,
Rvalue::Cast(CastKind::Misc, Operand::Move(tmp), iter_ty),
),
self.assign(&tmp, Rvalue::AddressOf(Mutability::Mut, self.place.clone())),
self.assign(&cur, Rvalue::Cast(CastKind::Misc, Operand::Move(tmp), iter_ty)),
self.assign(
&length_or_end,
Rvalue::BinaryOp(BinOp::Offset, Operand::Copy(cur), Operand::Move(length)
)),
Rvalue::BinaryOp(BinOp::Offset, Operand::Copy(cur), Operand::Move(length)),
),
]
} else {
// cur = 0 (length already pushed)
Expand Down
18 changes: 9 additions & 9 deletions src/test/mir-opt/slice-drop-shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ fn main() {
// let mut _2: usize;
// let mut _3: usize;
// let mut _4: usize;
// let mut _5: &mut std::string::String;
// let mut _5: *mut std::string::String;
// let mut _6: bool;
// let mut _7: &mut std::string::String;
// let mut _7: *mut std::string::String;
// let mut _8: bool;
// let mut _9: *mut std::string::String;
// let mut _10: *mut std::string::String;
// let mut _11: &mut std::string::String;
// let mut _11: *mut std::string::String;
// let mut _12: bool;
// let mut _13: &mut std::string::String;
// let mut _13: *mut std::string::String;
// let mut _14: bool;
// let mut _15: *mut [std::string::String];
// bb0: {
Expand All @@ -31,7 +31,7 @@ fn main() {
// resume;
// }
// bb3 (cleanup): {
// _5 = &mut (*_1)[_4];
// _5 = &raw mut (*_1)[_4];
// _4 = Add(move _4, const 1usize);
// drop((*_5)) -> bb4;
// }
Expand All @@ -40,7 +40,7 @@ fn main() {
// switchInt(move _6) -> [false: bb3, otherwise: bb2];
// }
// bb5: {
// _7 = &mut (*_1)[_4];
// _7 = &raw mut (*_1)[_4];
// _4 = Add(move _4, const 1usize);
// drop((*_7)) -> [return: bb6, unwind: bb4];
// }
Expand All @@ -56,7 +56,7 @@ fn main() {
// goto -> bb7;
// }
// bb9 (cleanup): {
// _11 = &mut (*_9);
// _11 = _9;
// _9 = Offset(move _9, const 1usize);
// drop((*_11)) -> bb10;
// }
Expand All @@ -65,7 +65,7 @@ fn main() {
// switchInt(move _12) -> [false: bb9, otherwise: bb2];
// }
// bb11: {
// _13 = &mut (*_9);
// _13 = _9;
// _9 = Offset(move _9, const 1usize);
// drop((*_13)) -> [return: bb12, unwind: bb10];
// }
Expand All @@ -74,7 +74,7 @@ fn main() {
// switchInt(move _14) -> [false: bb11, otherwise: bb1];
// }
// bb13: {
// _15 = &mut (*_1);
// _15 = &raw mut (*_1);
// _9 = move _15 as *mut std::string::String (Misc);
// _10 = Offset(_9, move _3);
// goto -> bb12;
Expand Down
0