summary refs log tree commit diff
path: root/compiler/rustc_mir_dataflow/src
diff options
context:
space:
mode:
authorJannis Christopher Köhl <mail@koehl.dev>2022-09-02 00:37:38 +0200
committerJannis Christopher Köhl <mail@koehl.dev>2022-11-07 10:35:13 +0100
commit16dedba1c80e96e7b0481191d4ae16e2d8cb0016 (patch)
treeca9e04b3c3b98ddb0e1047f01a859651e1a9aa2b /compiler/rustc_mir_dataflow/src
parent469fb197d06de9c6b06cb5b74eb8aff6ad85a332 (diff)
downloadrust-16dedba1c80e96e7b0481191d4ae16e2d8cb0016.tar.gz
rust-16dedba1c80e96e7b0481191d4ae16e2d8cb0016.zip
Ignore terminators explicitly
Diffstat (limited to 'compiler/rustc_mir_dataflow/src')
-rw-r--r--compiler/rustc_mir_dataflow/src/value_analysis.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs
index 64e45083fc0..5fe768f8310 100644
--- a/compiler/rustc_mir_dataflow/src/value_analysis.rs
+++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs
@@ -146,10 +146,7 @@ pub trait ValueAnalysis<'tcx> {
             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 @@ pub trait ValueAnalysis<'tcx> {
         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,