Skip to content

Commit af88d14

Browse files
committed
Use LLVMDIBuilderCreateStructType
1 parent bae6fde commit af88d14

File tree

3 files changed

+29
-42
lines changed

3 files changed

+29
-42
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_middle::bug;
1010
use rustc_middle::ty::{self, ExistentialTraitRef, Ty, TyCtxt};
1111

1212
use super::{DefinitionLocation, SmallVec, UNKNOWN_LINE_NUMBER, unknown_file_metadata};
13-
use crate::common::{AsCCharPtr, CodegenCx};
13+
use crate::common::CodegenCx;
1414
use crate::debuginfo::utils::{DIB, create_DIArray, debug_context};
1515
use crate::llvm::debuginfo::{DIFlags, DIScope, DIType};
1616
use crate::llvm::{self};
@@ -193,7 +193,6 @@ pub(super) fn stub<'ll, 'tcx>(
193193
flags: DIFlags,
194194
) -> StubInfo<'ll, 'tcx> {
195195
let no_elements: &[Option<&llvm::Metadata>] = &[];
196-
let empty_array = create_DIArray(DIB(cx), &[]);
197196
let unique_type_id_str = unique_type_id.generate_unique_id_string(cx.tcx);
198197

199198
let (file_metadata, line_number) = if let Some(def_location) = def_location {
@@ -209,21 +208,22 @@ pub(super) fn stub<'ll, 'tcx>(
209208
_ => None,
210209
};
211210
unsafe {
212-
llvm::LLVMRustDIBuilderCreateStructType(
211+
llvm::LLVMDIBuilderCreateStructType(
213212
DIB(cx),
214213
containing_scope,
215-
name.as_c_char_ptr(),
214+
name.as_ptr(),
216215
name.len(),
217216
file_metadata,
218217
line_number,
219218
size.bits(),
220219
align.bits() as u32,
221220
flags,
222221
None,
223-
empty_array,
224-
0,
222+
no_elements.as_ptr(),
223+
no_elements.len() as c_uint,
224+
0u32, // (Objective-C runtime version; default is 0)
225225
vtable_holder,
226-
unique_type_id_str.as_c_char_ptr(),
226+
unique_type_id_str.as_ptr(),
227227
unique_type_id_str.len(),
228228
)
229229
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ use rustc_target::spec::SymbolVisibility;
2424

2525
use super::RustString;
2626
use super::debuginfo::{
27-
DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
28-
DIFile, DIFlags, DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram,
29-
DISubrange, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind,
27+
DIArray, DIBasicType, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags,
28+
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram, DISubrange,
29+
DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind,
3030
};
3131
use crate::llvm;
3232

@@ -1923,6 +1923,25 @@ unsafe extern "C" {
19231923
Name: *const c_uchar, // See "PTR_LEN_STR".
19241924
NameLen: size_t,
19251925
) -> &'ll Metadata;
1926+
1927+
pub(crate) fn LLVMDIBuilderCreateStructType<'ll>(
1928+
Builder: &DIBuilder<'ll>,
1929+
Scope: Option<&'ll Metadata>,
1930+
Name: *const c_uchar, // See "PTR_LEN_STR".
1931+
NameLen: size_t,
1932+
File: &'ll Metadata,
1933+
LineNumber: c_uint,
1934+
SizeInBits: u64,
1935+
AlignInBits: u32,
1936+
Flags: DIFlags,
1937+
DerivedFrom: Option<&'ll Metadata>,
1938+
Elements: *const Option<&'ll Metadata>,
1939+
NumElements: c_uint,
1940+
RunTimeLang: c_uint, // (optional Objective-C runtime version; default is 0)
1941+
VTableHolder: Option<&'ll Metadata>,
1942+
UniqueId: *const c_uchar, // See "PTR_LEN_STR".
1943+
UniqueIdLen: size_t,
1944+
) -> &'ll Metadata;
19261945
}
19271946

19281947
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2268,24 +2287,6 @@ unsafe extern "C" {
22682287
Scope: Option<&'a DIScope>,
22692288
) -> &'a DIDerivedType;
22702289

2271-
pub(crate) fn LLVMRustDIBuilderCreateStructType<'a>(
2272-
Builder: &DIBuilder<'a>,
2273-
Scope: Option<&'a DIDescriptor>,
2274-
Name: *const c_char,
2275-
NameLen: size_t,
2276-
File: &'a DIFile,
2277-
LineNumber: c_uint,
2278-
SizeInBits: u64,
2279-
AlignInBits: u32,
2280-
Flags: DIFlags,
2281-
DerivedFrom: Option<&'a DIType>,
2282-
Elements: &'a DIArray,
2283-
RunTimeLang: c_uint,
2284-
VTableHolder: Option<&'a DIType>,
2285-
UniqueId: *const c_char,
2286-
UniqueIdLen: size_t,
2287-
) -> &'a DICompositeType;
2288-
22892290
pub(crate) fn LLVMRustDIBuilderCreateMemberType<'a>(
22902291
Builder: &DIBuilder<'a>,
22912292
Scope: &'a DIDescriptor,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,20 +1074,6 @@ LLVMRustDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type,
10741074
LineNo, unwrapDIPtr<DIScope>(Scope)));
10751075
}
10761076

1077-
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStructType(
1078-
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1079-
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1080-
uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags,
1081-
LLVMMetadataRef DerivedFrom, LLVMMetadataRef Elements, unsigned RunTimeLang,
1082-
LLVMMetadataRef VTableHolder, const char *UniqueId, size_t UniqueIdLen) {
1083-
return wrap(unwrap(Builder)->createStructType(
1084-
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
1085-
unwrapDI<DIFile>(File), LineNumber, SizeInBits, AlignInBits,
1086-
fromRust(Flags), unwrapDI<DIType>(DerivedFrom),
1087-
DINodeArray(unwrapDI<MDTuple>(Elements)), RunTimeLang,
1088-
unwrapDI<DIType>(VTableHolder), StringRef(UniqueId, UniqueIdLen)));
1089-
}
1090-
10911077
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantPart(
10921078
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
10931079
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,

0 commit comments

Comments
 (0)