Add method that applies DefUse effect
This commit is contained in:
parent
4462b4af52
commit
58eabb291d
1 changed files with 11 additions and 15 deletions
|
@ -122,11 +122,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_local(&mut self, local: Local, context: PlaceContext, _: Location) {
|
fn visit_local(&mut self, local: Local, context: PlaceContext, _: Location) {
|
||||||
match DefUse::for_place(local.into(), context) {
|
DefUse::apply(self.0, local.into(), context);
|
||||||
Some(DefUse::Def) => self.0.kill(local),
|
|
||||||
Some(DefUse::Use) => self.0.gen(local),
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,20 +133,12 @@ where
|
||||||
T: GenKill<Local>,
|
T: GenKill<Local>,
|
||||||
{
|
{
|
||||||
fn visit_place(&mut self, place: &mir::Place<'tcx>, context: PlaceContext, location: Location) {
|
fn visit_place(&mut self, place: &mir::Place<'tcx>, context: PlaceContext, location: Location) {
|
||||||
match DefUse::for_place(*place, context) {
|
DefUse::apply(self.0, *place, context);
|
||||||
Some(DefUse::Def) => self.0.kill(place.local),
|
|
||||||
Some(DefUse::Use) => self.0.gen(place.local),
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
self.visit_projection(place.as_ref(), context, location);
|
self.visit_projection(place.as_ref(), context, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_local(&mut self, local: Local, context: PlaceContext, _: Location) {
|
fn visit_local(&mut self, local: Local, context: PlaceContext, _: Location) {
|
||||||
match DefUse::for_place(local.into(), context) {
|
DefUse::apply(self.0, local.into(), context);
|
||||||
Some(DefUse::Def) => self.0.kill(local),
|
|
||||||
Some(DefUse::Use) => self.0.gen(local),
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +149,14 @@ enum DefUse {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DefUse {
|
impl DefUse {
|
||||||
|
fn apply<'tcx>(trans: &mut impl GenKill<Local>, place: Place<'tcx>, context: PlaceContext) {
|
||||||
|
match DefUse::for_place(place, context) {
|
||||||
|
Some(DefUse::Def) => trans.kill(place.local),
|
||||||
|
Some(DefUse::Use) => trans.gen(place.local),
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn for_place<'tcx>(place: Place<'tcx>, context: PlaceContext) -> Option<DefUse> {
|
fn for_place<'tcx>(place: Place<'tcx>, context: PlaceContext) -> Option<DefUse> {
|
||||||
match context {
|
match context {
|
||||||
PlaceContext::NonUse(_) => None,
|
PlaceContext::NonUse(_) => None,
|
||||||
|
|
Loading…
Add table
Reference in a new issue