Skip to content

Commit 8206a78

Browse files
committed
Use LLVMDIBuilderCreateArrayType
1 parent 6a1e75a commit 8206a78

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
@@ -29,9 +29,7 @@ use self::type_map::{DINodeCreationResult, Stub, UniqueTypeId};
2929
use super::CodegenUnitDebugContext;
3030
use super::namespace::mangled_name_of_instance;
3131
use super::type_names::{compute_debuginfo_type_name, compute_debuginfo_vtable_name};
32-
use super::utils::{
33-
DIB, create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit,
34-
};
32+
use super::utils::{DIB, debug_context, get_namespace_for_item, is_node_local_to_unit};
3533
use crate::common::{AsCCharPtr, CodegenCx};
3634
use crate::debuginfo::dwarf_const;
3735
use crate::debuginfo::metadata::type_map::build_type_with_children;
@@ -114,19 +112,9 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>(
114112
.try_to_target_usize(cx.tcx)
115113
.expect("expected monomorphic const in codegen") as c_longlong;
116114

117-
let subrange =
118-
unsafe { Some(llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound)) };
115+
let subrange = unsafe { llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound) };
119116

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

131119
DINodeCreationResult::new(di_node, false)
132120
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,15 @@ unsafe extern "C" {
17971797
UniqueId: *const c_uchar,
17981798
UniqueIdLen: size_t,
17991799
) -> &'ll Metadata;
1800+
1801+
pub(crate) fn LLVMDIBuilderCreateArrayType<'ll>(
1802+
Builder: &DIBuilder<'ll>,
1803+
Size: u64,
1804+
AlignInBits: u32,
1805+
Ty: &'ll Metadata,
1806+
Subscripts: *const &'ll Metadata,
1807+
NumSubscripts: c_uint,
1808+
) -> &'ll Metadata;
18001809
}
18011810

18021811
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2268,14 +2277,6 @@ unsafe extern "C" {
22682277
AlignInBits: u32,
22692278
) -> &'a DIVariable;
22702279

2271-
pub(crate) fn LLVMRustDIBuilderCreateArrayType<'a>(
2272-
Builder: &DIBuilder<'a>,
2273-
Size: u64,
2274-
AlignInBits: u32,
2275-
Ty: &'a DIType,
2276-
Subscripts: &'a DIArray,
2277-
) -> &'a DIType;
2278-
22792280
pub(crate) fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
22802281
Builder: &DIBuilder<'a>,
22812282
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)