Skip to content

Commit 14f48d9

Browse files
committed
Use LLVMDIBuilderCreateUnionType
1 parent e270f72 commit 14f48d9

File tree

3 files changed

+23
-34
lines changed

3 files changed

+23
-34
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,20 @@ pub(super) fn stub<'ll, 'tcx>(
227227
}
228228
}
229229
Stub::Union => unsafe {
230-
llvm::LLVMRustDIBuilderCreateUnionType(
230+
llvm::LLVMDIBuilderCreateUnionType(
231231
DIB(cx),
232232
containing_scope,
233-
name.as_c_char_ptr(),
233+
name.as_ptr(),
234234
name.len(),
235235
file_metadata,
236236
line_number,
237237
size.bits(),
238238
align.bits() as u32,
239239
flags,
240-
Some(empty_array),
241-
0,
242-
unique_type_id_str.as_c_char_ptr(),
240+
/* Elements */ (&[]).as_ptr(),
241+
/* NumElements */ 0u32,
242+
/* RunTimeLang */ 0u32,
243+
unique_type_id_str.as_ptr(),
243244
unique_type_id_str.len(),
244245
)
245246
},

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,23 @@ unsafe extern "C" {
16721672
NumParameterTypes: c_uint,
16731673
Flags: DIFlags, // (optional; default is `DIFlags::FlagZero`)
16741674
) -> &'ll Metadata;
1675+
1676+
pub(crate) fn LLVMDIBuilderCreateUnionType<'ll>(
1677+
Builder: &DIBuilder<'ll>,
1678+
Scope: Option<&'ll Metadata>,
1679+
Name: *const c_uchar,
1680+
NameLen: size_t,
1681+
File: &'ll Metadata,
1682+
LineNumber: c_uint,
1683+
SizeInBits: u64,
1684+
AlignInBits: u32,
1685+
Flags: DIFlags,
1686+
Elements: *const &'ll Metadata,
1687+
NumElements: c_uint,
1688+
RunTimeLang: c_uint, // (optional; default is 0)
1689+
UniqueId: *const c_uchar,
1690+
UniqueIdLen: size_t,
1691+
) -> &'ll Metadata;
16751692
}
16761693

16771694
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2176,22 +2193,6 @@ unsafe extern "C" {
21762193
IsScoped: bool,
21772194
) -> &'a DIType;
21782195

2179-
pub fn LLVMRustDIBuilderCreateUnionType<'a>(
2180-
Builder: &DIBuilder<'a>,
2181-
Scope: Option<&'a DIScope>,
2182-
Name: *const c_char,
2183-
NameLen: size_t,
2184-
File: &'a DIFile,
2185-
LineNumber: c_uint,
2186-
SizeInBits: u64,
2187-
AlignInBits: u32,
2188-
Flags: DIFlags,
2189-
Elements: Option<&'a DIArray>,
2190-
RunTimeLang: c_uint,
2191-
UniqueId: *const c_char,
2192-
UniqueIdLen: size_t,
2193-
) -> &'a DIType;
2194-
21952196
pub fn LLVMRustDIBuilderCreateVariantPart<'a>(
21962197
Builder: &DIBuilder<'a>,
21972198
Scope: &'a DIScope,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

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

1177-
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType(
1178-
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1179-
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1180-
uint64_t SizeInBits, uint32_t AlignInBits, LLVMRustDIFlags Flags,
1181-
LLVMMetadataRef Elements, unsigned RunTimeLang, const char *UniqueId,
1182-
size_t UniqueIdLen) {
1183-
return wrap(Builder->createUnionType(
1184-
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
1185-
unwrapDI<DIFile>(File), LineNumber, SizeInBits, AlignInBits,
1186-
fromRust(Flags), DINodeArray(unwrapDI<MDTuple>(Elements)), RunTimeLang,
1187-
StringRef(UniqueId, UniqueIdLen)));
1188-
}
1189-
11901177
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTemplateTypeParameter(
11911178
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
11921179
size_t NameLen, LLVMMetadataRef Ty) {

0 commit comments

Comments
 (0)