Merge borrowed locals too.
This commit is contained in:
parent
308cc76510
commit
73db12a223
5 changed files with 85 additions and 113 deletions
|
@ -111,7 +111,10 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
|
|||
|
||||
fn visit_local(&mut self, local: &mut Local, ctxt: PlaceContext, _: Location) {
|
||||
let new_local = self.copy_classes[*local];
|
||||
if self.borrowed_locals.contains(*local) || self.borrowed_locals.contains(new_local) {
|
||||
// We must not unify two locals that are borrowed. But this is fine if one is borrowed and
|
||||
// the other is not. We chose to check the original local, and not the target. That way, if
|
||||
// the original local is borrowed and the target is not, we do not pessimize the whole class.
|
||||
if self.borrowed_locals.contains(*local) {
|
||||
return;
|
||||
}
|
||||
match ctxt {
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
let mut _3: &u32;
|
||||
|
||||
bb0: {
|
||||
_2 = _1;
|
||||
- _2 = _1;
|
||||
_3 = &_1;
|
||||
_0 = opaque::<&u32>(_3) -> [return: bb1, unwind unreachable];
|
||||
}
|
||||
|
||||
bb1: {
|
||||
_0 = opaque::<u32>(_2) -> [return: bb2, unwind unreachable];
|
||||
- _0 = opaque::<u32>(_2) -> [return: bb2, unwind unreachable];
|
||||
+ _0 = opaque::<u32>(_1) -> [return: bb2, unwind unreachable];
|
||||
}
|
||||
|
||||
bb2: {
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
let mut _3: &u32;
|
||||
|
||||
bb0: {
|
||||
_2 = _1;
|
||||
- _2 = _1;
|
||||
_3 = &_1;
|
||||
_0 = opaque::<&u32>(_3) -> [return: bb1, unwind continue];
|
||||
}
|
||||
|
||||
bb1: {
|
||||
_0 = opaque::<u32>(_2) -> [return: bb2, unwind continue];
|
||||
- _0 = opaque::<u32>(_2) -> [return: bb2, unwind continue];
|
||||
+ _0 = opaque::<u32>(_1) -> [return: bb2, unwind continue];
|
||||
}
|
||||
|
||||
bb2: {
|
||||
|
|
|
@ -46,11 +46,10 @@ fn compare_address() -> bool {
|
|||
fn borrowed(x: u32) -> bool {
|
||||
// CHECK-LABEL: fn borrowed(
|
||||
// CHECK: bb0: {
|
||||
// CHECK-NEXT: _2 = _1;
|
||||
// CHECK-NEXT: _3 = &_1;
|
||||
// CHECK-NEXT: _0 = opaque::<&u32>(_3)
|
||||
// CHECK: bb1: {
|
||||
// CHECK-NEXT: _0 = opaque::<u32>(_2)
|
||||
// CHECK-NEXT: _0 = opaque::<u32>(_1)
|
||||
mir!(
|
||||
{
|
||||
let a = x;
|
||||
|
|
|
@ -10,18 +10,18 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2
|
|||
let mut _8: &&usize;
|
||||
let _9: &usize;
|
||||
let mut _10: &&usize;
|
||||
let mut _15: bool;
|
||||
let mut _13: bool;
|
||||
let mut _14: &&usize;
|
||||
let _15: &usize;
|
||||
let mut _16: &&usize;
|
||||
let _17: &usize;
|
||||
let mut _18: &&usize;
|
||||
let mut _19: bool;
|
||||
let mut _20: &&usize;
|
||||
let _21: &usize;
|
||||
let mut _22: &&usize;
|
||||
let mut _23: bool;
|
||||
let mut _24: &&usize;
|
||||
let _25: &usize;
|
||||
let mut _26: &&usize;
|
||||
let mut _29: bool;
|
||||
let mut _30: &&usize;
|
||||
let _31: &usize;
|
||||
let mut _32: &&usize;
|
||||
scope 1 {
|
||||
debug a => _4;
|
||||
debug b => _5;
|
||||
|
@ -30,47 +30,39 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2
|
|||
scope 2 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) {
|
||||
debug self => _8;
|
||||
debug other => _10;
|
||||
let mut _11: &usize;
|
||||
let mut _12: &usize;
|
||||
scope 3 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) {
|
||||
debug self => _11;
|
||||
debug other => _12;
|
||||
let mut _13: usize;
|
||||
let mut _14: usize;
|
||||
debug self => _4;
|
||||
debug other => _9;
|
||||
let mut _11: usize;
|
||||
let mut _12: usize;
|
||||
}
|
||||
}
|
||||
scope 4 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) {
|
||||
debug self => _16;
|
||||
debug other => _18;
|
||||
let mut _19: &usize;
|
||||
let mut _20: &usize;
|
||||
debug self => _14;
|
||||
debug other => _16;
|
||||
scope 5 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) {
|
||||
debug self => _19;
|
||||
debug other => _20;
|
||||
let mut _21: usize;
|
||||
let mut _22: usize;
|
||||
debug self => _7;
|
||||
debug other => _15;
|
||||
let mut _17: usize;
|
||||
let mut _18: usize;
|
||||
}
|
||||
}
|
||||
scope 6 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) {
|
||||
debug self => _24;
|
||||
debug other => _26;
|
||||
let mut _27: &usize;
|
||||
let mut _28: &usize;
|
||||
debug self => _20;
|
||||
debug other => _22;
|
||||
scope 7 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) {
|
||||
debug self => _27;
|
||||
debug other => _28;
|
||||
debug self => _6;
|
||||
debug other => _21;
|
||||
}
|
||||
}
|
||||
scope 8 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) {
|
||||
debug self => _30;
|
||||
debug other => _32;
|
||||
let mut _33: &usize;
|
||||
let mut _34: &usize;
|
||||
debug self => _24;
|
||||
debug other => _26;
|
||||
scope 9 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) {
|
||||
debug self => _33;
|
||||
debug other => _34;
|
||||
let mut _35: usize;
|
||||
let mut _36: usize;
|
||||
debug self => _5;
|
||||
debug other => _25;
|
||||
let mut _27: usize;
|
||||
let mut _28: usize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,22 +73,16 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2
|
|||
_5 = &((*_3).1: usize);
|
||||
_6 = &((*_3).2: usize);
|
||||
_7 = &((*_3).3: usize);
|
||||
StorageLive(_15);
|
||||
StorageLive(_13);
|
||||
StorageLive(_8);
|
||||
_8 = &_4;
|
||||
StorageLive(_10);
|
||||
_9 = &((*_3).2: usize);
|
||||
_10 = &_9;
|
||||
StorageLive(_11);
|
||||
StorageLive(_12);
|
||||
_11 = _4;
|
||||
_12 = _9;
|
||||
_13 = ((*_3).0: usize);
|
||||
_14 = ((*_3).2: usize);
|
||||
_15 = Le(_13, _14);
|
||||
StorageDead(_12);
|
||||
StorageDead(_11);
|
||||
switchInt(move _15) -> [0: bb1, otherwise: bb2];
|
||||
_11 = ((*_3).0: usize);
|
||||
_12 = ((*_3).2: usize);
|
||||
_13 = Le(_11, _12);
|
||||
switchInt(move _13) -> [0: bb1, otherwise: bb2];
|
||||
}
|
||||
|
||||
bb1: {
|
||||
|
@ -108,99 +94,81 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2
|
|||
bb2: {
|
||||
StorageDead(_10);
|
||||
StorageDead(_8);
|
||||
StorageLive(_23);
|
||||
StorageLive(_16);
|
||||
_16 = &_7;
|
||||
StorageLive(_18);
|
||||
_17 = &((*_3).1: usize);
|
||||
_18 = &_17;
|
||||
StorageLive(_19);
|
||||
StorageLive(_20);
|
||||
_19 = _7;
|
||||
_20 = _17;
|
||||
StorageLive(_21);
|
||||
_21 = ((*_3).3: usize);
|
||||
StorageLive(_22);
|
||||
_22 = ((*_3).1: usize);
|
||||
_23 = Le(move _21, move _22);
|
||||
StorageDead(_22);
|
||||
StorageDead(_21);
|
||||
StorageDead(_20);
|
||||
StorageDead(_19);
|
||||
switchInt(move _23) -> [0: bb3, otherwise: bb8];
|
||||
StorageLive(_14);
|
||||
_14 = &_7;
|
||||
StorageLive(_16);
|
||||
_15 = &((*_3).1: usize);
|
||||
_16 = &_15;
|
||||
StorageLive(_17);
|
||||
_17 = ((*_3).3: usize);
|
||||
StorageLive(_18);
|
||||
_18 = ((*_3).1: usize);
|
||||
_19 = Le(move _17, move _18);
|
||||
StorageDead(_18);
|
||||
StorageDead(_17);
|
||||
switchInt(move _19) -> [0: bb3, otherwise: bb8];
|
||||
}
|
||||
|
||||
bb3: {
|
||||
StorageDead(_18);
|
||||
StorageDead(_16);
|
||||
StorageDead(_14);
|
||||
goto -> bb4;
|
||||
}
|
||||
|
||||
bb4: {
|
||||
StorageLive(_29);
|
||||
StorageLive(_24);
|
||||
_24 = &_6;
|
||||
StorageLive(_26);
|
||||
_25 = &((*_3).0: usize);
|
||||
_26 = &_25;
|
||||
StorageLive(_27);
|
||||
StorageLive(_28);
|
||||
_27 = _6;
|
||||
_28 = _25;
|
||||
_29 = Le(_14, _13);
|
||||
StorageDead(_28);
|
||||
StorageDead(_27);
|
||||
switchInt(move _29) -> [0: bb5, otherwise: bb6];
|
||||
StorageLive(_23);
|
||||
StorageLive(_20);
|
||||
_20 = &_6;
|
||||
StorageLive(_22);
|
||||
_21 = &((*_3).0: usize);
|
||||
_22 = &_21;
|
||||
_23 = Le(_12, _11);
|
||||
switchInt(move _23) -> [0: bb5, otherwise: bb6];
|
||||
}
|
||||
|
||||
bb5: {
|
||||
StorageDead(_26);
|
||||
StorageDead(_24);
|
||||
StorageDead(_22);
|
||||
StorageDead(_20);
|
||||
_0 = const false;
|
||||
goto -> bb7;
|
||||
}
|
||||
|
||||
bb6: {
|
||||
StorageDead(_22);
|
||||
StorageDead(_20);
|
||||
StorageLive(_24);
|
||||
_24 = &_5;
|
||||
StorageLive(_26);
|
||||
_25 = &((*_3).3: usize);
|
||||
_26 = &_25;
|
||||
StorageLive(_27);
|
||||
_27 = ((*_3).1: usize);
|
||||
StorageLive(_28);
|
||||
_28 = ((*_3).3: usize);
|
||||
_0 = Le(move _27, move _28);
|
||||
StorageDead(_28);
|
||||
StorageDead(_27);
|
||||
StorageDead(_26);
|
||||
StorageDead(_24);
|
||||
StorageLive(_30);
|
||||
_30 = &_5;
|
||||
StorageLive(_32);
|
||||
_31 = &((*_3).3: usize);
|
||||
_32 = &_31;
|
||||
StorageLive(_33);
|
||||
StorageLive(_34);
|
||||
_33 = _5;
|
||||
_34 = _31;
|
||||
StorageLive(_35);
|
||||
_35 = ((*_3).1: usize);
|
||||
StorageLive(_36);
|
||||
_36 = ((*_3).3: usize);
|
||||
_0 = Le(move _35, move _36);
|
||||
StorageDead(_36);
|
||||
StorageDead(_35);
|
||||
StorageDead(_34);
|
||||
StorageDead(_33);
|
||||
StorageDead(_32);
|
||||
StorageDead(_30);
|
||||
goto -> bb7;
|
||||
}
|
||||
|
||||
bb7: {
|
||||
StorageDead(_29);
|
||||
StorageDead(_23);
|
||||
goto -> bb9;
|
||||
}
|
||||
|
||||
bb8: {
|
||||
StorageDead(_18);
|
||||
StorageDead(_16);
|
||||
StorageDead(_14);
|
||||
_0 = const true;
|
||||
goto -> bb9;
|
||||
}
|
||||
|
||||
bb9: {
|
||||
StorageDead(_23);
|
||||
StorageDead(_15);
|
||||
StorageDead(_19);
|
||||
StorageDead(_13);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue