Move the dataflow framework to its own crate.
This commit is contained in:
parent
81a600b6b7
commit
fd9c04fe32
74 changed files with 259 additions and 211 deletions
31
Cargo.lock
31
Cargo.lock
|
@ -3614,6 +3614,7 @@ dependencies = [
|
|||
"rustc_lexer",
|
||||
"rustc_middle",
|
||||
"rustc_mir",
|
||||
"rustc_mir_dataflow",
|
||||
"rustc_serialize",
|
||||
"rustc_session",
|
||||
"rustc_span",
|
||||
|
@ -4047,6 +4048,8 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"bitflags",
|
||||
"chalk-ir",
|
||||
"either",
|
||||
"gsgdt",
|
||||
"polonius-engine",
|
||||
"rustc-rayon-core",
|
||||
"rustc_apfloat",
|
||||
|
@ -4056,6 +4059,7 @@ dependencies = [
|
|||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_feature",
|
||||
"rustc_graphviz",
|
||||
"rustc_hir",
|
||||
"rustc_index",
|
||||
"rustc_macros",
|
||||
|
@ -4075,25 +4079,21 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"either",
|
||||
"gsgdt",
|
||||
"polonius-engine",
|
||||
"regex",
|
||||
"rustc_apfloat",
|
||||
"rustc_ast",
|
||||
"rustc_attr",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_graphviz",
|
||||
"rustc_hir",
|
||||
"rustc_index",
|
||||
"rustc_infer",
|
||||
"rustc_macros",
|
||||
"rustc_middle",
|
||||
"rustc_serialize",
|
||||
"rustc_mir_dataflow",
|
||||
"rustc_session",
|
||||
"rustc_span",
|
||||
"rustc_target",
|
||||
"rustc_trait_selection",
|
||||
"smallvec",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
|
@ -4120,6 +4120,26 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_mir_dataflow"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"polonius-engine",
|
||||
"regex",
|
||||
"rustc_ast",
|
||||
"rustc_data_structures",
|
||||
"rustc_graphviz",
|
||||
"rustc_hir",
|
||||
"rustc_index",
|
||||
"rustc_middle",
|
||||
"rustc_serialize",
|
||||
"rustc_session",
|
||||
"rustc_span",
|
||||
"rustc_target",
|
||||
"smallvec",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_mir_transform"
|
||||
version = "0.0.0"
|
||||
|
@ -4134,6 +4154,7 @@ dependencies = [
|
|||
"rustc_index",
|
||||
"rustc_middle",
|
||||
"rustc_mir",
|
||||
"rustc_mir_dataflow",
|
||||
"rustc_serialize",
|
||||
"rustc_session",
|
||||
"rustc_span",
|
||||
|
|
|
@ -22,6 +22,7 @@ rustc_infer = { path = "../rustc_infer" }
|
|||
rustc_lexer = { path = "../rustc_lexer" }
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_mir = { path = "../rustc_mir" }
|
||||
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
|
||||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
rustc_session = { path = "../rustc_session" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
|
|
|
@ -8,7 +8,7 @@ use rustc_middle::mir::traversal;
|
|||
use rustc_middle::mir::visit::{MutatingUseContext, NonUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{self, Body, Local, Location};
|
||||
use rustc_middle::ty::{RegionVid, TyCtxt};
|
||||
use rustc_mir::dataflow::move_paths::MoveData;
|
||||
use rustc_mir_dataflow::move_paths::MoveData;
|
||||
use std::fmt;
|
||||
use std::ops::Index;
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ use rustc_index::bit_set::BitSet;
|
|||
use rustc_middle::mir::{self, BasicBlock, Body, Location, Place};
|
||||
use rustc_middle::ty::RegionVid;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_mir::dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces};
|
||||
use rustc_mir::dataflow::ResultsVisitable;
|
||||
use rustc_mir::dataflow::{self, fmt::DebugWithContext, GenKill};
|
||||
use rustc_mir::dataflow::{Analysis, Direction, Results};
|
||||
use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces};
|
||||
use rustc_mir_dataflow::ResultsVisitable;
|
||||
use rustc_mir_dataflow::{self, fmt::DebugWithContext, GenKill};
|
||||
use rustc_mir_dataflow::{Analysis, Direction, Results};
|
||||
use std::fmt;
|
||||
use std::iter;
|
||||
|
||||
|
@ -323,7 +323,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> dataflow::AnalysisDomain<'tcx> for Borrows<'_, 'tcx> {
|
||||
impl<'tcx> rustc_mir_dataflow::AnalysisDomain<'tcx> for Borrows<'_, 'tcx> {
|
||||
type Domain = BitSet<BorrowIndex>;
|
||||
|
||||
const NAME: &'static str = "borrows";
|
||||
|
@ -339,7 +339,7 @@ impl<'tcx> dataflow::AnalysisDomain<'tcx> for Borrows<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
|
||||
impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
|
||||
type Idx = BorrowIndex;
|
||||
|
||||
fn before_statement_effect(
|
||||
|
|
|
@ -10,14 +10,14 @@ use rustc_middle::mir::{
|
|||
ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, VarBindingForm,
|
||||
};
|
||||
use rustc_middle::ty::{self, suggest_constraining_type_param, Ty};
|
||||
use rustc_mir_dataflow::drop_flag_effects;
|
||||
use rustc_mir_dataflow::move_paths::{MoveOutIndex, MovePathIndex};
|
||||
use rustc_span::source_map::DesugaringKind;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{BytePos, MultiSpan, Span, DUMMY_SP};
|
||||
use rustc_trait_selection::infer::InferCtxtExt;
|
||||
|
||||
use crate::borrowck_errors;
|
||||
use rustc_mir::dataflow::drop_flag_effects;
|
||||
use rustc_mir::dataflow::move_paths::{MoveOutIndex, MovePathIndex};
|
||||
|
||||
use crate::{
|
||||
borrow_set::BorrowData, diagnostics::Instance, prefixes::IsPrefixOf,
|
||||
|
|
|
@ -12,7 +12,7 @@ use rustc_middle::mir::{
|
|||
};
|
||||
use rustc_middle::ty::print::Print;
|
||||
use rustc_middle::ty::{self, DefIdTree, Instance, Ty, TyCtxt};
|
||||
use rustc_mir::dataflow::move_paths::{InitLocation, LookupResult};
|
||||
use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult};
|
||||
use rustc_span::{
|
||||
hygiene::{DesugaringKind, ForLoopLoc},
|
||||
symbol::sym,
|
||||
|
|
|
@ -2,7 +2,7 @@ use rustc_errors::{Applicability, DiagnosticBuilder};
|
|||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty;
|
||||
use rustc_mir::dataflow::move_paths::{
|
||||
use rustc_mir_dataflow::move_paths::{
|
||||
IllegalMoveOrigin, IllegalMoveOriginKind, LookupResult, MoveError, MovePathIndex,
|
||||
};
|
||||
use rustc_span::source_map::DesugaringKind;
|
||||
|
|
|
@ -5,7 +5,7 @@ use polonius_engine::Atom;
|
|||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::mir::Local;
|
||||
use rustc_middle::ty::{RegionVid, TyCtxt};
|
||||
use rustc_mir::dataflow::move_paths::MovePathIndex;
|
||||
use rustc_mir_dataflow::move_paths::MovePathIndex;
|
||||
use std::error::Error;
|
||||
use std::fmt::Debug;
|
||||
use std::fs::{self, File};
|
||||
|
|
|
@ -46,13 +46,13 @@ use std::iter;
|
|||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
|
||||
use rustc_mir::dataflow::impls::{
|
||||
use rustc_mir_dataflow::impls::{
|
||||
EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces,
|
||||
};
|
||||
use rustc_mir::dataflow::move_paths::{InitIndex, MoveOutIndex, MovePathIndex};
|
||||
use rustc_mir::dataflow::move_paths::{InitLocation, LookupResult, MoveData, MoveError};
|
||||
use rustc_mir::dataflow::Analysis;
|
||||
use rustc_mir::dataflow::MoveDataParamEnv;
|
||||
use rustc_mir_dataflow::move_paths::{InitIndex, MoveOutIndex, MovePathIndex};
|
||||
use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult, MoveData, MoveError};
|
||||
use rustc_mir_dataflow::Analysis;
|
||||
use rustc_mir_dataflow::MoveDataParamEnv;
|
||||
|
||||
use self::diagnostics::{AccessKind, RegionName};
|
||||
use self::location::LocationTable;
|
||||
|
@ -373,7 +373,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
|||
|
||||
mbcx.report_move_errors(move_errors);
|
||||
|
||||
rustc_mir::dataflow::visit_results(
|
||||
rustc_mir_dataflow::visit_results(
|
||||
&body,
|
||||
traversal::reverse_postorder(&body).map(|(bb, _)| bb),
|
||||
&results,
|
||||
|
@ -615,7 +615,7 @@ struct MirBorrowckCtxt<'cx, 'tcx> {
|
|||
// 2. loans made in overlapping scopes do not conflict
|
||||
// 3. assignments do not affect things loaned out as immutable
|
||||
// 4. moves do not affect things loaned out in any way
|
||||
impl<'cx, 'tcx> rustc_mir::dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx> {
|
||||
impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx> {
|
||||
type FlowState = Flows<'cx, 'tcx>;
|
||||
|
||||
fn visit_statement_before_primary_effect(
|
||||
|
|
|
@ -4,6 +4,7 @@ use rustc_data_structures::vec_map::VecMap;
|
|||
use rustc_errors::Diagnostic;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_infer::infer::InferCtxt;
|
||||
use rustc_middle::mir::{create_dump_file, dump_enabled, dump_mir, PassWhere};
|
||||
use rustc_middle::mir::{
|
||||
BasicBlock, Body, ClosureOutlivesSubject, ClosureRegionRequirements, LocalKind, Location,
|
||||
Promoted,
|
||||
|
@ -17,14 +18,11 @@ use std::path::PathBuf;
|
|||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
|
||||
use self::mir_util::PassWhere;
|
||||
use polonius_engine::{Algorithm, Output};
|
||||
|
||||
use rustc_mir::dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir::dataflow::move_paths::{InitKind, InitLocation, MoveData};
|
||||
use rustc_mir::dataflow::ResultsCursor;
|
||||
use rustc_mir::util as mir_util;
|
||||
use rustc_mir::util::pretty;
|
||||
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir_dataflow::move_paths::{InitKind, InitLocation, MoveData};
|
||||
use rustc_mir_dataflow::ResultsCursor;
|
||||
|
||||
use crate::{
|
||||
borrow_set::BorrowSet,
|
||||
|
@ -72,7 +70,7 @@ pub(crate) fn replace_regions_in_mir<'cx, 'tcx>(
|
|||
// Replace all remaining regions with fresh inference variables.
|
||||
renumber::renumber_mir(infcx, body, promoted);
|
||||
|
||||
mir_util::dump_mir(infcx.tcx, None, "renumber", &0, body, |_, _| Ok(()));
|
||||
dump_mir(infcx.tcx, None, "renumber", &0, body, |_, _| Ok(()));
|
||||
|
||||
universal_regions
|
||||
}
|
||||
|
@ -322,11 +320,11 @@ pub(super) fn dump_mir_results<'a, 'tcx>(
|
|||
regioncx: &RegionInferenceContext<'tcx>,
|
||||
closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,
|
||||
) {
|
||||
if !mir_util::dump_enabled(infcx.tcx, "nll", body.source.def_id()) {
|
||||
if !dump_enabled(infcx.tcx, "nll", body.source.def_id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mir_util::dump_mir(infcx.tcx, None, "nll", &0, body, |pass_where, out| {
|
||||
dump_mir(infcx.tcx, None, "nll", &0, body, |pass_where, out| {
|
||||
match pass_where {
|
||||
// Before the CFG, dump out the values for each region variable.
|
||||
PassWhere::BeforeCFG => {
|
||||
|
@ -354,14 +352,14 @@ pub(super) fn dump_mir_results<'a, 'tcx>(
|
|||
// Also dump the inference graph constraints as a graphviz file.
|
||||
let _: io::Result<()> = try {
|
||||
let mut file =
|
||||
pretty::create_dump_file(infcx.tcx, "regioncx.all.dot", None, "nll", &0, body.source)?;
|
||||
create_dump_file(infcx.tcx, "regioncx.all.dot", None, "nll", &0, body.source)?;
|
||||
regioncx.dump_graphviz_raw_constraints(&mut file)?;
|
||||
};
|
||||
|
||||
// Also dump the inference graph constraints as a graphviz file.
|
||||
let _: io::Result<()> = try {
|
||||
let mut file =
|
||||
pretty::create_dump_file(infcx.tcx, "regioncx.scc.dot", None, "nll", &0, body.source)?;
|
||||
create_dump_file(infcx.tcx, "regioncx.scc.dot", None, "nll", &0, body.source)?;
|
||||
regioncx.dump_graphviz_scc_constraints(&mut file)?;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ use rustc_middle::mir::{Body, Local};
|
|||
use rustc_middle::ty::{RegionVid, TyCtxt};
|
||||
use std::rc::Rc;
|
||||
|
||||
use rustc_mir::dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir::dataflow::move_paths::MoveData;
|
||||
use rustc_mir::dataflow::ResultsCursor;
|
||||
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir_dataflow::move_paths::MoveData;
|
||||
use rustc_mir_dataflow::ResultsCursor;
|
||||
|
||||
use crate::{
|
||||
constraints::OutlivesConstraintSet,
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::location::{LocationIndex, LocationTable};
|
|||
use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{Body, Local, Location, Place};
|
||||
use rustc_middle::ty::subst::GenericArg;
|
||||
use rustc_mir::dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
|
||||
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
|
||||
|
||||
use super::TypeChecker;
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives;
|
|||
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
|
||||
use std::rc::Rc;
|
||||
|
||||
use rustc_mir::dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir::dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
|
||||
use rustc_mir::dataflow::ResultsCursor;
|
||||
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
|
||||
use rustc_mir_dataflow::ResultsCursor;
|
||||
|
||||
use crate::{
|
||||
region_infer::values::{self, PointIndex, RegionValueElements},
|
||||
|
|
|
@ -41,12 +41,12 @@ use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
|
|||
use rustc_trait_selection::traits::query::Fallible;
|
||||
use rustc_trait_selection::traits::{self, ObligationCause, PredicateObligations};
|
||||
|
||||
use rustc_mir::dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir::dataflow::move_paths::MoveData;
|
||||
use rustc_mir::dataflow::ResultsCursor;
|
||||
use rustc_mir::transform::{
|
||||
check_consts::ConstCx, promote_consts::is_const_fn_in_array_repeat_expression,
|
||||
};
|
||||
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir_dataflow::move_paths::MoveData;
|
||||
use rustc_mir_dataflow::ResultsCursor;
|
||||
|
||||
use crate::{
|
||||
borrow_set::BorrowSet,
|
||||
|
|
|
@ -23,7 +23,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
|||
let mir = tcx.instance_mir(instance.def);
|
||||
let _mir_guard = crate::PrintOnPanic(|| {
|
||||
let mut buf = Vec::new();
|
||||
rustc_mir::util::write_mir_pretty(tcx, Some(instance.def_id()), &mut buf).unwrap();
|
||||
rustc_middle::mir::write_mir_pretty(tcx, Some(instance.def_id()), &mut buf).unwrap();
|
||||
String::from_utf8_lossy(&buf).into_owned()
|
||||
});
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ extern crate rustc_incremental;
|
|||
extern crate rustc_index;
|
||||
extern crate rustc_interface;
|
||||
extern crate rustc_metadata;
|
||||
extern crate rustc_mir;
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
extern crate rustc_target;
|
||||
|
|
|
@ -6,8 +6,8 @@ use rustc_errors::ErrorReported;
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir_pretty as pprust_hir;
|
||||
use rustc_middle::hir::map as hir_map;
|
||||
use rustc_middle::mir::{write_mir_graphviz, write_mir_pretty};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_mir::util::{write_mir_graphviz, write_mir_pretty};
|
||||
use rustc_session::config::{Input, PpAstTreeMode, PpHirMode, PpMode, PpSourceMode};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::Ident;
|
||||
|
|
|
@ -9,6 +9,8 @@ doctest = false
|
|||
[dependencies]
|
||||
rustc_arena = { path = "../rustc_arena" }
|
||||
bitflags = "1.2.1"
|
||||
either = "1.5.0"
|
||||
gsgdt = "0.1.2"
|
||||
tracing = "0.1"
|
||||
rustc-rayon-core = "0.3.1"
|
||||
polonius-engine = "0.13.0"
|
||||
|
@ -21,6 +23,7 @@ rustc_macros = { path = "../rustc_macros" }
|
|||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_query_system = { path = "../rustc_query_system" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_graphviz = { path = "../rustc_graphviz" }
|
||||
rustc_index = { path = "../rustc_index" }
|
||||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
#![feature(associated_type_defaults)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(thread_local_const_init)]
|
||||
#![feature(trusted_step)]
|
||||
#![feature(try_blocks)]
|
||||
#![feature(try_reserve)]
|
||||
#![feature(try_reserve_kind)]
|
||||
#![feature(nonzero_ops)]
|
||||
|
|
|
@ -42,11 +42,17 @@ pub use self::query::*;
|
|||
|
||||
pub mod abstract_const;
|
||||
pub mod coverage;
|
||||
mod generic_graph;
|
||||
pub mod generic_graphviz;
|
||||
mod graph_cyclic_cache;
|
||||
pub mod graphviz;
|
||||
pub mod interpret;
|
||||
pub mod mono;
|
||||
pub mod patch;
|
||||
mod predecessors;
|
||||
pub mod pretty;
|
||||
mod query;
|
||||
pub mod spanview;
|
||||
pub mod tcx;
|
||||
pub mod terminator;
|
||||
pub use terminator::*;
|
||||
|
@ -54,6 +60,12 @@ pub mod traversal;
|
|||
mod type_foldable;
|
||||
pub mod visit;
|
||||
|
||||
pub use self::generic_graph::graphviz_safe_def_name;
|
||||
pub use self::graphviz::write_mir_graphviz;
|
||||
pub use self::pretty::{
|
||||
create_dump_file, display_allocation, dump_enabled, dump_mir, write_mir_pretty, PassWhere,
|
||||
};
|
||||
|
||||
/// Types for locals
|
||||
pub type LocalDecls<'tcx> = IndexVec<Local, LocalDecl<'tcx>>;
|
||||
|
||||
|
@ -75,6 +87,22 @@ impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A streamlined trait that you can implement to create a pass; the
|
||||
/// pass will be named after the type, and it will consist of a main
|
||||
/// loop that goes over each available MIR and applies `run_pass`.
|
||||
pub trait MirPass<'tcx> {
|
||||
fn name(&self) -> Cow<'_, str> {
|
||||
let name = std::any::type_name::<Self>();
|
||||
if let Some(tail) = name.rfind(':') {
|
||||
Cow::from(&name[tail + 1..])
|
||||
} else {
|
||||
Cow::from(name)
|
||||
}
|
||||
}
|
||||
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>);
|
||||
}
|
||||
|
||||
/// The various "big phases" that MIR goes through.
|
||||
///
|
||||
/// These phases all describe dialects of MIR. Since all MIR uses the same datastructures, the
|
||||
|
|
|
@ -9,22 +9,18 @@ doctest = false
|
|||
[dependencies]
|
||||
either = "1.5.0"
|
||||
gsgdt = "0.1.2"
|
||||
polonius-engine = "0.13.0"
|
||||
regex = "1"
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
tracing = "0.1"
|
||||
rustc_apfloat = { path = "../rustc_apfloat" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr = { path = "../rustc_attr" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_graphviz = { path = "../rustc_graphviz" }
|
||||
rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_index = { path = "../rustc_index" }
|
||||
rustc_infer = { path = "../rustc_infer" }
|
||||
rustc_macros = { path = "../rustc_macros" }
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
|
||||
rustc_session = { path = "../rustc_session" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||
|
|
|
@ -5,12 +5,12 @@ use crate::interpret::{
|
|||
Immediate, InternKind, InterpCx, InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking, Scalar,
|
||||
ScalarMaybeUninit, StackPopCleanup,
|
||||
};
|
||||
use crate::util::pretty::display_allocation;
|
||||
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
use rustc_middle::mir::pretty::display_allocation;
|
||||
use rustc_middle::traits::Reveal;
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
|
|
|
@ -12,6 +12,7 @@ use rustc_middle::ty::layout::{self, LayoutError, LayoutOf, LayoutOfHelpers, TyA
|
|||
use rustc_middle::ty::{
|
||||
self, query::TyCtxtAt, subst::SubstsRef, ParamEnv, Ty, TyCtxt, TypeFoldable,
|
||||
};
|
||||
use rustc_mir_dataflow::storage::AlwaysLiveLocals;
|
||||
use rustc_session::Limit;
|
||||
use rustc_span::{Pos, Span};
|
||||
use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout};
|
||||
|
@ -22,7 +23,6 @@ use super::{
|
|||
ScalarMaybeUninit, StackPopJump,
|
||||
};
|
||||
use crate::transform::validate::equal_up_to_regions;
|
||||
use crate::util::storage::AlwaysLiveLocals;
|
||||
|
||||
pub struct InterpCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
|
||||
/// Stores the `Machine` instance.
|
||||
|
|
|
@ -15,6 +15,7 @@ use std::ptr;
|
|||
|
||||
use rustc_ast::Mutability;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_middle::mir::display_allocation;
|
||||
use rustc_middle::ty::{Instance, ParamEnv, TyCtxt};
|
||||
use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout};
|
||||
|
||||
|
@ -23,7 +24,6 @@ use super::{
|
|||
InterpResult, Machine, MayLeak, Pointer, PointerArithmetic, Provenance, Scalar,
|
||||
ScalarMaybeUninit,
|
||||
};
|
||||
use crate::util::pretty;
|
||||
|
||||
#[derive(Debug, PartialEq, Copy, Clone)]
|
||||
pub enum MemoryKind<T> {
|
||||
|
@ -851,7 +851,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> std::fmt::Debug for DumpAllocs<'a,
|
|||
for alloc_id in alloc.relocations().values().map(|tag| tag.get_alloc_id()) {
|
||||
allocs_to_print.push_back(alloc_id);
|
||||
}
|
||||
write!(fmt, "{}", pretty::display_allocation(tcx, alloc))
|
||||
write!(fmt, "{}", display_allocation(tcx, alloc))
|
||||
}
|
||||
|
||||
let mut allocs_to_print: VecDeque<_> = self.allocs.iter().copied().collect();
|
||||
|
|
|
@ -6,7 +6,6 @@ Rust MIR: a lowered representation of Rust.
|
|||
|
||||
#![feature(assert_matches)]
|
||||
#![cfg_attr(bootstrap, feature(bindings_after_at))]
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(control_flow_enum)]
|
||||
|
@ -19,9 +18,7 @@ Rust MIR: a lowered representation of Rust.
|
|||
#![feature(min_specialization)]
|
||||
#![feature(slice_ptr_get)]
|
||||
#![feature(option_get_or_insert_default)]
|
||||
#![feature(once_cell)]
|
||||
#![feature(never_type)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(trait_alias)]
|
||||
#![feature(trusted_len)]
|
||||
#![feature(trusted_step)]
|
||||
|
@ -33,7 +30,6 @@ extern crate tracing;
|
|||
extern crate rustc_middle;
|
||||
|
||||
pub mod const_eval;
|
||||
pub mod dataflow;
|
||||
pub mod interpret;
|
||||
pub mod transform;
|
||||
pub mod util;
|
||||
|
|
|
@ -12,6 +12,8 @@ use rustc_middle::ty::cast::CastTy;
|
|||
use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts};
|
||||
use rustc_middle::ty::{self, adjustment::PointerCast, Instance, InstanceDef, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{Binder, TraitPredicate, TraitRef};
|
||||
use rustc_mir_dataflow::impls::MaybeMutBorrowedLocals;
|
||||
use rustc_mir_dataflow::{self, Analysis};
|
||||
use rustc_span::{sym, Span, Symbol};
|
||||
use rustc_trait_selection::traits::error_reporting::InferCtxtExt;
|
||||
use rustc_trait_selection::traits::{self, SelectionContext, TraitEngine};
|
||||
|
@ -24,17 +26,15 @@ use super::qualifs::{self, CustomEq, HasMutInterior, NeedsDrop};
|
|||
use super::resolver::FlowSensitiveAnalysis;
|
||||
use super::{is_lang_panic_fn, ConstCx, Qualif};
|
||||
use crate::const_eval::is_unstable_const_fn;
|
||||
use crate::dataflow::impls::MaybeMutBorrowedLocals;
|
||||
use crate::dataflow::{self, Analysis};
|
||||
|
||||
// We are using `MaybeMutBorrowedLocals` as a proxy for whether an item may have been mutated
|
||||
// through a pointer prior to the given point. This is okay even though `MaybeMutBorrowedLocals`
|
||||
// kills locals upon `StorageDead` because a local will never be used after a `StorageDead`.
|
||||
type IndirectlyMutableResults<'mir, 'tcx> =
|
||||
dataflow::ResultsCursor<'mir, 'tcx, MaybeMutBorrowedLocals<'mir, 'tcx>>;
|
||||
rustc_mir_dataflow::ResultsCursor<'mir, 'tcx, MaybeMutBorrowedLocals<'mir, 'tcx>>;
|
||||
|
||||
type QualifResults<'mir, 'tcx, Q> =
|
||||
dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'mir, 'mir, 'tcx, Q>>;
|
||||
rustc_mir_dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'mir, 'mir, 'tcx, Q>>;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Qualifs<'mir, 'tcx> {
|
||||
|
|
|
@ -9,7 +9,6 @@ use rustc_middle::mir::{self, BasicBlock, Local, Location};
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use super::{qualifs, ConstCx, Qualif};
|
||||
use crate::dataflow;
|
||||
|
||||
/// A `Visitor` that propagates qualifs between locals. This defines the transfer function of
|
||||
/// `FlowSensitiveAnalysis`.
|
||||
|
@ -165,7 +164,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<Q> dataflow::AnalysisDomain<'tcx> for FlowSensitiveAnalysis<'_, '_, 'tcx, Q>
|
||||
impl<Q> rustc_mir_dataflow::AnalysisDomain<'tcx> for FlowSensitiveAnalysis<'_, '_, 'tcx, Q>
|
||||
where
|
||||
Q: Qualif,
|
||||
{
|
||||
|
@ -182,7 +181,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<Q> dataflow::Analysis<'tcx> for FlowSensitiveAnalysis<'_, '_, 'tcx, Q>
|
||||
impl<Q> rustc_mir_dataflow::Analysis<'tcx> for FlowSensitiveAnalysis<'_, '_, 'tcx, Q>
|
||||
where
|
||||
Q: Qualif,
|
||||
{
|
||||
|
|
|
@ -1,26 +1,5 @@
|
|||
use rustc_middle::mir::Body;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use std::borrow::Cow;
|
||||
|
||||
pub mod check_consts;
|
||||
pub mod promote_consts;
|
||||
pub mod rustc_peek;
|
||||
pub mod validate;
|
||||
|
||||
/// Generates a default name for the pass based on the name of the
|
||||
/// type `T`.
|
||||
pub fn default_name<T: ?Sized>() -> Cow<'static, str> {
|
||||
let name = std::any::type_name::<T>();
|
||||
if let Some(tail) = name.rfind(':') { Cow::from(&name[tail + 1..]) } else { Cow::from(name) }
|
||||
}
|
||||
|
||||
/// A streamlined trait that you can implement to create a pass; the
|
||||
/// pass will be named after the type, and it will consist of a main
|
||||
/// loop that goes over each available MIR and applies `run_pass`.
|
||||
pub trait MirPass<'tcx> {
|
||||
fn name(&self) -> Cow<'_, str> {
|
||||
default_name::<Self>()
|
||||
}
|
||||
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>);
|
||||
}
|
||||
pub use rustc_middle::mir::MirPass;
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
//! Validates the MIR to ensure that invariants are upheld.
|
||||
|
||||
use crate::dataflow::impls::MaybeStorageLive;
|
||||
use crate::dataflow::{Analysis, ResultsCursor};
|
||||
use crate::util::storage::AlwaysLiveLocals;
|
||||
|
||||
use super::MirPass;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
|
@ -17,6 +13,9 @@ use rustc_middle::mir::{
|
|||
};
|
||||
use rustc_middle::ty::fold::BottomUpFolder;
|
||||
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_mir_dataflow::impls::MaybeStorageLive;
|
||||
use rustc_mir_dataflow::storage::AlwaysLiveLocals;
|
||||
use rustc_mir_dataflow::{Analysis, ResultsCursor};
|
||||
use rustc_target::abi::Size;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
|
|
@ -1,20 +1,8 @@
|
|||
pub mod aggregate;
|
||||
pub mod elaborate_drops;
|
||||
pub mod patch;
|
||||
pub mod storage;
|
||||
|
||||
mod alignment;
|
||||
pub mod collect_writes;
|
||||
mod find_self_call;
|
||||
mod generic_graph;
|
||||
pub mod generic_graphviz;
|
||||
mod graphviz;
|
||||
pub mod pretty;
|
||||
pub mod spanview;
|
||||
|
||||
pub use self::aggregate::expand_aggregate;
|
||||
pub use self::alignment::is_disaligned;
|
||||
pub use self::find_self_call::find_self_call;
|
||||
pub use self::generic_graph::graphviz_safe_def_name;
|
||||
pub use self::graphviz::write_mir_graphviz;
|
||||
pub use self::pretty::{dump_enabled, dump_mir, write_mir_fn, write_mir_pretty, PassWhere};
|
||||
|
|
24
compiler/rustc_mir_dataflow/Cargo.toml
Normal file
24
compiler/rustc_mir_dataflow/Cargo.toml
Normal file
|
@ -0,0 +1,24 @@
|
|||
[package]
|
||||
authors = ["The Rust Project Developers"]
|
||||
name = "rustc_mir_dataflow"
|
||||
version = "0.0.0"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
polonius-engine = "0.13.0"
|
||||
regex = "1"
|
||||
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
|
||||
tracing = "0.1"
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_graphviz = { path = "../rustc_graphviz" }
|
||||
rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_index = { path = "../rustc_index" }
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
rustc_session = { path = "../rustc_session" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
rustc_span = { path = "../rustc_span" }
|
|
@ -1,4 +1,4 @@
|
|||
use crate::util::elaborate_drops::DropFlagState;
|
||||
use crate::elaborate_drops::DropFlagState;
|
||||
use rustc_middle::mir::{self, Body, Location};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_target::abi::VariantIdx;
|
|
@ -1,7 +1,7 @@
|
|||
use crate::util::patch::MirPatch;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::mir::patch::MirPatch;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::traits::Reveal;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
|
@ -11,6 +11,7 @@ use rustc_hir::def_id::DefId;
|
|||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_middle::mir::{self, traversal, BasicBlock};
|
||||
use rustc_middle::mir::{create_dump_file, dump_enabled};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
|
||||
|
@ -20,7 +21,6 @@ use super::{
|
|||
visit_results, Analysis, Direction, GenKill, GenKillAnalysis, GenKillSet, JoinSemiLattice,
|
||||
ResultsCursor, ResultsVisitor,
|
||||
};
|
||||
use crate::util::pretty::{create_dump_file, dump_enabled};
|
||||
|
||||
/// A dataflow analysis that has converged to fixpoint.
|
||||
pub struct Results<'tcx, A>
|
|
@ -147,18 +147,18 @@ where
|
|||
}
|
||||
|
||||
impl<C> DebugWithContext<C> for rustc_middle::mir::Local {}
|
||||
impl<C> DebugWithContext<C> for crate::dataflow::move_paths::InitIndex {}
|
||||
impl<C> DebugWithContext<C> for crate::move_paths::InitIndex {}
|
||||
|
||||
impl<'tcx, C> DebugWithContext<C> for crate::dataflow::move_paths::MovePathIndex
|
||||
impl<'tcx, C> DebugWithContext<C> for crate::move_paths::MovePathIndex
|
||||
where
|
||||
C: crate::dataflow::move_paths::HasMoveData<'tcx>,
|
||||
C: crate::move_paths::HasMoveData<'tcx>,
|
||||
{
|
||||
fn fmt_with(&self, ctxt: &C, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", ctxt.move_data().move_paths[*self])
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, C> DebugWithContext<C> for crate::dataflow::lattice::Dual<T>
|
||||
impl<T, C> DebugWithContext<C> for crate::lattice::Dual<T>
|
||||
where
|
||||
T: DebugWithContext<C>,
|
||||
{
|
|
@ -6,11 +6,11 @@ use std::{io, ops, str};
|
|||
|
||||
use regex::Regex;
|
||||
use rustc_graphviz as dot;
|
||||
use rustc_middle::mir::graphviz_safe_def_name;
|
||||
use rustc_middle::mir::{self, BasicBlock, Body, Location};
|
||||
|
||||
use super::fmt::{DebugDiffWithAdapter, DebugWithAdapter, DebugWithContext};
|
||||
use super::{Analysis, Direction, Results, ResultsRefCursor, ResultsVisitor};
|
||||
use crate::util::graphviz_safe_def_name;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum OutputStyle {
|
|
@ -1,6 +1,6 @@
|
|||
pub use super::*;
|
||||
use super::*;
|
||||
|
||||
use crate::dataflow::{AnalysisDomain, GenKill, GenKillAnalysis};
|
||||
use crate::{AnalysisDomain, GenKill, GenKillAnalysis};
|
||||
use rustc_middle::mir::visit::Visitor;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{ParamEnv, TyCtxt};
|
|
@ -2,7 +2,7 @@
|
|||
//!
|
||||
//! A local will be maybe initialized if *any* projections of that local might be initialized.
|
||||
|
||||
use crate::dataflow::{self, GenKill};
|
||||
use crate::GenKill;
|
||||
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_middle::mir::visit::{PlaceContext, Visitor};
|
||||
|
@ -10,7 +10,7 @@ use rustc_middle::mir::{self, BasicBlock, Local, Location};
|
|||
|
||||
pub struct MaybeInitializedLocals;
|
||||
|
||||
impl dataflow::AnalysisDomain<'tcx> for MaybeInitializedLocals {
|
||||
impl crate::AnalysisDomain<'tcx> for MaybeInitializedLocals {
|
||||
type Domain = BitSet<Local>;
|
||||
|
||||
const NAME: &'static str = "maybe_init_locals";
|
||||
|
@ -28,7 +28,7 @@ impl dataflow::AnalysisDomain<'tcx> for MaybeInitializedLocals {
|
|||
}
|
||||
}
|
||||
|
||||
impl dataflow::GenKillAnalysis<'tcx> for MaybeInitializedLocals {
|
||||
impl crate::GenKillAnalysis<'tcx> for MaybeInitializedLocals {
|
||||
type Idx = Local;
|
||||
|
||||
fn statement_effect(
|
|
@ -2,7 +2,7 @@ use rustc_index::bit_set::BitSet;
|
|||
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{self, Local, Location};
|
||||
|
||||
use crate::dataflow::{AnalysisDomain, Backward, GenKill, GenKillAnalysis};
|
||||
use crate::{AnalysisDomain, Backward, GenKill, GenKillAnalysis};
|
||||
|
||||
/// A [live-variable dataflow analysis][liveness].
|
||||
///
|
|
@ -7,18 +7,15 @@ use rustc_index::vec::Idx;
|
|||
use rustc_middle::mir::{self, Body, Location};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
|
||||
use super::MoveDataParamEnv;
|
||||
|
||||
use crate::util::elaborate_drops::DropFlagState;
|
||||
|
||||
use super::move_paths::{HasMoveData, InitIndex, InitKind, MoveData, MovePathIndex};
|
||||
use super::{lattice, AnalysisDomain, GenKill, GenKillAnalysis};
|
||||
|
||||
use super::drop_flag_effects_for_function_entry;
|
||||
use super::drop_flag_effects_for_location;
|
||||
use super::on_lookup_result_bits;
|
||||
use crate::dataflow::drop_flag_effects;
|
||||
use crate::dataflow::framework::SwitchIntEdgeEffects;
|
||||
use crate::drop_flag_effects;
|
||||
use crate::drop_flag_effects_for_function_entry;
|
||||
use crate::drop_flag_effects_for_location;
|
||||
use crate::elaborate_drops::DropFlagState;
|
||||
use crate::framework::SwitchIntEdgeEffects;
|
||||
use crate::move_paths::{HasMoveData, InitIndex, InitKind, MoveData, MovePathIndex};
|
||||
use crate::on_lookup_result_bits;
|
||||
use crate::MoveDataParamEnv;
|
||||
use crate::{lattice, AnalysisDomain, GenKill, GenKillAnalysis};
|
||||
|
||||
mod borrowed_locals;
|
||||
mod init_locals;
|
|
@ -1,7 +1,7 @@
|
|||
pub use super::*;
|
||||
|
||||
use crate::dataflow::{self, GenKill, Results, ResultsRefCursor};
|
||||
use crate::util::storage::AlwaysLiveLocals;
|
||||
use crate::storage::AlwaysLiveLocals;
|
||||
use crate::{GenKill, Results, ResultsRefCursor};
|
||||
use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
use std::cell::RefCell;
|
||||
|
@ -17,7 +17,7 @@ impl MaybeStorageLive {
|
|||
}
|
||||
}
|
||||
|
||||
impl dataflow::AnalysisDomain<'tcx> for MaybeStorageLive {
|
||||
impl crate::AnalysisDomain<'tcx> for MaybeStorageLive {
|
||||
type Domain = BitSet<Local>;
|
||||
|
||||
const NAME: &'static str = "maybe_storage_live";
|
||||
|
@ -39,7 +39,7 @@ impl dataflow::AnalysisDomain<'tcx> for MaybeStorageLive {
|
|||
}
|
||||
}
|
||||
|
||||
impl dataflow::GenKillAnalysis<'tcx> for MaybeStorageLive {
|
||||
impl crate::GenKillAnalysis<'tcx> for MaybeStorageLive {
|
||||
type Idx = Local;
|
||||
|
||||
fn statement_effect(
|
||||
|
@ -97,7 +97,7 @@ impl<'mir, 'tcx> MaybeRequiresStorage<'mir, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'mir, 'tcx> dataflow::AnalysisDomain<'tcx> for MaybeRequiresStorage<'mir, 'tcx> {
|
||||
impl<'mir, 'tcx> crate::AnalysisDomain<'tcx> for MaybeRequiresStorage<'mir, 'tcx> {
|
||||
type Domain = BitSet<Local>;
|
||||
|
||||
const NAME: &'static str = "requires_storage";
|
||||
|
@ -116,7 +116,7 @@ impl<'mir, 'tcx> dataflow::AnalysisDomain<'tcx> for MaybeRequiresStorage<'mir, '
|
|||
}
|
||||
}
|
||||
|
||||
impl<'mir, 'tcx> dataflow::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'mir, 'tcx> {
|
||||
impl<'mir, 'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'mir, 'tcx> {
|
||||
type Idx = Local;
|
||||
|
||||
fn before_statement_effect(
|
|
@ -1,3 +1,21 @@
|
|||
#![feature(associated_type_defaults)]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(const_panic)]
|
||||
#![feature(exact_size_is_empty)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(once_cell)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(trusted_step)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate tracing;
|
||||
#[macro_use]
|
||||
extern crate rustc_middle;
|
||||
|
||||
use rustc_ast::{self as ast, MetaItem};
|
||||
use rustc_middle::ty;
|
||||
use rustc_session::Session;
|
||||
|
@ -17,9 +35,12 @@ pub use self::framework::{
|
|||
use self::move_paths::MoveData;
|
||||
|
||||
pub mod drop_flag_effects;
|
||||
pub mod elaborate_drops;
|
||||
mod framework;
|
||||
pub mod impls;
|
||||
pub mod move_paths;
|
||||
pub mod rustc_peek;
|
||||
pub mod storage;
|
||||
|
||||
pub(crate) mod indexes {
|
||||
pub(crate) use super::move_paths::MovePathIndex;
|
|
@ -5,25 +5,25 @@ use rustc_span::symbol::sym;
|
|||
use rustc_span::Span;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use crate::transform::MirPass;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_middle::mir::MirPass;
|
||||
use rustc_middle::mir::{self, Body, Local, Location};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
|
||||
use crate::dataflow::impls::{
|
||||
use crate::impls::{
|
||||
DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeLiveLocals, MaybeMutBorrowedLocals,
|
||||
MaybeUninitializedPlaces,
|
||||
};
|
||||
use crate::dataflow::move_paths::{HasMoveData, MoveData};
|
||||
use crate::dataflow::move_paths::{LookupResult, MovePathIndex};
|
||||
use crate::dataflow::MoveDataParamEnv;
|
||||
use crate::dataflow::{Analysis, JoinSemiLattice, Results, ResultsCursor};
|
||||
use crate::move_paths::{HasMoveData, MoveData};
|
||||
use crate::move_paths::{LookupResult, MovePathIndex};
|
||||
use crate::MoveDataParamEnv;
|
||||
use crate::{Analysis, JoinSemiLattice, Results, ResultsCursor};
|
||||
|
||||
pub struct SanityCheck;
|
||||
|
||||
impl<'tcx> MirPass<'tcx> for SanityCheck {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
use crate::dataflow::has_rustc_mir_with;
|
||||
use crate::has_rustc_mir_with;
|
||||
let def_id = body.source.def_id();
|
||||
if !tcx.has_attr(def_id, sym::rustc_mir) {
|
||||
debug!("skipping rustc_peek::SanityCheck on {}", tcx.def_path_str(def_id));
|
|
@ -19,6 +19,7 @@ rustc_hir = { path = "../rustc_hir" }
|
|||
rustc_index = { path = "../rustc_index" }
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_mir = { path = "../rustc_mir" }
|
||||
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
|
||||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
rustc_session = { path = "../rustc_session" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
|
|
|
@ -2,8 +2,8 @@ use rustc_middle::mir::*;
|
|||
use rustc_middle::ty::TyCtxt;
|
||||
|
||||
use crate::util;
|
||||
use crate::util::patch::MirPatch;
|
||||
use crate::MirPass;
|
||||
use rustc_middle::mir::patch::MirPatch;
|
||||
|
||||
// This pass moves values being dropped that are within a packed
|
||||
// struct to a separate local before dropping them, to ensure that
|
||||
|
|
|
@ -111,9 +111,9 @@
|
|||
use super::graph::{BasicCoverageBlock, BasicCoverageBlockData, CoverageGraph};
|
||||
use super::spans::CoverageSpan;
|
||||
|
||||
use crate::util::generic_graphviz::GraphvizWriter;
|
||||
use crate::util::pretty;
|
||||
use crate::util::spanview::{self, SpanViewable};
|
||||
use rustc_middle::mir::create_dump_file;
|
||||
use rustc_middle::mir::generic_graphviz::GraphvizWriter;
|
||||
use rustc_middle::mir::spanview::{self, SpanViewable};
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_middle::mir::coverage::*;
|
||||
|
@ -641,7 +641,7 @@ pub(super) fn dump_coverage_spanview(
|
|||
let def_id = mir_source.def_id();
|
||||
|
||||
let span_viewables = span_viewables(tcx, mir_body, basic_coverage_blocks, &coverage_spans);
|
||||
let mut file = pretty::create_dump_file(tcx, "html", None, pass_name, &0, mir_source)
|
||||
let mut file = create_dump_file(tcx, "html", None, pass_name, &0, mir_source)
|
||||
.expect("Unexpected error creating MIR spanview HTML file");
|
||||
let crate_name = tcx.crate_name(def_id.krate);
|
||||
let item_name = tcx.def_path(def_id).to_filename_friendly_no_crate();
|
||||
|
@ -743,7 +743,7 @@ pub(super) fn dump_coverage_graphviz(
|
|||
.join("\n ")
|
||||
));
|
||||
}
|
||||
let mut file = pretty::create_dump_file(tcx, "dot", None, pass_name, &0, mir_source)
|
||||
let mut file = create_dump_file(tcx, "dot", None, pass_name, &0, mir_source)
|
||||
.expect("Unexpected error creating BasicCoverageBlock graphviz DOT file");
|
||||
graphviz_writer
|
||||
.write_graphviz(tcx, &mut file)
|
||||
|
|
|
@ -12,7 +12,6 @@ use counters::CoverageCounters;
|
|||
use graph::{BasicCoverageBlock, BasicCoverageBlockData, CoverageGraph};
|
||||
use spans::{CoverageSpan, CoverageSpans};
|
||||
|
||||
use crate::util::pretty;
|
||||
use crate::MirPass;
|
||||
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
|
@ -25,6 +24,7 @@ use rustc_middle::hir::map::blocks::FnLikeNode;
|
|||
use rustc_middle::ich::StableHashingContext;
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::mir::coverage::*;
|
||||
use rustc_middle::mir::dump_enabled;
|
||||
use rustc_middle::mir::{
|
||||
self, BasicBlock, BasicBlockData, Coverage, SourceInfo, Statement, StatementKind, Terminator,
|
||||
TerminatorKind,
|
||||
|
@ -159,7 +159,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
|
|||
let mut graphviz_data = debug::GraphvizData::new();
|
||||
let mut debug_used_expressions = debug::UsedExpressions::new();
|
||||
|
||||
let dump_mir = pretty::dump_enabled(tcx, self.pass_name, def_id);
|
||||
let dump_mir = dump_enabled(tcx, self.pass_name, def_id);
|
||||
let dump_graphviz = dump_mir && tcx.sess.opts.debugging_opts.dump_mir_graphviz;
|
||||
let dump_spanview = dump_mir && tcx.sess.opts.debugging_opts.dump_mir_spanview.is_some();
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
use super::debug::term_type;
|
||||
use super::graph::{BasicCoverageBlock, BasicCoverageBlockData, CoverageGraph, START_BCB};
|
||||
|
||||
use crate::util::spanview::source_range_no_file;
|
||||
|
||||
use rustc_data_structures::graph::WithNumNodes;
|
||||
use rustc_middle::mir::spanview::source_range_no_file;
|
||||
use rustc_middle::mir::{
|
||||
self, AggregateKind, BasicBlock, FakeReadCause, Rvalue, Statement, StatementKind, Terminator,
|
||||
TerminatorKind,
|
||||
};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
||||
use rustc_span::source_map::original_sp;
|
||||
use rustc_span::{BytePos, ExpnKind, MacroKind, Span, Symbol};
|
||||
|
||||
|
|
|
@ -96,10 +96,7 @@
|
|||
//! [previous attempt]: https://github.com/rust-lang/rust/pull/47954
|
||||
//! [subsequent approach]: https://github.com/rust-lang/rust/pull/71003
|
||||
|
||||
use crate::{
|
||||
util::{dump_mir, PassWhere},
|
||||
MirPass,
|
||||
};
|
||||
use crate::MirPass;
|
||||
use itertools::Itertools;
|
||||
use rustc_data_structures::unify::{InPlaceUnificationTable, UnifyKey};
|
||||
use rustc_index::{
|
||||
|
@ -108,13 +105,14 @@ use rustc_index::{
|
|||
};
|
||||
use rustc_middle::mir::tcx::PlaceTy;
|
||||
use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{dump_mir, PassWhere};
|
||||
use rustc_middle::mir::{
|
||||
traversal, Body, InlineAsmOperand, Local, LocalKind, Location, Operand, Place, PlaceElem,
|
||||
Rvalue, Statement, StatementKind, Terminator, TerminatorKind,
|
||||
};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_mir::dataflow::impls::{MaybeInitializedLocals, MaybeLiveLocals};
|
||||
use rustc_mir::dataflow::Analysis;
|
||||
use rustc_mir_dataflow::impls::{MaybeInitializedLocals, MaybeLiveLocals};
|
||||
use rustc_mir_dataflow::Analysis;
|
||||
|
||||
// Empirical measurements have resulted in some observations:
|
||||
// - Running on a body with a single block and 500 locals takes barely any time
|
||||
|
|
|
@ -5,9 +5,9 @@ use std::fmt;
|
|||
use std::fs::File;
|
||||
use std::io;
|
||||
|
||||
use crate::util as mir_util;
|
||||
use crate::MirPass;
|
||||
use rustc_middle::mir::Body;
|
||||
use rustc_middle::mir::{dump_enabled, dump_mir, write_mir_pretty};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config::{OutputFilenames, OutputType};
|
||||
|
||||
|
@ -39,21 +39,14 @@ pub fn on_mir_pass<'tcx>(
|
|||
body: &Body<'tcx>,
|
||||
is_after: bool,
|
||||
) {
|
||||
if mir_util::dump_enabled(tcx, pass_name, body.source.def_id()) {
|
||||
mir_util::dump_mir(
|
||||
tcx,
|
||||
Some(pass_num),
|
||||
pass_name,
|
||||
&Disambiguator { is_after },
|
||||
body,
|
||||
|_, _| Ok(()),
|
||||
);
|
||||
if dump_enabled(tcx, pass_name, body.source.def_id()) {
|
||||
dump_mir(tcx, Some(pass_num), pass_name, &Disambiguator { is_after }, body, |_, _| Ok(()));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn emit_mir(tcx: TyCtxt<'_>, outputs: &OutputFilenames) -> io::Result<()> {
|
||||
let path = outputs.path(OutputType::Mir);
|
||||
let mut f = io::BufWriter::new(File::create(&path)?);
|
||||
mir_util::write_mir_pretty(tcx, None, &mut f)?;
|
||||
write_mir_pretty(tcx, None, &mut f)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{util::patch::MirPatch, MirPass};
|
||||
use rustc_middle::mir::patch::MirPatch;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use std::fmt::Debug;
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
use crate::util::elaborate_drops::{elaborate_drop, DropFlagState, Unwind};
|
||||
use crate::util::elaborate_drops::{DropElaborator, DropFlagMode, DropStyle};
|
||||
use crate::util::patch::MirPatch;
|
||||
use crate::MirPass;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_middle::mir::patch::MirPatch;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_mir::dataflow;
|
||||
use rustc_mir::dataflow::impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
|
||||
use rustc_mir::dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
|
||||
use rustc_mir::dataflow::on_lookup_result_bits;
|
||||
use rustc_mir::dataflow::MoveDataParamEnv;
|
||||
use rustc_mir::dataflow::{on_all_children_bits, on_all_drop_children_bits};
|
||||
use rustc_mir::dataflow::{Analysis, ResultsCursor};
|
||||
use rustc_mir_dataflow::elaborate_drops::{elaborate_drop, DropFlagState, Unwind};
|
||||
use rustc_mir_dataflow::elaborate_drops::{DropElaborator, DropFlagMode, DropStyle};
|
||||
use rustc_mir_dataflow::impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
|
||||
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
|
||||
use rustc_mir_dataflow::on_lookup_result_bits;
|
||||
use rustc_mir_dataflow::MoveDataParamEnv;
|
||||
use rustc_mir_dataflow::{on_all_children_bits, on_all_drop_children_bits};
|
||||
use rustc_mir_dataflow::{Analysis, ResultsCursor};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use std::fmt;
|
||||
|
@ -214,14 +213,14 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> {
|
|||
}
|
||||
|
||||
fn field_subpath(&self, path: Self::Path, field: Field) -> Option<Self::Path> {
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| match e {
|
||||
rustc_mir_dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| match e {
|
||||
ProjectionElem::Field(idx, _) => idx == field,
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
|
||||
fn array_subpath(&self, path: Self::Path, index: u64, size: u64) -> Option<Self::Path> {
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| match e {
|
||||
rustc_mir_dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| match e {
|
||||
ProjectionElem::ConstantIndex { offset, min_length, from_end } => {
|
||||
debug_assert!(size == min_length, "min_length should be exact for arrays");
|
||||
assert!(!from_end, "from_end should not be used for array element ConstantIndex");
|
||||
|
@ -232,13 +231,13 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> {
|
|||
}
|
||||
|
||||
fn deref_subpath(&self, path: Self::Path) -> Option<Self::Path> {
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| {
|
||||
rustc_mir_dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| {
|
||||
e == ProjectionElem::Deref
|
||||
})
|
||||
}
|
||||
|
||||
fn downcast_subpath(&self, path: Self::Path, variant: VariantIdx) -> Option<Self::Path> {
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| match e {
|
||||
rustc_mir_dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| match e {
|
||||
ProjectionElem::Downcast(_, idx) => idx == variant,
|
||||
_ => false,
|
||||
})
|
||||
|
@ -513,9 +512,14 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
|||
|
||||
fn drop_flags_for_args(&mut self) {
|
||||
let loc = Location::START;
|
||||
dataflow::drop_flag_effects_for_function_entry(self.tcx, self.body, self.env, |path, ds| {
|
||||
self.set_drop_flag(loc, path, ds);
|
||||
})
|
||||
rustc_mir_dataflow::drop_flag_effects_for_function_entry(
|
||||
self.tcx,
|
||||
self.body,
|
||||
self.env,
|
||||
|path, ds| {
|
||||
self.set_drop_flag(loc, path, ds);
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn drop_flags_for_locs(&mut self) {
|
||||
|
@ -556,7 +560,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
|||
}
|
||||
}
|
||||
let loc = Location { block: bb, statement_index: i };
|
||||
dataflow::drop_flag_effects_for_location(
|
||||
rustc_mir_dataflow::drop_flag_effects_for_location(
|
||||
self.tcx,
|
||||
self.body,
|
||||
self.env,
|
||||
|
|
|
@ -50,24 +50,24 @@
|
|||
//! Otherwise it drops all the values in scope at the last suspension point.
|
||||
|
||||
use crate::simplify;
|
||||
use crate::util::dump_mir;
|
||||
use crate::util::expand_aggregate;
|
||||
use crate::util::storage;
|
||||
use crate::MirPass;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_index::bit_set::{BitMatrix, BitSet};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_middle::mir::dump_mir;
|
||||
use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::subst::{Subst, SubstsRef};
|
||||
use rustc_middle::ty::GeneratorSubsts;
|
||||
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt};
|
||||
use rustc_mir::dataflow::impls::{
|
||||
use rustc_mir_dataflow::impls::{
|
||||
MaybeBorrowedLocals, MaybeLiveLocals, MaybeRequiresStorage, MaybeStorageLive,
|
||||
};
|
||||
use rustc_mir::dataflow::{self, Analysis};
|
||||
use rustc_mir_dataflow::storage;
|
||||
use rustc_mir_dataflow::{self, Analysis};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
use std::{iter, ops};
|
||||
|
@ -468,7 +468,7 @@ fn locals_live_across_suspend_points(
|
|||
.iterate_to_fixpoint();
|
||||
|
||||
let mut borrowed_locals_cursor =
|
||||
dataflow::ResultsCursor::new(body_ref, &borrowed_locals_results);
|
||||
rustc_mir_dataflow::ResultsCursor::new(body_ref, &borrowed_locals_results);
|
||||
|
||||
// Calculate the MIR locals that we actually need to keep storage around
|
||||
// for.
|
||||
|
@ -476,7 +476,7 @@ fn locals_live_across_suspend_points(
|
|||
.into_engine(tcx, body_ref)
|
||||
.iterate_to_fixpoint();
|
||||
let mut requires_storage_cursor =
|
||||
dataflow::ResultsCursor::new(body_ref, &requires_storage_results);
|
||||
rustc_mir_dataflow::ResultsCursor::new(body_ref, &requires_storage_results);
|
||||
|
||||
// Calculate the liveness of MIR locals ignoring borrows.
|
||||
let mut liveness = MaybeLiveLocals
|
||||
|
@ -616,7 +616,7 @@ fn compute_storage_conflicts(
|
|||
body: &'mir Body<'tcx>,
|
||||
saved_locals: &GeneratorSavedLocals,
|
||||
always_live_locals: storage::AlwaysLiveLocals,
|
||||
requires_storage: dataflow::Results<'tcx, MaybeRequiresStorage<'mir, 'tcx>>,
|
||||
requires_storage: rustc_mir_dataflow::Results<'tcx, MaybeRequiresStorage<'mir, 'tcx>>,
|
||||
) -> BitMatrix<GeneratorSavedLocal, GeneratorSavedLocal> {
|
||||
assert_eq!(body.local_decls.len(), saved_locals.domain_size());
|
||||
|
||||
|
@ -671,7 +671,7 @@ struct StorageConflictVisitor<'mir, 'tcx, 's> {
|
|||
local_conflicts: BitMatrix<Local, Local>,
|
||||
}
|
||||
|
||||
impl dataflow::ResultsVisitor<'mir, 'tcx> for StorageConflictVisitor<'mir, 'tcx, '_> {
|
||||
impl rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx> for StorageConflictVisitor<'mir, 'tcx, '_> {
|
||||
type FlowState = BitSet<Local>;
|
||||
|
||||
fn visit_statement_before_primary_effect(
|
||||
|
@ -865,8 +865,8 @@ fn insert_switch<'tcx>(
|
|||
|
||||
fn elaborate_generator_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
use crate::shim::DropShimElaborator;
|
||||
use crate::util::elaborate_drops::{elaborate_drop, Unwind};
|
||||
use crate::util::patch::MirPatch;
|
||||
use rustc_middle::mir::patch::MirPatch;
|
||||
use rustc_mir_dataflow::elaborate_drops::{elaborate_drop, Unwind};
|
||||
|
||||
// Note that `elaborate_drops` only drops the upvars of a generator, and
|
||||
// this is ok because `open_drop` can only be reached within that own
|
||||
|
|
|
@ -75,9 +75,9 @@ mod unreachable_prop;
|
|||
|
||||
use rustc_mir::transform::check_consts;
|
||||
use rustc_mir::transform::promote_consts;
|
||||
use rustc_mir::transform::rustc_peek;
|
||||
use rustc_mir::transform::validate;
|
||||
use rustc_mir::transform::MirPass;
|
||||
use rustc_mir_dataflow::rustc_peek;
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
check_unsafety::provide(providers);
|
||||
|
@ -274,7 +274,7 @@ fn mir_const<'tcx>(
|
|||
|
||||
let mut body = tcx.mir_built(def).steal();
|
||||
|
||||
util::dump_mir(tcx, None, "mir_map", &0, &body, |_, _| Ok(()));
|
||||
rustc_middle::mir::dump_mir(tcx, None, "mir_map", &0, &body, |_, _| Ok(()));
|
||||
|
||||
run_passes(
|
||||
tcx,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::util::patch::MirPatch;
|
||||
use crate::MirPass;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_middle::mir::patch::MirPatch;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
|
|
@ -15,13 +15,13 @@ use rustc_target::spec::abi::Abi;
|
|||
use std::fmt;
|
||||
use std::iter;
|
||||
|
||||
use crate::util::elaborate_drops::{self, DropElaborator, DropFlagMode, DropStyle};
|
||||
use crate::util::expand_aggregate;
|
||||
use crate::util::patch::MirPatch;
|
||||
use crate::{
|
||||
abort_unwinding_calls, add_call_guards, add_moves_for_packed_drops, remove_noop_landing_pads,
|
||||
run_passes, simplify,
|
||||
};
|
||||
use rustc_middle::mir::patch::MirPatch;
|
||||
use rustc_mir_dataflow::elaborate_drops::{self, DropElaborator, DropFlagMode, DropStyle};
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
providers.mir_shims = make_shim;
|
||||
|
@ -940,7 +940,7 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> {
|
|||
span,
|
||||
);
|
||||
|
||||
crate::util::dump_mir(tcx, None, "mir_map", &0, &body, |_, _| Ok(()));
|
||||
rustc_middle::mir::dump_mir(tcx, None, "mir_map", &0, &body, |_, _| Ok(()));
|
||||
|
||||
body
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ extern crate rustc_infer;
|
|||
extern crate rustc_lexer;
|
||||
extern crate rustc_lint;
|
||||
extern crate rustc_middle;
|
||||
extern crate rustc_mir;
|
||||
extern crate rustc_mir_dataflow;
|
||||
extern crate rustc_parse;
|
||||
extern crate rustc_parse_format;
|
||||
extern crate rustc_session;
|
||||
|
|
|
@ -15,7 +15,7 @@ use rustc_middle::mir::{
|
|||
Mutability,
|
||||
};
|
||||
use rustc_middle::ty::{self, fold::TypeVisitor, Ty, TyCtxt};
|
||||
use rustc_mir::dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, ResultsCursor};
|
||||
use rustc_mir_dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, ResultsCursor};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::{BytePos, Span};
|
||||
use rustc_span::sym;
|
||||
|
@ -625,7 +625,10 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
|
|||
.flat_map(HybridBitSet::iter)
|
||||
.collect();
|
||||
|
||||
if ContainsRegion(self.cx.tcx).visit_ty(self.body.local_decls[*dest].ty).is_break() {
|
||||
if ContainsRegion(self.cx.tcx)
|
||||
.visit_ty(self.body.local_decls[*dest].ty)
|
||||
.is_break()
|
||||
{
|
||||
mutable_variables.push(*dest);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue