Skip to content

Commit bd6dd53

Browse files
committed
Use LLVMDIBuilderCreateArrayType
1 parent 43f9d09 commit bd6dd53

File tree

4 files changed

+31
-32
lines changed

4 files changed

+31
-32
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/di_builder.rs

+19
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,23 @@ impl<'ll> DIBuilder<'ll> {
5454
)
5555
}
5656
}
57+
58+
pub(crate) fn create_array_type(
59+
&self,
60+
size: Size,
61+
align: Align,
62+
element_type: &'ll Metadata,
63+
subscripts: &[&'ll Metadata],
64+
) -> &'ll Metadata {
65+
unsafe {
66+
llvm::LLVMDIBuilderCreateArrayType(
67+
self,
68+
size.bits(),
69+
align.bits() as u32,
70+
element_type,
71+
subscripts.as_ptr(),
72+
subscripts.len() as c_uint,
73+
)
74+
}
75+
}
5776
}

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ use self::type_map::{DINodeCreationResult, Stub, UniqueTypeId};
2727
use super::CodegenUnitDebugContext;
2828
use super::namespace::mangled_name_of_instance;
2929
use super::type_names::{compute_debuginfo_type_name, compute_debuginfo_vtable_name};
30-
use super::utils::{
31-
DIB, create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit,
32-
};
30+
use super::utils::{DIB, debug_context, get_namespace_for_item, is_node_local_to_unit};
3331
use crate::common::{AsCCharPtr, CodegenCx};
3432
use crate::debuginfo::dwarf_const;
3533
use crate::debuginfo::metadata::type_map::build_type_with_children;
@@ -112,19 +110,9 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>(
112110
.try_to_target_usize(cx.tcx)
113111
.expect("expected monomorphic const in codegen") as c_longlong;
114112

115-
let subrange =
116-
unsafe { Some(llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound)) };
113+
let subrange = unsafe { llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound) };
117114

118-
let subscripts = create_DIArray(DIB(cx), &[subrange]);
119-
let di_node = unsafe {
120-
llvm::LLVMRustDIBuilderCreateArrayType(
121-
DIB(cx),
122-
size.bits(),
123-
align.bits() as u32,
124-
element_type_di_node,
125-
subscripts,
126-
)
127-
};
115+
let di_node = DIB(cx).create_array_type(size, align, element_type_di_node, &[subrange]);
128116

129117
DINodeCreationResult::new(di_node, false)
130118
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,15 @@ unsafe extern "C" {
17921792
UniqueId: *const c_uchar,
17931793
UniqueIdLen: size_t,
17941794
) -> &'ll Metadata;
1795+
1796+
pub(crate) fn LLVMDIBuilderCreateArrayType<'ll>(
1797+
Builder: &DIBuilder<'ll>,
1798+
Size: u64,
1799+
AlignInBits: u32,
1800+
Ty: &'ll Metadata,
1801+
Subscripts: *const &'ll Metadata,
1802+
NumSubscripts: c_uint,
1803+
) -> &'ll Metadata;
17951804
}
17961805

17971806
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2249,14 +2258,6 @@ unsafe extern "C" {
22492258
AlignInBits: u32,
22502259
) -> &'a DIVariable;
22512260

2252-
pub fn LLVMRustDIBuilderCreateArrayType<'a>(
2253-
Builder: &DIBuilder<'a>,
2254-
Size: u64,
2255-
AlignInBits: u32,
2256-
Ty: &'a DIType,
2257-
Subscripts: &'a DIArray,
2258-
) -> &'a DIType;
2259-
22602261
pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
22612262
Builder: &DIBuilder<'a>,
22622263
Lo: i64,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -1221,15 +1221,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
12211221
}
12221222
}
12231223

1224-
extern "C" LLVMMetadataRef
1225-
LLVMRustDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size,
1226-
uint32_t AlignInBits, LLVMMetadataRef Ty,
1227-
LLVMMetadataRef Subscripts) {
1228-
return wrap(unwrap(Builder)->createArrayType(
1229-
Size, AlignInBits, unwrapDI<DIType>(Ty),
1230-
DINodeArray(unwrapDI<MDTuple>(Subscripts))));
1231-
}
1232-
12331224
extern "C" LLVMMetadataRef
12341225
LLVMRustDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, int64_t Lo,
12351226
int64_t Count) {

0 commit comments

Comments
 (0)