summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs53
1 files changed, 12 insertions, 41 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
index c1b3f34e5..21a0a60b0 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
@@ -176,15 +176,14 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
return_if_di_node_created_in_meantime!(cx, unique_type_id);
- let (thin_pointer_size, thin_pointer_align) =
- cx.size_and_align_of(cx.tcx.mk_imm_ptr(cx.tcx.types.unit));
+ let data_layout = &cx.tcx.data_layout;
let ptr_type_debuginfo_name = compute_debuginfo_type_name(cx.tcx, ptr_type, true);
match fat_pointer_kind(cx, pointee_type) {
None => {
// This is a thin pointer. Create a regular pointer type and give it the correct name.
debug_assert_eq!(
- (thin_pointer_size, thin_pointer_align),
+ (data_layout.pointer_size, data_layout.pointer_align.abi),
cx.size_and_align_of(ptr_type),
"ptr_type={}, pointee_type={}",
ptr_type,
@@ -195,8 +194,8 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
llvm::LLVMRustDIBuilderCreatePointerType(
DIB(cx),
pointee_type_di_node,
- thin_pointer_size.bits(),
- thin_pointer_align.bits() as u32,
+ data_layout.pointer_size.bits(),
+ data_layout.pointer_align.abi.bits() as u32,
0, // Ignore DWARF address space.
ptr_type_debuginfo_name.as_ptr().cast(),
ptr_type_debuginfo_name.len(),
@@ -831,24 +830,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
}
.unwrap_or_default();
let split_name = split_name.to_str().unwrap();
-
- // FIXME(#60020):
- //
- // This should actually be
- //
- // let kind = DebugEmissionKind::from_generic(tcx.sess.opts.debuginfo);
- //
- // That is, we should set LLVM's emission kind to `LineTablesOnly` if
- // we are compiling with "limited" debuginfo. However, some of the
- // existing tools relied on slightly more debuginfo being generated than
- // would be the case with `LineTablesOnly`, and we did not want to break
- // these tools in a "drive-by fix", without a good idea or plan about
- // what limited debuginfo should exactly look like. So for now we keep
- // the emission kind as `FullDebug`.
- //
- // See https://github.com/rust-lang/rust/issues/60020 for details.
- let kind = DebugEmissionKind::FullDebug;
- assert!(tcx.sess.opts.debuginfo != DebugInfo::None);
+ let kind = DebugEmissionKind::from_generic(tcx.sess.opts.debuginfo);
unsafe {
let compile_unit_file = llvm::LLVMRustDIBuilderCreateFile(
@@ -882,8 +864,6 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
);
if tcx.sess.opts.unstable_opts.profile {
- let cu_desc_metadata =
- llvm::LLVMRustMetadataAsValue(debug_context.llcontext, unit_metadata);
let default_gcda_path = &output_filenames.with_extension("gcda");
let gcda_path =
tcx.sess.opts.unstable_opts.profile_emit.as_ref().unwrap_or(default_gcda_path);
@@ -891,20 +871,17 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
let gcov_cu_info = [
path_to_mdstring(debug_context.llcontext, &output_filenames.with_extension("gcno")),
path_to_mdstring(debug_context.llcontext, gcda_path),
- cu_desc_metadata,
+ unit_metadata,
];
- let gcov_metadata = llvm::LLVMMDNodeInContext(
+ let gcov_metadata = llvm::LLVMMDNodeInContext2(
debug_context.llcontext,
gcov_cu_info.as_ptr(),
- gcov_cu_info.len() as c_uint,
+ gcov_cu_info.len(),
);
+ let val = llvm::LLVMMetadataAsValue(debug_context.llcontext, gcov_metadata);
let llvm_gcov_ident = cstr!("llvm.gcov");
- llvm::LLVMAddNamedMetadataOperand(
- debug_context.llmod,
- llvm_gcov_ident.as_ptr(),
- gcov_metadata,
- );
+ llvm::LLVMAddNamedMetadataOperand(debug_context.llmod, llvm_gcov_ident.as_ptr(), val);
}
// Insert `llvm.ident` metadata on the wasm targets since that will
@@ -925,15 +902,9 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
return unit_metadata;
};
- fn path_to_mdstring<'ll>(llcx: &'ll llvm::Context, path: &Path) -> &'ll Value {
+ fn path_to_mdstring<'ll>(llcx: &'ll llvm::Context, path: &Path) -> &'ll llvm::Metadata {
let path_str = path_to_c_string(path);
- unsafe {
- llvm::LLVMMDStringInContext(
- llcx,
- path_str.as_ptr(),
- path_str.as_bytes().len() as c_uint,
- )
- }
+ unsafe { llvm::LLVMMDStringInContext2(llcx, path_str.as_ptr(), path_str.as_bytes().len()) }
}
}