summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_ssa/src/mir/analyze.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/mir/analyze.rs')
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/analyze.rs23
1 files changed, 15 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/analyze.rs b/compiler/rustc_codegen_ssa/src/mir/analyze.rs
index 2285e7f4e..c1de9b76f 100644
--- a/compiler/rustc_codegen_ssa/src/mir/analyze.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/analyze.rs
@@ -36,13 +36,13 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// Arguments get assigned to by means of the function being called
for arg in mir.args_iter() {
- analyzer.assign(arg, DefLocation::Argument);
+ analyzer.define(arg, DefLocation::Argument);
}
// If there exists a local definition that dominates all uses of that local,
// the definition should be visited first. Traverse blocks in an order that
// is a topological sort of dominance partial order.
- for (bb, data) in traversal::reverse_postorder(&mir) {
+ for (bb, data) in traversal::reverse_postorder(mir) {
analyzer.visit_basic_block_data(bb, data);
}
@@ -74,7 +74,7 @@ struct LocalAnalyzer<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
}
impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
- fn assign(&mut self, local: mir::Local, location: DefLocation) {
+ fn define(&mut self, local: mir::Local, location: DefLocation) {
let kind = &mut self.locals[local];
match *kind {
LocalKind::ZST => {}
@@ -162,7 +162,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue);
if let Some(local) = place.as_local() {
- self.assign(local, DefLocation::Body(location));
+ self.define(local, DefLocation::Assignment(location));
if self.locals[local] != LocalKind::Memory {
let decl_span = self.fx.mir.local_decls[local].source_info.span;
if !self.fx.rvalue_creates_operand(rvalue, decl_span) {
@@ -183,9 +183,14 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
fn visit_local(&mut self, local: mir::Local, context: PlaceContext, location: Location) {
match context {
- PlaceContext::MutatingUse(MutatingUseContext::Call)
- | PlaceContext::MutatingUse(MutatingUseContext::Yield) => {
- self.assign(local, DefLocation::Body(location));
+ PlaceContext::MutatingUse(MutatingUseContext::Call) => {
+ let call = location.block;
+ let TerminatorKind::Call { target, .. } =
+ self.fx.mir.basic_blocks[call].terminator().kind
+ else {
+ bug!()
+ };
+ self.define(local, DefLocation::CallReturn { call, target });
}
PlaceContext::NonUse(_)
@@ -197,7 +202,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
) => match &mut self.locals[local] {
LocalKind::ZST => {}
LocalKind::Memory => {}
- LocalKind::SSA(def) if def.dominates(location, &self.dominators) => {}
+ LocalKind::SSA(def) if def.dominates(location, self.dominators) => {}
// Reads from uninitialized variables (e.g., in dead code, after
// optimizations) require locals to be in (uninitialized) memory.
// N.B., there can be uninitialized reads of a local visited after
@@ -237,6 +242,8 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
}
}
}
+
+ PlaceContext::MutatingUse(MutatingUseContext::Yield) => bug!(),
}
}
}