mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Do not clone MIR for const-prop lint.
This commit is contained in:
parent
5e71913156
commit
5d18a0edb4
@ -105,25 +105,12 @@ impl<'tcx> MirLint<'tcx> for ConstProp {
|
||||
|
||||
trace!("ConstProp starting for {:?}", def_id);
|
||||
|
||||
let dummy_body = &Body::new(
|
||||
body.source,
|
||||
(*body.basic_blocks).to_owned(),
|
||||
body.source_scopes.clone(),
|
||||
body.local_decls.clone(),
|
||||
Default::default(),
|
||||
body.arg_count,
|
||||
Default::default(),
|
||||
body.span,
|
||||
body.generator_kind(),
|
||||
body.tainted_by_errors,
|
||||
);
|
||||
|
||||
// FIXME(oli-obk, eddyb) Optimize locals (or even local paths) to hold
|
||||
// constants, instead of just checking for const-folding succeeding.
|
||||
// That would require a uniform one-def no-mutation analysis
|
||||
// and RPO (or recursing when needing the value of a local).
|
||||
let mut optimization_finder = ConstPropagator::new(body, dummy_body, tcx);
|
||||
optimization_finder.visit_body(body);
|
||||
let mut linter = ConstPropagator::new(body, tcx);
|
||||
linter.visit_body(body);
|
||||
|
||||
trace!("ConstProp done for {:?}", def_id);
|
||||
}
|
||||
@ -169,11 +156,7 @@ impl<'tcx> ty::layout::HasParamEnv<'tcx> for ConstPropagator<'_, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
fn new(
|
||||
body: &Body<'tcx>,
|
||||
dummy_body: &'mir Body<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> ConstPropagator<'mir, 'tcx> {
|
||||
fn new(body: &'mir Body<'tcx>, tcx: TyCtxt<'tcx>) -> ConstPropagator<'mir, 'tcx> {
|
||||
let def_id = body.source.def_id();
|
||||
let args = &GenericArgs::identity_for_item(tcx, def_id);
|
||||
let param_env = tcx.param_env_reveal_all_normalized(def_id);
|
||||
@ -204,7 +187,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
|
||||
ecx.push_stack_frame(
|
||||
Instance::new(def_id, args),
|
||||
dummy_body,
|
||||
body,
|
||||
&ret,
|
||||
StackPopCleanup::Root { cleanup: false },
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user