diff --git a/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs b/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs index 09422f4ec3768..13a36c36a309a 100644 --- a/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs +++ b/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs @@ -1,11 +1,13 @@ use super::metadata::{file_metadata, UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER}; use super::utils::DIB; use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; +use rustc_codegen_ssa::traits::*; use crate::common::CodegenCx; use crate::llvm; use crate::llvm::debuginfo::{DIScope, DISubprogram}; use rustc::mir::{Body, SourceScope}; +use rustc_session::config::DebugInfo; use rustc_index::bit_set::BitSet; use rustc_index::vec::Idx; @@ -19,10 +21,17 @@ pub fn compute_mir_scopes( ) { // Find all the scopes with variables defined in them. let mut has_variables = BitSet::new_empty(mir.source_scopes.len()); - // FIXME(eddyb) take into account that arguments always have debuginfo, - // irrespective of their name (assuming full debuginfo is enabled). - for var_debug_info in &mir.var_debug_info { - has_variables.insert(var_debug_info.source_info.scope); + + // Only consider variables when they're going to be emitted. + // FIXME(eddyb) don't even allocate `has_variables` otherwise. + if cx.sess().opts.debuginfo == DebugInfo::Full { + // FIXME(eddyb) take into account that arguments always have debuginfo, + // irrespective of their name (assuming full debuginfo is enabled). + // NOTE(eddyb) actually, on second thought, those are always in the + // function scope, which always exists. + for var_debug_info in &mir.var_debug_info { + has_variables.insert(var_debug_info.source_info.scope); + } } // Instantiate all scopes. diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index f35220cc6666a..c867d8cf3c481 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -2299,6 +2299,11 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global return; } + // Only create type information if full debuginfo is enabled + if cx.sess().opts.debuginfo != DebugInfo::Full { + return; + } + let tcx = cx.tcx; let attrs = tcx.codegen_fn_attrs(def_id); @@ -2358,6 +2363,11 @@ pub fn create_vtable_metadata(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>, vtable: & return; } + // Only create type information if full debuginfo is enabled + if cx.sess().opts.debuginfo != DebugInfo::Full { + return; + } + let type_metadata = type_metadata(cx, ty, rustc_span::DUMMY_SP); unsafe { diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 41829d4ee4256..4b8140263f1f2 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -475,7 +475,12 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { // so avoid methods on other types (e.g., `<*mut T>::null`). match impl_self_ty.kind { ty::Adt(def, ..) if !def.is_box() => { - Some(type_metadata(cx, impl_self_ty, rustc_span::DUMMY_SP)) + // Again, only create type information if full debuginfo is enabled + if cx.sess().opts.debuginfo == DebugInfo::Full { + Some(type_metadata(cx, impl_self_ty, rustc_span::DUMMY_SP)) + } else { + Some(namespace::item_namespace(cx, def.did)) + } } _ => None, } diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 9b4f03b3fb64b..fcaeaf2e4b07d 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -151,6 +151,7 @@ fn main() { if env::var_os("LLVM_NDEBUG").is_some() { cfg.define("NDEBUG", None); + cfg.debug(false); } build_helper::rerun_if_changed_anything_in_dir(Path::new("../rustllvm"));