Skip to content

Commit f4f8663

Browse files
committed
Use LLVMDIBuilderCreateArrayType
1 parent a9332af commit f4f8663

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
@@ -1795,6 +1795,15 @@ unsafe extern "C" {
17951795
UniqueId: *const c_uchar,
17961796
UniqueIdLen: size_t,
17971797
) -> &'ll Metadata;
1798+
1799+
pub(crate) fn LLVMDIBuilderCreateArrayType<'ll>(
1800+
Builder: &DIBuilder<'ll>,
1801+
Size: u64,
1802+
AlignInBits: u32,
1803+
Ty: &'ll Metadata,
1804+
Subscripts: *const &'ll Metadata,
1805+
NumSubscripts: c_uint,
1806+
) -> &'ll Metadata;
17981807
}
17991808

18001809
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2266,14 +2275,6 @@ unsafe extern "C" {
22662275
AlignInBits: u32,
22672276
) -> &'a DIVariable;
22682277

2269-
pub(crate) fn LLVMRustDIBuilderCreateArrayType<'a>(
2270-
Builder: &DIBuilder<'a>,
2271-
Size: u64,
2272-
AlignInBits: u32,
2273-
Ty: &'a DIType,
2274-
Subscripts: &'a DIArray,
2275-
) -> &'a DIType;
2276-
22772278
pub(crate) fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
22782279
Builder: &DIBuilder<'a>,
22792280
Lo: i64,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -1194,15 +1194,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
11941194
}
11951195
}
11961196

1197-
extern "C" LLVMMetadataRef
1198-
LLVMRustDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size,
1199-
uint32_t AlignInBits, LLVMMetadataRef Ty,
1200-
LLVMMetadataRef Subscripts) {
1201-
return wrap(unwrap(Builder)->createArrayType(
1202-
Size, AlignInBits, unwrapDI<DIType>(Ty),
1203-
DINodeArray(unwrapDI<MDTuple>(Subscripts))));
1204-
}
1205-
12061197
extern "C" LLVMMetadataRef
12071198
LLVMRustDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, int64_t Lo,
12081199
int64_t Count) {

0 commit comments

Comments
 (0)