rapx/vm/step.rs
1//! MIR items retained by the backward slicer for VM execution.
2
3use rustc_hir::def_id::DefId;
4use rustc_middle::mir::{BasicBlock, Body};
5
6/// One relevant item kept from the backward slice.
7#[derive(Clone, Debug)]
8pub(crate) enum RelevantItem<'tcx> {
9 /// A MIR statement retained from a basic block. `def_id` identifies the
10 /// function owning `block` (differs from the caller for inlined callees).
11 Statement {
12 def_id: DefId,
13 block: BasicBlock,
14 global_block: Option<usize>,
15 stmt_index: usize,
16 },
17 /// A MIR terminator retained from a basic block. For a `SwitchInt`, `block`
18 /// is the switch block and `switch_succ` is the successor taken along this
19 /// path (so the VM need not re-resolve it from the path); for any other
20 /// terminator — or when the path ends at the checkpoint — `switch_succ` is
21 /// `None`.
22 Terminator {
23 def_id: DefId,
24 block: BasicBlock,
25 global_block: Option<usize>,
26 switch_succ: Option<BasicBlock>,
27 },
28 /// Enter an inlined callee: bind each argument to its parameter position.
29 CalleeEntry {
30 callee: DefId,
31 body: Option<&'tcx Body<'tcx>>,
32 args: Vec<crate::analysis::path::CallArg>,
33 },
34 /// Return from an inlined callee: write the callee's `_0` to the caller's
35 /// destination local.
36 CalleeExit { dest: usize },
37}
38impl RelevantItem<'_> {
39 pub(crate) fn set_global_block(&mut self, global_block: usize) {
40 match self {
41 Self::Statement {
42 global_block: slot, ..
43 }
44 | Self::Terminator {
45 global_block: slot, ..
46 } => *slot = Some(global_block),
47 _ => {}
48 }
49 }
50}