rustc_codegen_llvm: remove closure env alloca hack around upvar debuginfo.
This commit is contained in:
parent
a8ceab9cd7
commit
da579ef75e
1 changed files with 2 additions and 22 deletions
|
@ -583,23 +583,6 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
|
||||||
};
|
};
|
||||||
let upvar_tys = upvar_substs.upvar_tys(def_id, tcx);
|
let upvar_tys = upvar_substs.upvar_tys(def_id, tcx);
|
||||||
|
|
||||||
// Store the pointer to closure data in an alloca for debuginfo
|
|
||||||
// because that's what the llvm.dbg.declare intrinsic expects.
|
|
||||||
|
|
||||||
// FIXME(eddyb) this shouldn't be necessary but SROA seems to
|
|
||||||
// mishandle DW_OP_plus not preceded by DW_OP_deref, i.e. it
|
|
||||||
// doesn't actually strip the offset when splitting the closure
|
|
||||||
// environment into its components so it ends up out of bounds.
|
|
||||||
let env_ptr = if !env_ref {
|
|
||||||
let scratch = PlaceRef::alloca(bx,
|
|
||||||
bx.cx.layout_of(tcx.mk_mut_ptr(arg.layout.ty)),
|
|
||||||
"__debuginfo_env_ptr");
|
|
||||||
bx.store(place.llval, scratch.llval, scratch.align);
|
|
||||||
scratch.llval
|
|
||||||
} else {
|
|
||||||
place.llval
|
|
||||||
};
|
|
||||||
|
|
||||||
for (i, (decl, ty)) in mir.upvar_decls.iter().zip(upvar_tys).enumerate() {
|
for (i, (decl, ty)) in mir.upvar_decls.iter().zip(upvar_tys).enumerate() {
|
||||||
let byte_offset_of_var_in_env = closure_layout.fields.offset(i).bytes();
|
let byte_offset_of_var_in_env = closure_layout.fields.offset(i).bytes();
|
||||||
|
|
||||||
|
@ -611,10 +594,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
|
||||||
};
|
};
|
||||||
|
|
||||||
// The environment and the capture can each be indirect.
|
// The environment and the capture can each be indirect.
|
||||||
|
let mut ops = if env_ref { &ops[..] } else { &ops[1..] };
|
||||||
// FIXME(eddyb) see above why we have to keep
|
|
||||||
// a pointer in an alloca for debuginfo atm.
|
|
||||||
let mut ops = if env_ref || true { &ops[..] } else { &ops[1..] };
|
|
||||||
|
|
||||||
let ty = if let (true, &ty::TyRef(_, ty, _)) = (decl.by_ref, &ty.sty) {
|
let ty = if let (true, &ty::TyRef(_, ty, _)) = (decl.by_ref, &ty.sty) {
|
||||||
ty
|
ty
|
||||||
|
@ -624,7 +604,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
|
||||||
};
|
};
|
||||||
|
|
||||||
let variable_access = VariableAccess::IndirectVariable {
|
let variable_access = VariableAccess::IndirectVariable {
|
||||||
alloca: env_ptr,
|
alloca: place.llval,
|
||||||
address_operations: &ops
|
address_operations: &ops
|
||||||
};
|
};
|
||||||
declare_local(
|
declare_local(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue