Skip to content

Commit e423380

Browse files
committed
use LLVMDIBuilderCreateQualifiedType from llvm c api
1 parent 7c6fe1e commit e423380

File tree

3 files changed

+35
-44
lines changed

3 files changed

+35
-44
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -567,39 +567,37 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
567567
None,
568568
));
569569

570-
let build_assoc_const = |name: &str,
571-
type_di_node_: &'ll DIType,
572-
value: u64,
573-
align: Align| unsafe {
574-
// FIXME: Currently we force all DISCR_* values to be u64's as LLDB seems to have
575-
// problems inspecting other value types. Since DISCR_* is typically only going to be
576-
// directly inspected via the debugger visualizer - which compares it to the `tag` value
577-
// (whose type is not modified at all) it shouldn't cause any real problems.
578-
let (t_di, align) = if name == ASSOC_CONST_DISCR_NAME {
579-
(type_di_node_, align.bits() as u32)
580-
} else {
581-
let ty_u64 = Ty::new_uint(cx.tcx, ty::UintTy::U64);
582-
(type_di_node(cx, ty_u64), Align::EIGHT.bits() as u32)
570+
let build_assoc_const =
571+
|name: &str, type_di_node_: &'ll DIType, value: u64, align: Align| unsafe {
572+
// FIXME: Currently we force all DISCR_* values to be u64's as LLDB seems to have
573+
// problems inspecting other value types. Since DISCR_* is typically only going to be
574+
// directly inspected via the debugger visualizer - which compares it to the `tag` value
575+
// (whose type is not modified at all) it shouldn't cause any real problems.
576+
let (t_di, align) = if name == ASSOC_CONST_DISCR_NAME {
577+
(type_di_node_, align.bits() as u32)
578+
} else {
579+
let ty_u64 = Ty::new_uint(cx.tcx, ty::UintTy::U64);
580+
(type_di_node(cx, ty_u64), Align::EIGHT.bits() as u32)
581+
};
582+
583+
// must wrap type in a `const` modifier for LLDB to be able to inspect the value of the member
584+
let field_type =
585+
llvm::LLVMDIBuilderCreateQualifiedType(DIB(cx), DW_TAG_const_type, t_di);
586+
587+
llvm::LLVMRustDIBuilderCreateStaticMemberType(
588+
DIB(cx),
589+
wrapper_struct_type_di_node,
590+
name.as_c_char_ptr(),
591+
name.len(),
592+
unknown_file_metadata(cx),
593+
UNKNOWN_LINE_NUMBER,
594+
field_type,
595+
DIFlags::FlagZero,
596+
Some(cx.const_u64(value)),
597+
align,
598+
)
583599
};
584600

585-
// must wrap type in a `const` modifier for LLDB to be able to inspect the value of the member
586-
let field_type =
587-
llvm::LLVMRustDIBuilderCreateQualifiedType(DIB(cx), DW_TAG_const_type, t_di);
588-
589-
llvm::LLVMRustDIBuilderCreateStaticMemberType(
590-
DIB(cx),
591-
wrapper_struct_type_di_node,
592-
name.as_c_char_ptr(),
593-
name.len(),
594-
unknown_file_metadata(cx),
595-
UNKNOWN_LINE_NUMBER,
596-
field_type,
597-
DIFlags::FlagZero,
598-
Some(cx.const_u64(value)),
599-
align,
600-
)
601-
};
602-
603601
// We also always have an associated constant for the discriminant value
604602
// of the variant.
605603
fields.push(build_assoc_const(

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,12 @@ unsafe extern "C" {
18301830
Scope: &'ll Metadata,
18311831
InlinedAt: Option<&'ll Metadata>,
18321832
) -> &'ll Metadata;
1833+
1834+
pub(crate) fn LLVMDIBuilderCreateQualifiedType<'ll>(
1835+
Builder: &DIBuilder<'ll>,
1836+
Tag: c_uint,
1837+
Type: &'ll DIType,
1838+
) -> &'ll DIDerivedType;
18331839
}
18341840

18351841
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2259,12 +2265,6 @@ unsafe extern "C" {
22592265
AlignInBits: u32,
22602266
) -> &'a DIDerivedType;
22612267

2262-
pub(crate) fn LLVMRustDIBuilderCreateQualifiedType<'a>(
2263-
Builder: &DIBuilder<'a>,
2264-
Tag: c_uint,
2265-
Type: &'a DIType,
2266-
) -> &'a DIDerivedType;
2267-
22682268
pub(crate) fn LLVMRustDIBuilderCreateStaticVariable<'a>(
22692269
Builder: &DIBuilder<'a>,
22702270
Context: Option<&'a DIScope>,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,13 +1149,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticMemberType(
11491149
unwrap<llvm::ConstantInt>(val), llvm::dwarf::DW_TAG_member, AlignInBits));
11501150
}
11511151

1152-
extern "C" LLVMMetadataRef
1153-
LLVMRustDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag,
1154-
LLVMMetadataRef Type) {
1155-
return wrap(
1156-
unwrap(Builder)->createQualifiedType(Tag, unwrapDI<DIType>(Type)));
1157-
}
1158-
11591152
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
11601153
LLVMDIBuilderRef Builder, LLVMMetadataRef Context, const char *Name,
11611154
size_t NameLen, const char *LinkageName, size_t LinkageNameLen,

0 commit comments

Comments
 (0)