Skip to content

Commit 4115c7a

Browse files
committed
Use LLVMDIBuilderCreateArrayType
1 parent a678b0d commit 4115c7a

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
@@ -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::metadata::type_map::build_type_with_children;
3533
use crate::debuginfo::utils::{WidePtrKind, wide_pointer_kind};
@@ -127,17 +125,17 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>(
127125
.try_to_target_usize(cx.tcx)
128126
.expect("expected monomorphic const in codegen") as c_longlong;
129127

130-
let subrange =
131-
unsafe { Some(llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound)) };
128+
let subrange = unsafe { llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound) };
132129

133-
let subscripts = create_DIArray(DIB(cx), &[subrange]);
130+
let subscripts = &[subrange];
134131
let di_node = unsafe {
135-
llvm::LLVMRustDIBuilderCreateArrayType(
132+
llvm::LLVMDIBuilderCreateArrayType(
136133
DIB(cx),
137134
size.bits(),
138135
align.bits() as u32,
139136
element_type_di_node,
140-
subscripts,
137+
subscripts.as_ptr(),
138+
subscripts.len() as c_uint,
141139
)
142140
};
143141

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,15 @@ unsafe extern "C" {
16851685
UniqueId: *const c_uchar,
16861686
UniqueIdLen: size_t,
16871687
) -> &'ll Metadata;
1688+
1689+
pub(crate) fn LLVMDIBuilderCreateArrayType<'ll>(
1690+
Builder: &DIBuilder<'ll>,
1691+
Size: u64,
1692+
AlignInBits: u32,
1693+
Ty: &'ll Metadata,
1694+
Subscripts: *const &'ll Metadata,
1695+
NumSubscripts: c_uint,
1696+
) -> &'ll Metadata;
16881697
}
16891698

16901699
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2136,14 +2145,6 @@ unsafe extern "C" {
21362145
AlignInBits: u32,
21372146
) -> &'a DIVariable;
21382147

2139-
pub fn LLVMRustDIBuilderCreateArrayType<'a>(
2140-
Builder: &DIBuilder<'a>,
2141-
Size: u64,
2142-
AlignInBits: u32,
2143-
Ty: &'a DIType,
2144-
Subscripts: &'a DIArray,
2145-
) -> &'a DIType;
2146-
21472148
pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
21482149
Builder: &DIBuilder<'a>,
21492150
Lo: i64,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,15 +1107,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
11071107
}
11081108
}
11091109

1110-
extern "C" LLVMMetadataRef
1111-
LLVMRustDIBuilderCreateArrayType(LLVMRustDIBuilderRef Builder, uint64_t Size,
1112-
uint32_t AlignInBits, LLVMMetadataRef Ty,
1113-
LLVMMetadataRef Subscripts) {
1114-
return wrap(
1115-
Builder->createArrayType(Size, AlignInBits, unwrapDI<DIType>(Ty),
1116-
DINodeArray(unwrapDI<MDTuple>(Subscripts))));
1117-
}
1118-
11191110
extern "C" LLVMMetadataRef
11201111
LLVMRustDIBuilderGetOrCreateSubrange(LLVMRustDIBuilderRef Builder, int64_t Lo,
11211112
int64_t Count) {

0 commit comments

Comments
 (0)