-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Special case deref projections in SsaVisitor.
- Loading branch information
Showing
6 changed files
with
222 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
- // MIR for `demiraw` before CopyProp | ||
+ // MIR for `demiraw` after CopyProp | ||
|
||
fn demiraw(_1: u8) -> () { | ||
debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:12: +0:17 | ||
let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:23: +0:23 | ||
let _2: *mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 | ||
let mut _4: &mut u8; // in scope 0 at $DIR/reborrow.rs:+2:22: +2:29 | ||
scope 1 { | ||
debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 | ||
let _3: &mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 | ||
scope 2 { | ||
debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 | ||
let _5: *mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 | ||
scope 4 { | ||
- debug c => _5; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 | ||
+ debug c => _2; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 | ||
} | ||
} | ||
scope 3 { | ||
} | ||
} | ||
|
||
bb0: { | ||
- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 | ||
_2 = &raw mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:23 | ||
StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 | ||
StorageLive(_4); // scope 1 at $DIR/reborrow.rs:+2:22: +2:29 | ||
_4 = &mut (*_2); // scope 3 at $DIR/reborrow.rs:+2:22: +2:29 | ||
_3 = &mut (*_4); // scope 1 at $DIR/reborrow.rs:+2:22: +2:29 | ||
StorageDead(_4); // scope 1 at $DIR/reborrow.rs:+2:31: +2:32 | ||
- StorageLive(_5); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 | ||
- _5 = _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 | ||
_0 = const (); // scope 0 at $DIR/reborrow.rs:+0:23: +4:2 | ||
- StorageDead(_5); // scope 2 at $DIR/reborrow.rs:+4:1: +4:2 | ||
StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+4:1: +4:2 | ||
- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+4:1: +4:2 | ||
return; // scope 0 at $DIR/reborrow.rs:+4:2: +4:2 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
- // MIR for `miraw` before CopyProp | ||
+ // MIR for `miraw` after CopyProp | ||
|
||
fn miraw(_1: u8) -> () { | ||
debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15 | ||
let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21 | ||
let _2: *mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 | ||
scope 1 { | ||
debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 | ||
let _3: *mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 | ||
scope 2 { | ||
debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 | ||
let _4: *mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 | ||
scope 4 { | ||
- debug c => _4; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 | ||
+ debug c => _2; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 | ||
} | ||
} | ||
scope 3 { | ||
} | ||
} | ||
|
||
bb0: { | ||
- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 | ||
_2 = &raw mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:23 | ||
StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 | ||
_3 = &raw mut (*_2); // scope 3 at $DIR/reborrow.rs:+2:22: +2:33 | ||
- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 | ||
- _4 = _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 | ||
_0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +4:2 | ||
- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+4:1: +4:2 | ||
StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+4:1: +4:2 | ||
- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+4:1: +4:2 | ||
return; // scope 0 at $DIR/reborrow.rs:+4:2: +4:2 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
- // MIR for `remut` before CopyProp | ||
+ // MIR for `remut` after CopyProp | ||
|
||
fn remut(_1: u8) -> () { | ||
debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15 | ||
let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21 | ||
let _2: &mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 | ||
scope 1 { | ||
debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 | ||
let _3: &mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 | ||
scope 2 { | ||
debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 | ||
let _4: &mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 | ||
scope 3 { | ||
- debug c => _4; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 | ||
+ debug c => _2; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 | ||
} | ||
} | ||
} | ||
|
||
bb0: { | ||
- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 | ||
_2 = &mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:19 | ||
StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 | ||
_3 = &mut (*_2); // scope 1 at $DIR/reborrow.rs:+2:13: +2:20 | ||
- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 | ||
- _4 = move _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 | ||
_0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +4:2 | ||
- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+4:1: +4:2 | ||
StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+4:1: +4:2 | ||
- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+4:1: +4:2 | ||
return; // scope 0 at $DIR/reborrow.rs:+4:2: +4:2 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
- // MIR for `reraw` before CopyProp | ||
+ // MIR for `reraw` after CopyProp | ||
|
||
fn reraw(_1: u8) -> () { | ||
debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15 | ||
let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21 | ||
let _2: &mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 | ||
scope 1 { | ||
debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 | ||
let _3: *mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 | ||
scope 2 { | ||
debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 | ||
let _4: &mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 | ||
scope 3 { | ||
- debug c => _4; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 | ||
+ debug c => _2; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 | ||
} | ||
} | ||
} | ||
|
||
bb0: { | ||
- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 | ||
_2 = &mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:19 | ||
StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 | ||
_3 = &raw mut (*_2); // scope 1 at $DIR/reborrow.rs:+2:13: +2:24 | ||
- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 | ||
- _4 = move _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 | ||
_0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +4:2 | ||
- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+4:1: +4:2 | ||
StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+4:1: +4:2 | ||
- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+4:1: +4:2 | ||
return; // scope 0 at $DIR/reborrow.rs:+4:2: +4:2 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Check that CopyProp considers reborrows as not mutating the pointer. | ||
// unit-test: CopyProp | ||
|
||
#![feature(raw_ref_op)] | ||
|
||
// EMIT_MIR reborrow.remut.CopyProp.diff | ||
fn remut(mut x: u8) { | ||
let a = &mut x; | ||
let b = &mut *a; //< this cannot mutate a. | ||
let c = a; //< so `c` and `a` can be merged. | ||
} | ||
|
||
// EMIT_MIR reborrow.reraw.CopyProp.diff | ||
fn reraw(mut x: u8) { | ||
let a = &mut x; | ||
let b = &raw mut *a; //< this cannot mutate a. | ||
let c = a; //< so `c` and `a` can be merged. | ||
} | ||
|
||
// EMIT_MIR reborrow.miraw.CopyProp.diff | ||
fn miraw(mut x: u8) { | ||
let a = &raw mut x; | ||
let b = unsafe { &raw mut *a }; //< this cannot mutate a. | ||
let c = a; //< so `c` and `a` can be merged. | ||
} | ||
|
||
// EMIT_MIR reborrow.demiraw.CopyProp.diff | ||
fn demiraw(mut x: u8) { | ||
let a = &raw mut x; | ||
let b = unsafe { &mut *a }; //< this cannot mutate a. | ||
let c = a; //< so `c` and `a` can be merged. | ||
} | ||
|
||
fn main() { | ||
remut(0); | ||
reraw(0); | ||
miraw(0); | ||
demiraw(0); | ||
} |