-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Split dead store elimination off dest prop #97158
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
Merged
+732
−364
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
148 changes: 148 additions & 0 deletions
148
compiler/rustc_mir_transform/src/dead_store_elimination.rs
This file contains hidden or 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,148 @@ | ||
//! This module implements a dead store elimination (DSE) routine. | ||
//! | ||
//! This transformation was written specifically for the needs of dest prop. Although it is | ||
//! perfectly sound to use it in any context that might need it, its behavior should not be changed | ||
//! without analyzing the interaction this will have with dest prop. Specifically, in addition to | ||
//! the soundness of this pass in general, dest prop needs it to satisfy two additional conditions: | ||
//! | ||
//! 1. It's idempotent, meaning that running this pass a second time immediately after running it a | ||
//! first time will not cause any further changes. | ||
//! 2. This idempotence persists across dest prop's main transform, in other words inserting any | ||
//! number of iterations of dest prop between the first and second application of this transform | ||
//! will still not cause any further changes. | ||
//! | ||
use rustc_index::bit_set::BitSet; | ||
use rustc_middle::{ | ||
mir::{visit::Visitor, *}, | ||
ty::TyCtxt, | ||
}; | ||
use rustc_mir_dataflow::{impls::MaybeTransitiveLiveLocals, Analysis}; | ||
|
||
/// Performs the optimization on the body | ||
/// | ||
/// The `borrowed` set must be a `BitSet` of all the locals that are ever borrowed in this body. It | ||
/// can be generated via the [`get_borrowed_locals`] function. | ||
pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, borrowed: &BitSet<Local>) { | ||
let mut live = MaybeTransitiveLiveLocals::new(borrowed, &body.local_decls, tcx) | ||
.into_engine(tcx, body) | ||
.iterate_to_fixpoint() | ||
.into_results_cursor(body); | ||
|
||
let mut patch = Vec::new(); | ||
for (bb, bb_data) in traversal::preorder(body) { | ||
for (statement_index, statement) in bb_data.statements.iter().enumerate().rev() { | ||
let loc = Location { block: bb, statement_index }; | ||
if let StatementKind::Assign(assign) = &statement.kind { | ||
if assign.1.is_pointer_int_cast(&body.local_decls, tcx) { | ||
continue; | ||
} | ||
} | ||
match &statement.kind { | ||
StatementKind::Assign(box (place, _)) | ||
| StatementKind::SetDiscriminant { place: box place, .. } | ||
| StatementKind::Deinit(box place) => { | ||
if !place.is_indirect() && !borrowed.contains(place.local) { | ||
live.seek_before_primary_effect(loc); | ||
if !live.get().contains(place.local) { | ||
patch.push(loc); | ||
} | ||
} | ||
} | ||
StatementKind::Retag(_, _) | ||
| StatementKind::StorageLive(_) | ||
| StatementKind::StorageDead(_) | ||
| StatementKind::Coverage(_) | ||
| StatementKind::CopyNonOverlapping(_) | ||
| StatementKind::Nop => (), | ||
|
||
StatementKind::FakeRead(_) | StatementKind::AscribeUserType(_, _) => { | ||
bug!("{:?} not found in this MIR phase!", &statement.kind) | ||
} | ||
} | ||
} | ||
} | ||
|
||
if patch.is_empty() { | ||
return; | ||
} | ||
|
||
let bbs = body.basic_blocks_mut(); | ||
JakobDegen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for Location { block, statement_index } in patch { | ||
bbs[block].statements[statement_index].make_nop(); | ||
} | ||
} | ||
|
||
pub fn get_borrowed_locals(body: &Body<'_>) -> BitSet<Local> { | ||
let mut b = BorrowedLocals(BitSet::new_empty(body.local_decls.len())); | ||
b.visit_body(body); | ||
b.0 | ||
} | ||
|
||
struct BorrowedLocals(BitSet<Local>); | ||
|
||
impl<'tcx> Visitor<'tcx> for BorrowedLocals { | ||
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, loc: Location) { | ||
self.super_rvalue(rvalue, loc); | ||
match rvalue { | ||
Rvalue::AddressOf(_, borrowed_place) | Rvalue::Ref(_, _, borrowed_place) => { | ||
if !borrowed_place.is_indirect() { | ||
self.0.insert(borrowed_place.local); | ||
} | ||
} | ||
|
||
Rvalue::Cast(..) | ||
| Rvalue::ShallowInitBox(..) | ||
| Rvalue::Use(..) | ||
| Rvalue::Repeat(..) | ||
| Rvalue::Len(..) | ||
| Rvalue::BinaryOp(..) | ||
| Rvalue::CheckedBinaryOp(..) | ||
| Rvalue::NullaryOp(..) | ||
| Rvalue::UnaryOp(..) | ||
| Rvalue::Discriminant(..) | ||
| Rvalue::Aggregate(..) | ||
| Rvalue::ThreadLocalRef(..) => {} | ||
} | ||
} | ||
|
||
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { | ||
self.super_terminator(terminator, location); | ||
|
||
match terminator.kind { | ||
TerminatorKind::Drop { place: dropped_place, .. } => { | ||
if !dropped_place.is_indirect() { | ||
self.0.insert(dropped_place.local); | ||
} | ||
} | ||
|
||
TerminatorKind::Abort | ||
| TerminatorKind::DropAndReplace { .. } | ||
| TerminatorKind::Assert { .. } | ||
| TerminatorKind::Call { .. } | ||
| TerminatorKind::FalseEdge { .. } | ||
| TerminatorKind::FalseUnwind { .. } | ||
| TerminatorKind::GeneratorDrop | ||
| TerminatorKind::Goto { .. } | ||
| TerminatorKind::Resume | ||
| TerminatorKind::Return | ||
| TerminatorKind::SwitchInt { .. } | ||
| TerminatorKind::Unreachable | ||
| TerminatorKind::Yield { .. } | ||
| TerminatorKind::InlineAsm { .. } => {} | ||
} | ||
} | ||
} | ||
|
||
pub struct DeadStoreElimination; | ||
|
||
impl<'tcx> MirPass<'tcx> for DeadStoreElimination { | ||
fn is_enabled(&self, sess: &rustc_session::Session) -> bool { | ||
sess.mir_opt_level() >= 2 | ||
} | ||
|
||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { | ||
let borrowed = get_borrowed_locals(body); | ||
eliminate(tcx, body, &borrowed); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
75 changes: 75 additions & 0 deletions
75
src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff
This file contains hidden or 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,75 @@ | ||
- // MIR for `cycle` before DeadStoreElimination | ||
+ // MIR for `cycle` after DeadStoreElimination | ||
|
||
fn cycle(_1: i32, _2: i32, _3: i32) -> () { | ||
debug x => _1; // in scope 0 at $DIR/cycle.rs:9:10: 9:15 | ||
debug y => _2; // in scope 0 at $DIR/cycle.rs:9:22: 9:27 | ||
debug z => _3; // in scope 0 at $DIR/cycle.rs:9:34: 9:39 | ||
let mut _0: (); // return place in scope 0 at $DIR/cycle.rs:9:46: 9:46 | ||
let mut _4: (); // in scope 0 at $DIR/cycle.rs:9:1: 18:2 | ||
let mut _5: bool; // in scope 0 at $DIR/cycle.rs:12:11: 12:17 | ||
let _6: i32; // in scope 0 at $DIR/cycle.rs:13:13: 13:17 | ||
let mut _7: i32; // in scope 0 at $DIR/cycle.rs:14:13: 14:14 | ||
let mut _8: i32; // in scope 0 at $DIR/cycle.rs:15:13: 15:14 | ||
let mut _9: i32; // in scope 0 at $DIR/cycle.rs:16:13: 16:17 | ||
let mut _10: !; // in scope 0 at $DIR/cycle.rs:12:5: 17:6 | ||
let _11: (); // in scope 0 at $DIR/cycle.rs:12:5: 17:6 | ||
let mut _12: !; // in scope 0 at $DIR/cycle.rs:12:5: 17:6 | ||
scope 1 { | ||
debug temp => _6; // in scope 1 at $DIR/cycle.rs:13:13: 13:17 | ||
} | ||
|
||
bb0: { | ||
goto -> bb1; // scope 0 at $DIR/cycle.rs:12:5: 17:6 | ||
} | ||
|
||
bb1: { | ||
StorageLive(_5); // scope 0 at $DIR/cycle.rs:12:11: 12:17 | ||
_5 = cond() -> bb2; // scope 0 at $DIR/cycle.rs:12:11: 12:17 | ||
// mir::Constant | ||
// + span: $DIR/cycle.rs:12:11: 12:15 | ||
// + literal: Const { ty: fn() -> bool {cond}, val: Value(Scalar(<ZST>)) } | ||
} | ||
|
||
bb2: { | ||
switchInt(move _5) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/cycle.rs:12:11: 12:17 | ||
} | ||
|
||
bb3: { | ||
StorageLive(_6); // scope 0 at $DIR/cycle.rs:13:13: 13:17 | ||
- _6 = _3; // scope 0 at $DIR/cycle.rs:13:20: 13:21 | ||
+ nop; // scope 0 at $DIR/cycle.rs:13:20: 13:21 | ||
StorageLive(_7); // scope 1 at $DIR/cycle.rs:14:13: 14:14 | ||
- _7 = _2; // scope 1 at $DIR/cycle.rs:14:13: 14:14 | ||
- _3 = move _7; // scope 1 at $DIR/cycle.rs:14:9: 14:14 | ||
+ nop; // scope 1 at $DIR/cycle.rs:14:13: 14:14 | ||
+ nop; // scope 1 at $DIR/cycle.rs:14:9: 14:14 | ||
StorageDead(_7); // scope 1 at $DIR/cycle.rs:14:13: 14:14 | ||
StorageLive(_8); // scope 1 at $DIR/cycle.rs:15:13: 15:14 | ||
- _8 = _1; // scope 1 at $DIR/cycle.rs:15:13: 15:14 | ||
- _2 = move _8; // scope 1 at $DIR/cycle.rs:15:9: 15:14 | ||
+ nop; // scope 1 at $DIR/cycle.rs:15:13: 15:14 | ||
+ nop; // scope 1 at $DIR/cycle.rs:15:9: 15:14 | ||
StorageDead(_8); // scope 1 at $DIR/cycle.rs:15:13: 15:14 | ||
StorageLive(_9); // scope 1 at $DIR/cycle.rs:16:13: 16:17 | ||
- _9 = _6; // scope 1 at $DIR/cycle.rs:16:13: 16:17 | ||
- _1 = move _9; // scope 1 at $DIR/cycle.rs:16:9: 16:17 | ||
+ nop; // scope 1 at $DIR/cycle.rs:16:13: 16:17 | ||
+ nop; // scope 1 at $DIR/cycle.rs:16:9: 16:17 | ||
StorageDead(_9); // scope 1 at $DIR/cycle.rs:16:16: 16:17 | ||
- _4 = const (); // scope 0 at $DIR/cycle.rs:12:18: 17:6 | ||
+ nop; // scope 0 at $DIR/cycle.rs:12:18: 17:6 | ||
StorageDead(_6); // scope 0 at $DIR/cycle.rs:17:5: 17:6 | ||
StorageDead(_5); // scope 0 at $DIR/cycle.rs:17:5: 17:6 | ||
goto -> bb1; // scope 0 at $DIR/cycle.rs:12:5: 17:6 | ||
} | ||
|
||
bb4: { | ||
StorageLive(_11); // scope 0 at $DIR/cycle.rs:12:5: 17:6 | ||
_0 = const (); // scope 0 at $DIR/cycle.rs:12:5: 17:6 | ||
StorageDead(_11); // scope 0 at $DIR/cycle.rs:17:5: 17:6 | ||
StorageDead(_5); // scope 0 at $DIR/cycle.rs:17:5: 17:6 | ||
return; // scope 0 at $DIR/cycle.rs:18:2: 18:2 | ||
} | ||
} | ||
|
This file contains hidden or 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,22 @@ | ||
// unit-test: DeadStoreElimination | ||
|
||
#[inline(never)] | ||
fn cond() -> bool { | ||
false | ||
} | ||
|
||
// EMIT_MIR cycle.cycle.DeadStoreElimination.diff | ||
fn cycle(mut x: i32, mut y: i32, mut z: i32) { | ||
// This example is interesting because the non-transitive version of `MaybeLiveLocals` would | ||
// report that *all* of these stores are live. | ||
while cond() { | ||
let temp = z; | ||
z = y; | ||
y = x; | ||
x = temp; | ||
} | ||
} | ||
|
||
fn main() { | ||
cycle(1, 2, 3); | ||
} |
35 changes: 35 additions & 0 deletions
35
...-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff
This file contains hidden or 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 `pointer_to_int` before DeadStoreElimination | ||
+ // MIR for `pointer_to_int` after DeadStoreElimination | ||
|
||
fn pointer_to_int(_1: *mut i32) -> () { | ||
debug p => _1; // in scope 0 at $DIR/provenance_soundness.rs:7:19: 7:20 | ||
let mut _0: (); // return place in scope 0 at $DIR/provenance_soundness.rs:7:32: 7:32 | ||
let _2: usize; // in scope 0 at $DIR/provenance_soundness.rs:8:9: 8:11 | ||
let mut _3: *mut i32; // in scope 0 at $DIR/provenance_soundness.rs:8:14: 8:15 | ||
let mut _5: *mut i32; // in scope 0 at $DIR/provenance_soundness.rs:9:14: 9:15 | ||
scope 1 { | ||
debug _x => _2; // in scope 1 at $DIR/provenance_soundness.rs:8:9: 8:11 | ||
let _4: isize; // in scope 1 at $DIR/provenance_soundness.rs:9:9: 9:11 | ||
scope 2 { | ||
debug _y => _4; // in scope 2 at $DIR/provenance_soundness.rs:9:9: 9:11 | ||
} | ||
} | ||
|
||
bb0: { | ||
StorageLive(_2); // scope 0 at $DIR/provenance_soundness.rs:8:9: 8:11 | ||
StorageLive(_3); // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:15 | ||
_3 = _1; // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:15 | ||
_2 = move _3 as usize (Misc); // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:24 | ||
StorageDead(_3); // scope 0 at $DIR/provenance_soundness.rs:8:23: 8:24 | ||
StorageLive(_4); // scope 1 at $DIR/provenance_soundness.rs:9:9: 9:11 | ||
StorageLive(_5); // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:15 | ||
_5 = _1; // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:15 | ||
_4 = move _5 as isize (Misc); // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:24 | ||
StorageDead(_5); // scope 1 at $DIR/provenance_soundness.rs:9:23: 9:24 | ||
_0 = const (); // scope 0 at $DIR/provenance_soundness.rs:7:32: 10:2 | ||
StorageDead(_4); // scope 1 at $DIR/provenance_soundness.rs:10:1: 10:2 | ||
StorageDead(_2); // scope 0 at $DIR/provenance_soundness.rs:10:1: 10:2 | ||
return; // scope 0 at $DIR/provenance_soundness.rs:10:2: 10:2 | ||
} | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
...test/mir-opt/dead-store-elimination/provenance_soundness.retags.DeadStoreElimination.diff
This file contains hidden or 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,14 @@ | ||
- // MIR for `retags` before DeadStoreElimination | ||
+ // MIR for `retags` after DeadStoreElimination | ||
|
||
fn retags(_1: &mut i32) -> () { | ||
debug _r => _1; // in scope 0 at $DIR/provenance_soundness.rs:13:11: 13:13 | ||
let mut _0: (); // return place in scope 0 at $DIR/provenance_soundness.rs:13:25: 13:25 | ||
|
||
bb0: { | ||
Retag([fn entry] _1); // scope 0 at $DIR/provenance_soundness.rs:13:1: 13:27 | ||
_0 = const (); // scope 0 at $DIR/provenance_soundness.rs:13:25: 13:27 | ||
return; // scope 0 at $DIR/provenance_soundness.rs:13:27: 13:27 | ||
} | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
src/test/mir-opt/dead-store-elimination/provenance_soundness.rs
This file contains hidden or 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,18 @@ | ||
// unit-test: DeadStoreElimination | ||
// compile-flags: -Zmir-emit-retag | ||
|
||
// Test that we don't remove pointer to int casts or retags | ||
|
||
// EMIT_MIR provenance_soundness.pointer_to_int.DeadStoreElimination.diff | ||
fn pointer_to_int(p: *mut i32) { | ||
let _x = p as usize; | ||
let _y = p as isize; | ||
} | ||
|
||
// EMIT_MIR provenance_soundness.retags.DeadStoreElimination.diff | ||
fn retags(_r: &mut i32) {} | ||
|
||
fn main() { | ||
pointer_to_int(&mut 5 as *mut _); | ||
retags(&mut 5); | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.