Module rustc_mir::transform::copy_prop[][src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Trivial copy propagation pass.

This uses def-use analysis to remove values that have exactly one def and one use, which must be an assignment.

To give an example, we look for patterns that look like:

DEST = SRC
...
USE(DEST)

where DEST and SRC are both locals of some form. We replace that with:

NOP
...
USE(SRC)

The assignment DEST = SRC must be (a) the only mutation of DEST and (b) the only (non-mutating) use of SRC. These restrictions are conservative and may be relaxed in the future.

Re-exports

use rustc::mir::Constant;
use rustc::mir::Local;
use rustc::mir::LocalKind;
use rustc::mir::Location;
use rustc::mir::Place;
use rustc::mir::Mir;
use rustc::mir::Operand;
use rustc::mir::Rvalue;
use rustc::mir::StatementKind;
use rustc::mir::visit::MutVisitor;
use rustc::ty::TyCtxt;
use transform::MirPass;
use transform::MirSource;
use util::def_use::DefUseAnalysis;

Structs

ConstantPropagationVisitor [
Experimental
]
CopyPropagation [
Experimental
]

Enums

Action [
Experimental
]

Functions

eliminate_self_assignments [
Experimental
]