diff options
| author | Matt Weber <30441572+mweber15@users.noreply.github.com> | 2022-11-10 12:12:02 -0500 |
|---|---|---|
| committer | Matt Weber <30441572+mweber15@users.noreply.github.com> | 2024-11-06 22:12:02 -0500 |
| commit | 2f00b6affda7b25cb2721422d7adad39154ce9d1 (patch) | |
| tree | c32791b1dcf9b7a762dae1ce837691ec3579e02c /compiler/rustc_codegen_llvm/src/debuginfo/metadata | |
| parent | c07aa1e17199e27f6f7ac8f3307bca7bda0084b6 (diff) | |
| download | rust-2f00b6affda7b25cb2721422d7adad39154ce9d1.tar.gz rust-2f00b6affda7b25cb2721422d7adad39154ce9d1.zip | |
Require `type_map::stub` callers to supply file information
This change attaches file information (`DIFile` reference and line number) to struct debug info nodes. Before: ``` ; foo.ll ... !5 = !DIFile(filename: "<unknown>", directory: "") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !5, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "4cb373851db92e732c4cb5651b886dd0") ... ``` After: ``` ; foo.ll ... !3 = !DIFile(filename: "foo.rs", directory: "/home/matt/src/rust98678", checksumkind: CSK_SHA1, checksum: "bcb9f08512c8f3b8181ef4726012bc6807bc9be4") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !3, line: 3, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "9e5968c7af39c148acb253912b7f409f") ... ``` Fixes #98678
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/debuginfo/metadata')
4 files changed, 26 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs index 100b046cee2..a33347aa283 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs @@ -199,6 +199,8 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>( type_map::Stub::Union, unique_type_id, &enum_type_name, + unknown_file_metadata(cx), + UNKNOWN_LINE_NUMBER, cx.size_and_align_of(enum_type), NO_SCOPE_METADATA, visibility_di_flags(cx, enum_adt_def.did(), enum_adt_def.did()), @@ -274,6 +276,8 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>( type_map::Stub::Union, unique_type_id, &coroutine_type_name, + unknown_file_metadata(cx), + UNKNOWN_LINE_NUMBER, size_and_align_of(coroutine_type_and_layout), NO_SCOPE_METADATA, DIFlags::FlagZero, @@ -481,6 +485,8 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>( variant_index, ), &variant_struct_wrapper_type_name(variant_index), + unknown_file_metadata(cx), + UNKNOWN_LINE_NUMBER, // NOTE: We use size and align of enum_type, not from variant_layout: size_and_align_of(enum_or_coroutine_type_and_layout), Some(enum_or_coroutine_type_di_node), diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs index b3d4a6642a1..4402f289454 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs @@ -204,6 +204,8 @@ fn build_enum_variant_struct_type_di_node<'ll, 'tcx>( variant_index, ), variant_def.name.as_str(), + unknown_file_metadata(cx), + UNKNOWN_LINE_NUMBER, // NOTE: We use size and align of enum_type, not from variant_layout: size_and_align_of(enum_type_and_layout), Some(enum_type_di_node), @@ -286,6 +288,8 @@ fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>( Stub::Struct, unique_type_id, &variant_name, + unknown_file_metadata(cx), + UNKNOWN_LINE_NUMBER, size_and_align_of(coroutine_type_and_layout), Some(coroutine_type_di_node), DIFlags::FlagZero, @@ -351,7 +355,11 @@ enum DiscrResult { impl DiscrResult { fn opt_single_val(&self) -> Option<u128> { - if let Self::Value(d) = *self { Some(d) } else { None } + if let Self::Value(d) = *self { + Some(d) + } else { + None + } } } diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs index d4006691d37..07c3784efe7 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs @@ -62,6 +62,8 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>( Stub::Struct, unique_type_id, &enum_type_name, + unknown_file_metadata(cx), + UNKNOWN_LINE_NUMBER, size_and_align_of(enum_type_and_layout), Some(containing_scope), visibility_flags, @@ -141,6 +143,8 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>( Stub::Struct, unique_type_id, &coroutine_type_name, + unknown_file_metadata(cx), + UNKNOWN_LINE_NUMBER, size_and_align_of(coroutine_type_and_layout), Some(containing_scope), DIFlags::FlagZero, diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs index 5120b63d173..f8f8cf914ba 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs @@ -11,7 +11,7 @@ use rustc_middle::ty::{ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt}; use super::{SmallVec, UNKNOWN_LINE_NUMBER, unknown_file_metadata}; use crate::common::{AsCCharPtr, CodegenCx}; use crate::debuginfo::utils::{DIB, create_DIArray, debug_context}; -use crate::llvm::debuginfo::{DIFlags, DIScope, DIType}; +use crate::llvm::debuginfo::{DIFile, DIFlags, DIScope, DIType}; use crate::llvm::{self}; mod private { @@ -174,6 +174,8 @@ pub(super) fn stub<'ll, 'tcx>( kind: Stub<'ll>, unique_type_id: UniqueTypeId<'tcx>, name: &str, + file_metadata: &'ll DIFile, + line_number: u32, (size, align): (Size, Align), containing_scope: Option<&'ll DIScope>, flags: DIFlags, @@ -193,8 +195,8 @@ pub(super) fn stub<'ll, 'tcx>( containing_scope, name.as_c_char_ptr(), name.len(), - unknown_file_metadata(cx), - UNKNOWN_LINE_NUMBER, + file_metadata, + line_number, size.bits(), align.bits() as u32, flags, @@ -213,8 +215,8 @@ pub(super) fn stub<'ll, 'tcx>( containing_scope, name.as_c_char_ptr(), name.len(), - unknown_file_metadata(cx), - UNKNOWN_LINE_NUMBER, + file_metadata, + line_number, size.bits(), align.bits() as u32, flags, |
