Skip to content

Commit efbea54

Browse files
committed
Rename dead code removal pass to a proper-er name
1 parent 61a58f1 commit efbea54

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

src/librustc_driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
994994
passes.push_pass(box mir::transform::deaggregator::Deaggregator);
995995
passes.push_pass(box mir::transform::cs_propagate::CsPropagate);
996996
passes.push_pass(box mir::transform::simplify_cfg::SimplifyCfg::new("ccs-propagate"));
997-
passes.push_pass(box mir::transform::liveness::LocalLivenessAnalysis);
997+
passes.push_pass(box mir::transform::deadcode::DeadCode);
998998

999999
passes.push_pass(box mir::transform::add_call_guards::AddCallGuards);
10001000
passes.push_pass(box borrowck::ElaborateDrops);

src/librustc_mir/transform/liveness.rs renamed to src/librustc_mir/transform/deadcode.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ use rustc::ty::TyCtxt;
1616

1717
use super::dataflow::*;
1818

19-
pub struct LocalLivenessAnalysis;
19+
pub struct DeadCode;
2020

21-
impl Pass for LocalLivenessAnalysis {}
21+
impl Pass for DeadCode {}
2222

23-
impl<'tcx> MirPass<'tcx> for LocalLivenessAnalysis {
23+
impl<'tcx> MirPass<'tcx> for DeadCode {
2424
fn run_pass<'a>(&mut self, _: TyCtxt<'a, 'tcx, 'tcx>, _: MirSource, mir: &mut Mir<'tcx>) {
25-
let new_mir = Dataflow::backward(mir, LiveValueTransfer, LiveValueRewrite);
25+
let new_mir = Dataflow::backward(mir, DeadCodeTransfer, DeadCodeRewrite);
2626
*mir = new_mir;
2727
}
2828
}
2929

3030
#[derive(Debug, Clone)]
31-
struct LiveValueLattice {
31+
struct DeadCodeLattice {
3232
vars: BitVector,
3333
args: BitVector,
3434
tmps: BitVector,
3535
}
3636

37-
impl Lattice for LiveValueLattice {
37+
impl Lattice for DeadCodeLattice {
3838
fn bottom() -> Self {
39-
LiveValueLattice {
39+
DeadCodeLattice {
4040
vars: BitVector::new(0),
4141
tmps: BitVector::new(0),
4242
args: BitVector::new(0)
@@ -53,7 +53,7 @@ impl Lattice for LiveValueLattice {
5353
}
5454
}
5555

56-
impl LiveValueLattice {
56+
impl DeadCodeLattice {
5757
fn set_lvalue_live<'a>(&mut self, l: &Lvalue<'a>) {
5858
match *l {
5959
Lvalue::Arg(a) => {
@@ -82,29 +82,29 @@ impl LiveValueLattice {
8282
}
8383
}
8484

85-
struct LiveValueTransfer;
86-
impl<'tcx> Transfer<'tcx> for LiveValueTransfer {
87-
type Lattice = LiveValueLattice;
88-
type TerminatorReturn = LiveValueLattice;
85+
struct DeadCodeTransfer;
86+
impl<'tcx> Transfer<'tcx> for DeadCodeTransfer {
87+
type Lattice = DeadCodeLattice;
88+
type TerminatorReturn = DeadCodeLattice;
8989

90-
fn stmt(&self, s: &Statement<'tcx>, lat: LiveValueLattice) -> LiveValueLattice {
91-
let mut vis = LiveValueVisitor(lat);
90+
fn stmt(&self, s: &Statement<'tcx>, lat: DeadCodeLattice) -> DeadCodeLattice {
91+
let mut vis = DeadCodeVisitor(lat);
9292
vis.visit_statement(START_BLOCK, s);
9393
vis.0
9494
}
9595

96-
fn term(&self, t: &Terminator<'tcx>, lat: LiveValueLattice) -> LiveValueLattice {
97-
let mut vis = LiveValueVisitor(lat);
96+
fn term(&self, t: &Terminator<'tcx>, lat: DeadCodeLattice) -> DeadCodeLattice {
97+
let mut vis = DeadCodeVisitor(lat);
9898
vis.visit_terminator(START_BLOCK, t);
9999
vis.0
100100
}
101101
}
102102

103-
struct LiveValueRewrite;
104-
impl<'tcx, T> Rewrite<'tcx, T> for LiveValueRewrite
105-
where T: Transfer<'tcx, Lattice=LiveValueLattice>
103+
struct DeadCodeRewrite;
104+
impl<'tcx, T> Rewrite<'tcx, T> for DeadCodeRewrite
105+
where T: Transfer<'tcx, Lattice=DeadCodeLattice>
106106
{
107-
fn stmt(&self, s: &Statement<'tcx>, lat: &LiveValueLattice)
107+
fn stmt(&self, s: &Statement<'tcx>, lat: &DeadCodeLattice)
108108
-> StatementChange<'tcx>
109109
{
110110
let StatementKind::Assign(ref lval, ref rval) = s.kind;
@@ -121,15 +121,15 @@ where T: Transfer<'tcx, Lattice=LiveValueLattice>
121121
}
122122
}
123123

124-
fn term(&self, t: &Terminator<'tcx>, _: &LiveValueLattice)
124+
fn term(&self, t: &Terminator<'tcx>, _: &DeadCodeLattice)
125125
-> TerminatorChange<'tcx>
126126
{
127127
TerminatorChange::Terminator(t.clone())
128128
}
129129
}
130130

131-
struct LiveValueVisitor(LiveValueLattice);
132-
impl<'tcx> Visitor<'tcx> for LiveValueVisitor {
131+
struct DeadCodeVisitor(DeadCodeLattice);
132+
impl<'tcx> Visitor<'tcx> for DeadCodeVisitor {
133133
fn visit_lvalue(&mut self, lval: &Lvalue<'tcx>, ctx: LvalueContext) {
134134
if ctx == LvalueContext::Store || ctx == LvalueContext::CallStore {
135135
match *lval {

0 commit comments

Comments
 (0)