Skip to content

Commit bef8f64

Browse files
committed
Use LLVMDIBuilderCreateArrayType
1 parent 2552deb commit bef8f64

File tree

3 files changed

+15
-25
lines changed

3 files changed

+15
-25
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ use self::type_map::{DINodeCreationResult, Stub, UniqueTypeId};
3232
use super::CodegenUnitDebugContext;
3333
use super::namespace::mangled_name_of_instance;
3434
use super::type_names::{compute_debuginfo_type_name, compute_debuginfo_vtable_name};
35-
use super::utils::{
36-
DIB, create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit,
37-
};
35+
use super::utils::{DIB, debug_context, get_namespace_for_item, is_node_local_to_unit};
3836
use crate::common::{AsCCharPtr, CodegenCx};
3937
use crate::debuginfo::dwarf_const;
4038
use crate::debuginfo::metadata::type_map::build_type_with_children;
@@ -119,17 +117,17 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>(
119117
.try_to_target_usize(cx.tcx)
120118
.expect("expected monomorphic const in codegen") as c_longlong;
121119

122-
let subrange =
123-
unsafe { Some(llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound)) };
120+
let subrange = unsafe { llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound) };
121+
let subscripts = &[subrange];
124122

125-
let subscripts = create_DIArray(DIB(cx), &[subrange]);
126123
let di_node = unsafe {
127-
llvm::LLVMRustDIBuilderCreateArrayType(
124+
llvm::LLVMDIBuilderCreateArrayType(
128125
DIB(cx),
129126
size.bits(),
130127
align.bits() as u32,
131128
element_type_di_node,
132-
subscripts,
129+
subscripts.as_ptr(),
130+
subscripts.len() as c_uint,
133131
)
134132
};
135133

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,15 @@ unsafe extern "C" {
18951895
UniqueId: *const c_uchar, // See "PTR_LEN_STR".
18961896
UniqueIdLen: size_t,
18971897
) -> &'ll Metadata;
1898+
1899+
pub(crate) fn LLVMDIBuilderCreateArrayType<'ll>(
1900+
Builder: &DIBuilder<'ll>,
1901+
Size: u64,
1902+
Align: u32,
1903+
Ty: &'ll Metadata,
1904+
Subscripts: *const &'ll Metadata,
1905+
NumSubscripts: c_uint,
1906+
) -> &'ll Metadata;
18981907
}
18991908

19001909
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2355,14 +2364,6 @@ unsafe extern "C" {
23552364
AlignInBits: u32,
23562365
) -> &'a DIVariable;
23572366

2358-
pub(crate) fn LLVMRustDIBuilderCreateArrayType<'a>(
2359-
Builder: &DIBuilder<'a>,
2360-
Size: u64,
2361-
AlignInBits: u32,
2362-
Ty: &'a DIType,
2363-
Subscripts: &'a DIArray,
2364-
) -> &'a DIType;
2365-
23662367
pub(crate) fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
23672368
Builder: &DIBuilder<'a>,
23682369
Lo: i64,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,15 +1211,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
12111211
}
12121212
}
12131213

1214-
extern "C" LLVMMetadataRef
1215-
LLVMRustDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size,
1216-
uint32_t AlignInBits, LLVMMetadataRef Ty,
1217-
LLVMMetadataRef Subscripts) {
1218-
return wrap(unwrap(Builder)->createArrayType(
1219-
Size, AlignInBits, unwrapDI<DIType>(Ty),
1220-
DINodeArray(unwrapDI<MDTuple>(Subscripts))));
1221-
}
1222-
12231214
extern "C" LLVMMetadataRef
12241215
LLVMRustDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, int64_t Lo,
12251216
int64_t Count) {

0 commit comments

Comments
 (0)