Skip to content

Commit a76bff8

Browse files
committed
Auto merge of #50949 - eddyb:debuginfo, r=mw
rustc_codegen_llvm: remove some debuginfo cruft. (The second commit passes tests locally but might not on older LLVM versions) r? @nikomatsakis
2 parents 7426f5c + da579ef commit a76bff8

File tree

2 files changed

+5
-33
lines changed

2 files changed

+5
-33
lines changed

src/librustc_codegen_llvm/debuginfo/mod.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ pub enum VariableAccess<'a> {
147147
pub enum VariableKind {
148148
ArgumentVariable(usize /*index*/),
149149
LocalVariable,
150-
CapturedVariable,
151150
}
152151

153152
/// Create any deferred debug metadata nodes
@@ -478,6 +477,7 @@ pub fn declare_local<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
478477
variable_access: VariableAccess,
479478
variable_kind: VariableKind,
480479
span: Span) {
480+
assert!(!dbg_context.get_ref(span).source_locations_enabled.get());
481481
let cx = bx.cx;
482482

483483
let file = span_start(cx, span).file;
@@ -490,8 +490,7 @@ pub fn declare_local<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
490490

491491
let (argument_index, dwarf_tag) = match variable_kind {
492492
ArgumentVariable(index) => (index as c_uint, DW_TAG_arg_variable),
493-
LocalVariable |
494-
CapturedVariable => (0, DW_TAG_auto_variable)
493+
LocalVariable => (0, DW_TAG_auto_variable)
495494
};
496495
let align = cx.align_of(variable_type);
497496

@@ -529,14 +528,7 @@ pub fn declare_local<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
529528

530529
llvm::LLVMSetInstDebugLocation(bx.llbuilder, instr);
531530
}
532-
}
533-
}
534-
535-
match variable_kind {
536-
ArgumentVariable(_) | CapturedVariable => {
537-
assert!(!dbg_context.get_ref(span).source_locations_enabled.get());
538531
source_loc::set_debug_location(bx, UnknownLocation);
539532
}
540-
_ => { /* nothing to do */ }
541533
}
542534
}

src/librustc_codegen_llvm/mir/mod.rs

+3-23
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(
@@ -634,7 +614,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
634614
ty,
635615
scope,
636616
variable_access,
637-
VariableKind::CapturedVariable,
617+
VariableKind::LocalVariable,
638618
DUMMY_SP
639619
);
640620
}

0 commit comments

Comments
 (0)