Skip to content

Commit da579ef

Browse files
committed
rustc_codegen_llvm: remove closure env alloca hack around upvar debuginfo.
1 parent a8ceab9 commit da579ef

File tree

1 file changed

+2
-22
lines changed
  • src/librustc_codegen_llvm/mir

1 file changed

+2
-22
lines changed

src/librustc_codegen_llvm/mir/mod.rs

+2-22
Original file line numberDiff line numberDiff line change
@@ -583,23 +583,6 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
583583
};
584584
let upvar_tys = upvar_substs.upvar_tys(def_id, tcx);
585585

586-
// Store the pointer to closure data in an alloca for debuginfo
587-
// because that's what the llvm.dbg.declare intrinsic expects.
588-
589-
// FIXME(eddyb) this shouldn't be necessary but SROA seems to
590-
// mishandle DW_OP_plus not preceded by DW_OP_deref, i.e. it
591-
// doesn't actually strip the offset when splitting the closure
592-
// environment into its components so it ends up out of bounds.
593-
let env_ptr = if !env_ref {
594-
let scratch = PlaceRef::alloca(bx,
595-
bx.cx.layout_of(tcx.mk_mut_ptr(arg.layout.ty)),
596-
"__debuginfo_env_ptr");
597-
bx.store(place.llval, scratch.llval, scratch.align);
598-
scratch.llval
599-
} else {
600-
place.llval
601-
};
602-
603586
for (i, (decl, ty)) in mir.upvar_decls.iter().zip(upvar_tys).enumerate() {
604587
let byte_offset_of_var_in_env = closure_layout.fields.offset(i).bytes();
605588

@@ -611,10 +594,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
611594
};
612595

613596
// The environment and the capture can each be indirect.
614-
615-
// FIXME(eddyb) see above why we have to keep
616-
// a pointer in an alloca for debuginfo atm.
617-
let mut ops = if env_ref || true { &ops[..] } else { &ops[1..] };
597+
let mut ops = if env_ref { &ops[..] } else { &ops[1..] };
618598

619599
let ty = if let (true, &ty::TyRef(_, ty, _)) = (decl.by_ref, &ty.sty) {
620600
ty
@@ -624,7 +604,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
624604
};
625605

626606
let variable_access = VariableAccess::IndirectVariable {
627-
alloca: env_ptr,
607+
alloca: place.llval,
628608
address_operations: &ops
629609
};
630610
declare_local(

0 commit comments

Comments
 (0)