Skip to content

Commit 82ae063

Browse files
committed
Move DefLocation from rustc_codegen_ssa to rustc_middle
1 parent ffd0dd6 commit 82ae063

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

compiler/rustc_codegen_ssa/src/mir/analyze.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_index::bit_set::BitSet;
88
use rustc_index::{IndexSlice, IndexVec};
99
use rustc_middle::mir::traversal;
1010
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
11-
use rustc_middle::mir::{self, Location, TerminatorKind};
11+
use rustc_middle::mir::{self, DefLocation, Location, TerminatorKind};
1212
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
1313

1414
pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
@@ -67,21 +67,6 @@ enum LocalKind {
6767
SSA(DefLocation),
6868
}
6969

70-
#[derive(Copy, Clone, PartialEq, Eq)]
71-
enum DefLocation {
72-
Argument,
73-
Body(Location),
74-
}
75-
76-
impl DefLocation {
77-
fn dominates(self, location: Location, dominators: &Dominators<mir::BasicBlock>) -> bool {
78-
match self {
79-
DefLocation::Argument => true,
80-
DefLocation::Body(def) => def.successor_within_block().dominates(location, dominators),
81-
}
82-
}
83-
}
84-
8570
struct LocalAnalyzer<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
8671
fx: &'mir FunctionCx<'a, 'tcx, Bx>,
8772
dominators: &'mir Dominators<mir::BasicBlock>,

compiler/rustc_middle/src/mir/mod.rs

+17
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,23 @@ impl Location {
15901590
}
15911591
}
15921592

1593+
/// `DefLocation` represents the location of a definition - either an argument or an assignment
1594+
/// within MIR body.
1595+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
1596+
pub enum DefLocation {
1597+
Argument,
1598+
Body(Location),
1599+
}
1600+
1601+
impl DefLocation {
1602+
pub fn dominates(self, location: Location, dominators: &Dominators<BasicBlock>) -> bool {
1603+
match self {
1604+
DefLocation::Argument => true,
1605+
DefLocation::Body(def) => def.successor_within_block().dominates(location, dominators),
1606+
}
1607+
}
1608+
}
1609+
15931610
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
15941611
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
15951612
mod size_asserts {

0 commit comments

Comments
 (0)