Skip to content

Commit 6b51f7c

Browse files
committed
Use LLVMDIBuilderCreateTypedef
1 parent 002771a commit 6b51f7c

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,15 @@ fn build_basic_type_di_node<'ll, 'tcx>(
821821
};
822822

823823
let typedef_di_node = unsafe {
824-
llvm::LLVMRustDIBuilderCreateTypedef(
824+
llvm::LLVMDIBuilderCreateTypedef(
825825
DIB(cx),
826826
ty_di_node,
827-
typedef_name.as_c_char_ptr(),
827+
typedef_name.as_ptr(),
828828
typedef_name.len(),
829829
unknown_file_metadata(cx),
830-
0,
831-
None,
830+
0, // (no line number)
831+
None, // (no scope)
832+
0u32, // (no alignment specified)
832833
)
833834
};
834835

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_target::spec::SymbolVisibility;
2424

2525
use super::RustString;
2626
use super::debuginfo::{
27-
DIArray, DIBasicType, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags,
27+
DIArray, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags,
2828
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram, DISubrange,
2929
DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind,
3030
};
@@ -1978,6 +1978,17 @@ unsafe extern "C" {
19781978
Tag: c_uint, // (DWARF tag, e.g. `DW_TAG_const_type`)
19791979
Type: &'ll Metadata,
19801980
) -> &'ll Metadata;
1981+
1982+
pub(crate) fn LLVMDIBuilderCreateTypedef<'ll>(
1983+
Builder: &DIBuilder<'ll>,
1984+
Type: &'ll Metadata,
1985+
Name: *const c_uchar, // See "PTR_LEN_STR".
1986+
NameLen: size_t,
1987+
File: &'ll Metadata,
1988+
LineNo: c_uint,
1989+
Scope: Option<&'ll Metadata>,
1990+
AlignInBits: u32, // (optional; default is 0)
1991+
) -> &'ll Metadata;
19811992
}
19821993

19831994
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2313,16 +2324,6 @@ unsafe extern "C" {
23132324
TParam: &'a DIArray,
23142325
) -> &'a DISubprogram;
23152326

2316-
pub(crate) fn LLVMRustDIBuilderCreateTypedef<'a>(
2317-
Builder: &DIBuilder<'a>,
2318-
Type: &'a DIBasicType,
2319-
Name: *const c_char,
2320-
NameLen: size_t,
2321-
File: &'a DIFile,
2322-
LineNo: c_uint,
2323-
Scope: Option<&'a DIScope>,
2324-
) -> &'a DIDerivedType;
2325-
23262327
pub(crate) fn LLVMRustDIBuilderCreateVariantMemberType<'a>(
23272328
Builder: &DIBuilder<'a>,
23282329
Scope: &'a DIScope,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,16 +1064,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMethod(
10641064
return wrap(Sub);
10651065
}
10661066

1067-
extern "C" LLVMMetadataRef
1068-
LLVMRustDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type,
1069-
const char *Name, size_t NameLen,
1070-
LLVMMetadataRef File, unsigned LineNo,
1071-
LLVMMetadataRef Scope) {
1072-
return wrap(unwrap(Builder)->createTypedef(
1073-
unwrap<DIType>(Type), StringRef(Name, NameLen), unwrap<DIFile>(File),
1074-
LineNo, unwrapDIPtr<DIScope>(Scope)));
1075-
}
1076-
10771067
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantPart(
10781068
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
10791069
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,

0 commit comments

Comments
 (0)