}
/// Computes which local variables are live within the given function
-/// `mir`. The liveness mode `mode` determines what sorts of uses are
-/// considered to make a variable live (e.g., do drops count?).
+/// `mir`, including drops.
pub fn liveness_of_locals<'tcx>(
- mir: &Mir<'tcx>,
+ mir: &Body<'tcx>,
) -> LivenessResult {
let num_live_vars = mir.local_decls.len();
Drop,
}
-pub fn categorize<'tcx>(context: PlaceContext<'tcx>) -> Option<DefUse> {
+pub fn categorize<'tcx>(context: PlaceContext) -> Option<DefUse> {
match context {
///////////////////////////////////////////////////////////////////////////
// DEFS
// This won't affect the results since we use this analysis for generators
// and we only care about the result at suspension points. Borrows cannot
// cross suspension points so this behavior is unproblematic.
- PlaceContext::MutatingUse(MutatingUseContext::Borrow(..)) |
- PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) |
- PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) |
- PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow(..)) |
+ PlaceContext::MutatingUse(MutatingUseContext::Borrow) |
+ PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) |
+ PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow) |
+ PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow) |
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) |
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) |
impl<'tcx> Visitor<'tcx> for DefsUsesVisitor
{
- fn visit_local(&mut self, &local: &Local, context: PlaceContext<'tcx>, _: Location) {
+ fn visit_local(&mut self, &local: &Local, context: PlaceContext, _: Location) {
match categorize(context) {
Some(DefUse::Def) => self.defs_uses.add_def(local),
Some(DefUse::Use) | Some(DefUse::Drop) => self.defs_uses.add_use(local),
// Visit the various parts of the basic block in reverse. If we go
// forward, the logic in `add_def` and `add_use` would be wrong.
- visitor.visit_terminator(BasicBlock::new(0), b.terminator(), dummy_location);
+ visitor.visit_terminator(b.terminator(), dummy_location);
for statement in b.statements.iter().rev() {
- visitor.visit_statement(BasicBlock::new(0), statement, dummy_location);
+ visitor.visit_statement(statement, dummy_location);
}
visitor.defs_uses
tcx: TyCtxt<'a, 'tcx, 'tcx>,
pass_name: &str,
source: MirSource<'tcx>,
- mir: &Mir<'tcx>,
+ mir: &Body<'tcx>,
result: &LivenessResult,
) {
if !dump_enabled(tcx, pass_name, source) {
pass_name: &str,
node_path: &str,
source: MirSource<'tcx>,
- mir: &Mir<'tcx>,
+ mir: &Body<'tcx>,
result: &LivenessResult,
) {
let mut file_path = PathBuf::new();
pub fn write_mir_fn<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
src: MirSource<'tcx>,
- mir: &Mir<'tcx>,
+ mir: &Body<'tcx>,
w: &mut dyn Write,
result: &LivenessResult,
) -> io::Result<()> {