Skip to content

Commit a678b0d

Browse files
committed
Use LLVMDIBuilderCreateUnionType
1 parent b2ee387 commit a678b0d

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
@@ -1668,6 +1668,23 @@ unsafe extern "C" {
16681668
NumParameterTypes: c_uint,
16691669
Flags: DIFlags,
16701670
) -> &'ll Metadata;
1671+
1672+
pub(crate) fn LLVMDIBuilderCreateUnionType<'ll>(
1673+
Builder: &DIBuilder<'ll>,
1674+
Scope: Option<&'ll Metadata>,
1675+
Name: *const c_uchar,
1676+
NameLen: size_t,
1677+
File: &'ll Metadata,
1678+
LineNumber: c_uint,
1679+
SizeInBits: u64,
1680+
AlignInBits: u32,
1681+
Flags: DIFlags,
1682+
Elements: *const &'ll Metadata,
1683+
NumElements: c_uint,
1684+
RunTimeLang: c_uint,
1685+
UniqueId: *const c_uchar,
1686+
UniqueIdLen: size_t,
1687+
) -> &'ll Metadata;
16711688
}
16721689

16731690
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2172,22 +2189,6 @@ unsafe extern "C" {
21722189
IsScoped: bool,
21732190
) -> &'a DIType;
21742191

2175-
pub fn LLVMRustDIBuilderCreateUnionType<'a>(
2176-
Builder: &DIBuilder<'a>,
2177-
Scope: Option<&'a DIScope>,
2178-
Name: *const c_char,
2179-
NameLen: size_t,
2180-
File: &'a DIFile,
2181-
LineNumber: c_uint,
2182-
SizeInBits: u64,
2183-
AlignInBits: u32,
2184-
Flags: DIFlags,
2185-
Elements: Option<&'a DIArray>,
2186-
RunTimeLang: c_uint,
2187-
UniqueId: *const c_char,
2188-
UniqueIdLen: size_t,
2189-
) -> &'a DIType;
2190-
21912192
pub fn LLVMRustDIBuilderCreateVariantPart<'a>(
21922193
Builder: &DIBuilder<'a>,
21932194
Scope: &'a DIScope,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

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

1164-
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType(
1165-
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1166-
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1167-
uint64_t SizeInBits, uint32_t AlignInBits, LLVMRustDIFlags Flags,
1168-
LLVMMetadataRef Elements, unsigned RunTimeLang, const char *UniqueId,
1169-
size_t UniqueIdLen) {
1170-
return wrap(Builder->createUnionType(
1171-
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
1172-
unwrapDI<DIFile>(File), LineNumber, SizeInBits, AlignInBits,
1173-
fromRust(Flags), DINodeArray(unwrapDI<MDTuple>(Elements)), RunTimeLang,
1174-
StringRef(UniqueId, UniqueIdLen)));
1175-
}
1176-
11771164
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTemplateTypeParameter(
11781165
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
11791166
size_t NameLen, LLVMMetadataRef Ty) {

0 commit comments

Comments
 (0)