Skip to content

Commit 3be1ccb

Browse files
committed
Use LLVMDIBuilderCreateStructType
1 parent 50194be commit 3be1ccb

File tree

3 files changed

+30
-43
lines changed

3 files changed

+30
-43
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::bug;
99
use rustc_middle::ty::{self, PolyExistentialTraitRef, Ty, TyCtxt};
1010

1111
use super::{DefinitionLocation, SmallVec, UNKNOWN_LINE_NUMBER, unknown_file_metadata};
12-
use crate::common::{AsCCharPtr, CodegenCx};
12+
use crate::common::CodegenCx;
1313
use crate::debuginfo::utils::{DIB, create_DIArray, debug_context};
1414
use crate::llvm::debuginfo::{DIFlags, DIScope, DIType};
1515
use crate::llvm::{self};
@@ -191,7 +191,6 @@ pub(super) fn stub<'ll, 'tcx>(
191191
containing_scope: Option<&'ll DIScope>,
192192
flags: DIFlags,
193193
) -> StubInfo<'ll, 'tcx> {
194-
let empty_array = create_DIArray(DIB(cx), &[]);
195194
let unique_type_id_str = unique_type_id.generate_unique_id_string(cx.tcx);
196195

197196
let (file_metadata, line_number) = if let Some(def_location) = def_location {
@@ -207,21 +206,22 @@ pub(super) fn stub<'ll, 'tcx>(
207206
_ => None,
208207
};
209208
unsafe {
210-
llvm::LLVMRustDIBuilderCreateStructType(
209+
llvm::LLVMDIBuilderCreateStructType(
211210
DIB(cx),
212211
containing_scope,
213-
name.as_c_char_ptr(),
212+
name.as_ptr(),
214213
name.len(),
215214
file_metadata,
216215
line_number,
217216
size.bits(),
218217
align.bits() as u32,
219218
flags,
220-
None,
221-
empty_array,
222-
0,
219+
/* DerivedFrom */ None,
220+
/* Elements */ (&[]).as_ptr(),
221+
/* NumElements */ 0u32,
222+
/* RunTimeLang */ 0u32,
223223
vtable_holder,
224-
unique_type_id_str.as_c_char_ptr(),
224+
unique_type_id_str.as_ptr(),
225225
unique_type_id_str.len(),
226226
)
227227
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

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

1212
use super::RustString;
1313
use super::debuginfo::{
14-
DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
15-
DIFile, DIFlags, DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram,
16-
DISubrange, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind,
14+
DIArray, DIBasicType, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags,
15+
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram, DISubrange,
16+
DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind,
1717
};
1818
use crate::llvm;
1919

@@ -1715,6 +1715,25 @@ unsafe extern "C" {
17151715
Name: *const c_uchar,
17161716
NameLen: size_t,
17171717
) -> &'ll Metadata;
1718+
1719+
pub(crate) fn LLVMDIBuilderCreateStructType<'ll>(
1720+
Builder: &DIBuilder<'ll>,
1721+
Scope: Option<&'ll Metadata>,
1722+
Name: *const c_uchar,
1723+
NameLen: size_t,
1724+
File: &'ll Metadata,
1725+
LineNumber: c_uint,
1726+
SizeInBits: u64,
1727+
AlignInBits: u32,
1728+
Flags: DIFlags,
1729+
DerivedFrom: Option<&'ll Metadata>,
1730+
Elements: *const &'ll Metadata,
1731+
NumElements: c_uint,
1732+
RunTimeLang: c_uint,
1733+
VTableHolder: Option<&'ll Metadata>,
1734+
UniqueId: *const c_uchar,
1735+
UniqueIdLen: size_t,
1736+
) -> &'ll Metadata;
17181737
}
17191738

17201739
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2057,24 +2076,6 @@ unsafe extern "C" {
20572076
Scope: Option<&'a DIScope>,
20582077
) -> &'a DIDerivedType;
20592078

2060-
pub fn LLVMRustDIBuilderCreateStructType<'a>(
2061-
Builder: &DIBuilder<'a>,
2062-
Scope: Option<&'a DIDescriptor>,
2063-
Name: *const c_char,
2064-
NameLen: size_t,
2065-
File: &'a DIFile,
2066-
LineNumber: c_uint,
2067-
SizeInBits: u64,
2068-
AlignInBits: u32,
2069-
Flags: DIFlags,
2070-
DerivedFrom: Option<&'a DIType>,
2071-
Elements: &'a DIArray,
2072-
RunTimeLang: c_uint,
2073-
VTableHolder: Option<&'a DIType>,
2074-
UniqueId: *const c_char,
2075-
UniqueIdLen: size_t,
2076-
) -> &'a DICompositeType;
2077-
20782079
pub fn LLVMRustDIBuilderCreateMemberType<'a>(
20792080
Builder: &DIBuilder<'a>,
20802081
Scope: &'a DIDescriptor,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -990,20 +990,6 @@ LLVMRustDIBuilderCreateTypedef(LLVMRustDIBuilderRef Builder,
990990
LineNo, unwrapDIPtr<DIScope>(Scope)));
991991
}
992992

993-
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStructType(
994-
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
995-
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
996-
uint64_t SizeInBits, uint32_t AlignInBits, LLVMRustDIFlags Flags,
997-
LLVMMetadataRef DerivedFrom, LLVMMetadataRef Elements, unsigned RunTimeLang,
998-
LLVMMetadataRef VTableHolder, const char *UniqueId, size_t UniqueIdLen) {
999-
return wrap(Builder->createStructType(
1000-
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
1001-
unwrapDI<DIFile>(File), LineNumber, SizeInBits, AlignInBits,
1002-
fromRust(Flags), unwrapDI<DIType>(DerivedFrom),
1003-
DINodeArray(unwrapDI<MDTuple>(Elements)), RunTimeLang,
1004-
unwrapDI<DIType>(VTableHolder), StringRef(UniqueId, UniqueIdLen)));
1005-
}
1006-
1007993
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantPart(
1008994
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1009995
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,

0 commit comments

Comments
 (0)