about summary refs log tree commit diff
path: root/compiler/rustc_mir_dataflow/src/debuginfo.rs
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-01-12 20:04:42 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-10-06 15:46:11 +0000
commit27d6a57e5821c8b7f5c8b049e36b856ed9440bfe (patch)
tree1e7ecfcfc3c9055313b5cc07d6b0addd58f02df8 /compiler/rustc_mir_dataflow/src/debuginfo.rs
parent1bc0463b183392ad4e0ae9c5f7a76630d487230d (diff)
downloadrust-27d6a57e5821c8b7f5c8b049e36b856ed9440bfe.tar.gz
rust-27d6a57e5821c8b7f5c8b049e36b856ed9440bfe.zip
Preserve DebugInfo in DeadStoreElimination.
Diffstat (limited to 'compiler/rustc_mir_dataflow/src/debuginfo.rs')
-rw-r--r--compiler/rustc_mir_dataflow/src/debuginfo.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_mir_dataflow/src/debuginfo.rs b/compiler/rustc_mir_dataflow/src/debuginfo.rs
new file mode 100644
index 00000000000..fd5e8cf2955
--- /dev/null
+++ b/compiler/rustc_mir_dataflow/src/debuginfo.rs
@@ -0,0 +1,20 @@
+use rustc_index::bit_set::BitSet;
+use rustc_middle::mir::visit::*;
+use rustc_middle::mir::*;
+
+/// Return the set of locals that appear in debuginfo.
+pub fn debuginfo_locals(body: &Body<'_>) -> BitSet<Local> {
+    let mut visitor = DebuginfoLocals(BitSet::new_empty(body.local_decls.len()));
+    for debuginfo in body.var_debug_info.iter() {
+        visitor.visit_var_debug_info(debuginfo);
+    }
+    visitor.0
+}
+
+struct DebuginfoLocals(BitSet<Local>);
+
+impl Visitor<'_> for DebuginfoLocals {
+    fn visit_local(&mut self, local: Local, _: PlaceContext, _: Location) {
+        self.0.insert(local);
+    }
+}