about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-05-24 09:27:15 +0000
committerbors <bors@rust-lang.org>2018-05-24 09:27:15 +0000
commita76bff86e6f4b56b2c3fd1704ce8535ed207dd78 (patch)
treed59de40c0f799c06efa8499f48a7b3196c50c4da
parent7426f5ccf7b362785a5abeb365674d3da3d4df2e (diff)
parentda579ef75e4a8ca11fb98b24a0a3ea0c7ccffeeb (diff)
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
-rw-r--r--src/librustc_codegen_llvm/debuginfo/mod.rs12
-rw-r--r--src/librustc_codegen_llvm/mir/mod.rs26
2 files changed, 5 insertions, 33 deletions
diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs
index 294d8cbbd93..803966145f7 100644
--- a/src/librustc_codegen_llvm/debuginfo/mod.rs
+++ b/src/librustc_codegen_llvm/debuginfo/mod.rs
@@ -147,7 +147,6 @@ pub enum VariableAccess<'a> {
 pub enum VariableKind {
     ArgumentVariable(usize /*index*/),
     LocalVariable,
-    CapturedVariable,
 }
 
 /// Create any deferred debug metadata nodes
@@ -478,6 +477,7 @@ pub fn declare_local<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
                                variable_access: VariableAccess,
                                variable_kind: VariableKind,
                                span: Span) {
+    assert!(!dbg_context.get_ref(span).source_locations_enabled.get());
     let cx = bx.cx;
 
     let file = span_start(cx, span).file;
@@ -490,8 +490,7 @@ pub fn declare_local<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
 
     let (argument_index, dwarf_tag) = match variable_kind {
         ArgumentVariable(index) => (index as c_uint, DW_TAG_arg_variable),
-        LocalVariable    |
-        CapturedVariable => (0, DW_TAG_auto_variable)
+        LocalVariable => (0, DW_TAG_auto_variable)
     };
     let align = cx.align_of(variable_type);
 
@@ -529,14 +528,7 @@ pub fn declare_local<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
 
                 llvm::LLVMSetInstDebugLocation(bx.llbuilder, instr);
             }
-        }
-    }
-
-    match variable_kind {
-        ArgumentVariable(_) | CapturedVariable => {
-            assert!(!dbg_context.get_ref(span).source_locations_enabled.get());
             source_loc::set_debug_location(bx, UnknownLocation);
         }
-        _ => { /* nothing to do */ }
     }
 }
diff --git a/src/librustc_codegen_llvm/mir/mod.rs b/src/librustc_codegen_llvm/mir/mod.rs
index 47b15320311..d34f881bf9d 100644
--- a/src/librustc_codegen_llvm/mir/mod.rs
+++ b/src/librustc_codegen_llvm/mir/mod.rs
@@ -583,23 +583,6 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, '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() {
                 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.
-
-                // 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 mut ops = if env_ref { &ops[..] } else { &ops[1..] };
 
                 let ty = if let (true, &ty::TyRef(_, ty, _)) = (decl.by_ref, &ty.sty) {
                     ty
@@ -624,7 +604,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
                 };
 
                 let variable_access = VariableAccess::IndirectVariable {
-                    alloca: env_ptr,
+                    alloca: place.llval,
                     address_operations: &ops
                 };
                 declare_local(
@@ -634,7 +614,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
                     ty,
                     scope,
                     variable_access,
-                    VariableKind::CapturedVariable,
+                    VariableKind::LocalVariable,
                     DUMMY_SP
                 );
             }