[mir-opt] Allow debuginfo to be generated for a constant or a Place
Prior to this commit, debuginfo was always generated by mapping a name to a Place. This has the side-effect that `SimplifyLocals` cannot remove locals that are only used for debuginfo because their other uses have been const-propagated. To allow these locals to be removed, we now allow debuginfo to point to a constant value. The `ConstProp` pass detects when debuginfo points to a local with a known constant value and replaces it with the value. This allows the later `SimplifyLocals` pass to remove the local.
This commit is contained in:
@@ -21,6 +21,7 @@ pub mod check_consts;
|
||||
pub mod check_packed_ref;
|
||||
pub mod check_unsafety;
|
||||
pub mod cleanup_post_borrowck;
|
||||
pub mod const_debuginfo;
|
||||
pub mod const_prop;
|
||||
pub mod coverage;
|
||||
pub mod deaggregator;
|
||||
@@ -408,6 +409,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
&remove_noop_landing_pads::RemoveNoopLandingPads,
|
||||
&simplify::SimplifyCfg::new("final"),
|
||||
&nrvo::RenameReturnPlace,
|
||||
&const_debuginfo::ConstDebugInfo,
|
||||
&simplify::SimplifyLocals,
|
||||
&multiple_return_terminators::MultipleReturnTerminators,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user