1
Fork 0

[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:
Wesley Wiser 2020-05-30 15:02:32 -04:00
parent b776d1c3e3
commit 01aec8d185
23 changed files with 406 additions and 127 deletions

View file

@ -186,7 +186,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
caller_location: None,
};
fx.per_local_var_debug_info = fx.compute_per_local_var_debug_info();
fx.per_local_var_debug_info = fx.compute_per_local_var_debug_info(&mut bx);
for const_ in &mir.required_consts {
if let Err(err) = fx.eval_mir_constant(const_) {