cleanup mir visitor for rustc::pass_by_value
This commit is contained in:
parent
7e2733bb1d
commit
cf9c0a5935
23 changed files with 193 additions and 150 deletions
|
@ -88,12 +88,12 @@ fn find_optimization_oportunities<'tcx>(body: &Body<'tcx>) -> Vec<(Local, Consta
|
|||
}
|
||||
|
||||
impl Visitor<'_> for LocalUseVisitor {
|
||||
fn visit_local(&mut self, local: &Local, context: PlaceContext, location: Location) {
|
||||
fn visit_local(&mut self, local: Local, context: PlaceContext, location: Location) {
|
||||
if context.is_mutating_use() {
|
||||
self.local_mutating_uses[*local] = self.local_mutating_uses[*local].saturating_add(1);
|
||||
self.local_mutating_uses[local] = self.local_mutating_uses[local].saturating_add(1);
|
||||
|
||||
if context.is_place_assignment() {
|
||||
self.local_assignment_locations[*local] = Some(location);
|
||||
self.local_assignment_locations[local] = Some(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -882,7 +882,7 @@ impl CanConstProp {
|
|||
}
|
||||
|
||||
impl Visitor<'_> for CanConstProp {
|
||||
fn visit_local(&mut self, &local: &Local, context: PlaceContext, _: Location) {
|
||||
fn visit_local(&mut self, local: Local, context: PlaceContext, _: Location) {
|
||||
use rustc_middle::mir::visit::PlaceContext::*;
|
||||
match context {
|
||||
// Projections are fine, because `&mut foo.x` will be caught by
|
||||
|
|
|
@ -773,7 +773,7 @@ impl CanConstProp {
|
|||
}
|
||||
|
||||
impl Visitor<'_> for CanConstProp {
|
||||
fn visit_local(&mut self, &local: &Local, context: PlaceContext, _: Location) {
|
||||
fn visit_local(&mut self, local: Local, context: PlaceContext, _: Location) {
|
||||
use rustc_middle::mir::visit::PlaceContext::*;
|
||||
match context {
|
||||
// Projections are fine, because `&mut foo.x` will be caught by
|
||||
|
|
|
@ -219,7 +219,7 @@ impl IsReturnPlaceRead {
|
|||
}
|
||||
|
||||
impl<'tcx> Visitor<'tcx> for IsReturnPlaceRead {
|
||||
fn visit_local(&mut self, &l: &Local, ctxt: PlaceContext, _: Location) {
|
||||
fn visit_local(&mut self, l: Local, ctxt: PlaceContext, _: Location) {
|
||||
if l == mir::RETURN_PLACE && ctxt.is_use() && !ctxt.is_place_assignment() {
|
||||
self.0 = true;
|
||||
}
|
||||
|
|
|
@ -509,12 +509,12 @@ impl<'tcx> Visitor<'tcx> for UsedLocals {
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_local(&mut self, local: &Local, _ctx: PlaceContext, _location: Location) {
|
||||
fn visit_local(&mut self, local: Local, _ctx: PlaceContext, _location: Location) {
|
||||
if self.increment {
|
||||
self.use_count[*local] += 1;
|
||||
self.use_count[local] += 1;
|
||||
} else {
|
||||
assert_ne!(self.use_count[*local], 0);
|
||||
self.use_count[*local] -= 1;
|
||||
assert_ne!(self.use_count[local], 0);
|
||||
self.use_count[local] -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -462,14 +462,14 @@ impl LocalUseCounter {
|
|||
}
|
||||
|
||||
impl Visitor<'_> for LocalUseCounter {
|
||||
fn visit_local(&mut self, local: &Local, context: PlaceContext, _location: Location) {
|
||||
fn visit_local(&mut self, local: Local, context: PlaceContext, _location: Location) {
|
||||
if context.is_storage_marker()
|
||||
|| context == PlaceContext::NonUse(NonUseContext::VarDebugInfo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self.local_uses[*local] += 1;
|
||||
self.local_uses[local] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue