Skip to content

Commit 2552deb

Browse files
committed
Use LLVMDIBuilderCreateUnionType
1 parent 5419896 commit 2552deb

File tree

3 files changed

+25
-34
lines changed

3 files changed

+25
-34
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::cell::RefCell;
22

3+
use libc::c_uint;
34
use rustc_abi::{Align, Size, VariantIdx};
45
use rustc_data_structures::fingerprint::Fingerprint;
56
use rustc_data_structures::fx::FxHashMap;
@@ -191,6 +192,7 @@ pub(super) fn stub<'ll, 'tcx>(
191192
containing_scope: Option<&'ll DIScope>,
192193
flags: DIFlags,
193194
) -> StubInfo<'ll, 'tcx> {
195+
let no_elements: &[Option<&llvm::Metadata>] = &[];
194196
let empty_array = create_DIArray(DIB(cx), &[]);
195197
let unique_type_id_str = unique_type_id.generate_unique_id_string(cx.tcx);
196198

@@ -227,19 +229,20 @@ pub(super) fn stub<'ll, 'tcx>(
227229
}
228230
}
229231
Stub::Union => unsafe {
230-
llvm::LLVMRustDIBuilderCreateUnionType(
232+
llvm::LLVMDIBuilderCreateUnionType(
231233
DIB(cx),
232234
containing_scope,
233-
name.as_c_char_ptr(),
235+
name.as_ptr(),
234236
name.len(),
235237
file_metadata,
236238
line_number,
237239
size.bits(),
238240
align.bits() as u32,
239241
flags,
240-
Some(empty_array),
241-
0,
242-
unique_type_id_str.as_c_char_ptr(),
242+
no_elements.as_ptr(),
243+
no_elements.len() as c_uint,
244+
0u32, // (Objective-C runtime version; default is 0)
245+
unique_type_id_str.as_ptr(),
243246
unique_type_id_str.len(),
244247
)
245248
},

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,23 @@ unsafe extern "C" {
18781878
NumParameterTypes: c_uint,
18791879
Flags: DIFlags, // (default is `DIFlags::DIFlagZero`)
18801880
) -> &'ll Metadata;
1881+
1882+
pub(crate) fn LLVMDIBuilderCreateUnionType<'ll>(
1883+
Builder: &DIBuilder<'ll>,
1884+
Scope: Option<&'ll Metadata>,
1885+
Name: *const c_uchar, // See "PTR_LEN_STR".
1886+
NameLen: size_t,
1887+
File: &'ll Metadata,
1888+
LineNumber: c_uint,
1889+
SizeInBits: u64,
1890+
AlignInBits: u32,
1891+
Flags: DIFlags,
1892+
Elements: *const Option<&'ll Metadata>,
1893+
NumElements: c_uint,
1894+
RunTimeLang: c_uint, // (optional Objective-C runtime version; default is 0)
1895+
UniqueId: *const c_uchar, // See "PTR_LEN_STR".
1896+
UniqueIdLen: size_t,
1897+
) -> &'ll Metadata;
18811898
}
18821899

18831900
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2391,22 +2408,6 @@ unsafe extern "C" {
23912408
IsScoped: bool,
23922409
) -> &'a DIType;
23932410

2394-
pub(crate) fn LLVMRustDIBuilderCreateUnionType<'a>(
2395-
Builder: &DIBuilder<'a>,
2396-
Scope: Option<&'a DIScope>,
2397-
Name: *const c_char,
2398-
NameLen: size_t,
2399-
File: &'a DIFile,
2400-
LineNumber: c_uint,
2401-
SizeInBits: u64,
2402-
AlignInBits: u32,
2403-
Flags: DIFlags,
2404-
Elements: Option<&'a DIArray>,
2405-
RunTimeLang: c_uint,
2406-
UniqueId: *const c_char,
2407-
UniqueIdLen: size_t,
2408-
) -> &'a DIType;
2409-
24102411
pub(crate) fn LLVMRustDIBuilderCreateVariantPart<'a>(
24112412
Builder: &DIBuilder<'a>,
24122413
Scope: &'a DIScope,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,19 +1268,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerationType(
12681268
/* RunTimeLang */ 0, "", IsScoped));
12691269
}
12701270

1271-
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType(
1272-
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1273-
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1274-
uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags,
1275-
LLVMMetadataRef Elements, unsigned RunTimeLang, const char *UniqueId,
1276-
size_t UniqueIdLen) {
1277-
return wrap(unwrap(Builder)->createUnionType(
1278-
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
1279-
unwrapDI<DIFile>(File), LineNumber, SizeInBits, AlignInBits,
1280-
fromRust(Flags), DINodeArray(unwrapDI<MDTuple>(Elements)), RunTimeLang,
1281-
StringRef(UniqueId, UniqueIdLen)));
1282-
}
1283-
12841271
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTemplateTypeParameter(
12851272
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
12861273
size_t NameLen, LLVMMetadataRef Ty) {

0 commit comments

Comments
 (0)