Ignore terminators explicitly

This commit is contained in:
Jannis Christopher Köhl 2022-09-02 00:37:38 +02:00
parent 469fb197d0
commit 16dedba1c8
2 changed files with 15 additions and 6 deletions

View File

@ -146,10 +146,7 @@ fn super_rvalue(
Rvalue::CopyForDeref(place) => {
self.handle_operand(&Operand::Copy(*place), state).into()
}
_ => {
// FIXME: Check that other Rvalues really have no side-effect.
ValueOrPlaceOrRef::Unknown
}
_ => ValueOrPlaceOrRef::Unknown,
}
}
@ -200,7 +197,20 @@ fn handle_terminator(&self, terminator: &Terminator<'tcx>, state: &mut State<Sel
self.super_terminator(terminator, state)
}
fn super_terminator(&self, _terminator: &Terminator<'tcx>, _state: &mut State<Self::Value>) {}
fn super_terminator(&self, terminator: &Terminator<'tcx>, _state: &mut State<Self::Value>) {
match &terminator.kind {
TerminatorKind::Call { .. } | TerminatorKind::InlineAsm { .. } => {
// Effect is applied by `handle_call_return`.
}
TerminatorKind::DropAndReplace { .. } | TerminatorKind::Yield { .. } => {
// They would have an effect, but are not allowed in this phase.
bug!("encountered disallowed terminator");
}
_ => {
// The other terminators can be ignored.
}
}
}
fn handle_call_return(
&self,

View File

@ -35,7 +35,6 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
}
}
// FIXME: Consider support for discriminants, mutable references, arrays and slices.
struct ConstAnalysis<'tcx> {
map: Map,
tcx: TyCtxt<'tcx>,