Use `LLVMDIBuilderCreateArrayType`
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
index db821b3..fcbfe6c 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
@@ -32,9 +32,7 @@
use super::CodegenUnitDebugContext;
use super::namespace::mangled_name_of_instance;
use super::type_names::{compute_debuginfo_type_name, compute_debuginfo_vtable_name};
-use super::utils::{
- DIB, create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit,
-};
+use super::utils::{DIB, debug_context, get_namespace_for_item, is_node_local_to_unit};
use crate::common::{AsCCharPtr, CodegenCx};
use crate::debuginfo::dwarf_const;
use crate::debuginfo::metadata::type_map::build_type_with_children;
@@ -119,17 +117,17 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>(
.try_to_target_usize(cx.tcx)
.expect("expected monomorphic const in codegen") as c_longlong;
- let subrange =
- unsafe { Some(llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound)) };
+ let subrange = unsafe { llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound) };
+ let subscripts = &[subrange];
- let subscripts = create_DIArray(DIB(cx), &[subrange]);
let di_node = unsafe {
- llvm::LLVMRustDIBuilderCreateArrayType(
+ llvm::LLVMDIBuilderCreateArrayType(
DIB(cx),
size.bits(),
align.bits() as u32,
element_type_di_node,
- subscripts,
+ subscripts.as_ptr(),
+ subscripts.len() as c_uint,
)
};
diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
index 58aebe4..e242698 100644
--- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
@@ -1895,6 +1895,15 @@ pub(crate) fn LLVMDIBuilderCreateUnionType<'ll>(
UniqueId: *const c_uchar, // See "PTR_LEN_STR".
UniqueIdLen: size_t,
) -> &'ll Metadata;
+
+ pub(crate) fn LLVMDIBuilderCreateArrayType<'ll>(
+ Builder: &DIBuilder<'ll>,
+ Size: u64,
+ Align: u32,
+ Ty: &'ll Metadata,
+ Subscripts: *const &'ll Metadata,
+ NumSubscripts: c_uint,
+ ) -> &'ll Metadata;
}
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2355,14 +2364,6 @@ pub(crate) fn LLVMRustDIBuilderCreateVariable<'a>(
AlignInBits: u32,
) -> &'a DIVariable;
- pub(crate) fn LLVMRustDIBuilderCreateArrayType<'a>(
- Builder: &DIBuilder<'a>,
- Size: u64,
- AlignInBits: u32,
- Ty: &'a DIType,
- Subscripts: &'a DIArray,
- ) -> &'a DIType;
-
pub(crate) fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
Builder: &DIBuilder<'a>,
Lo: i64,
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index 2cbfcf7..d5be7ae 100644
--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
@@ -1212,15 +1212,6 @@
}
extern "C" LLVMMetadataRef
-LLVMRustDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size,
- uint32_t AlignInBits, LLVMMetadataRef Ty,
- LLVMMetadataRef Subscripts) {
- return wrap(unwrap(Builder)->createArrayType(
- Size, AlignInBits, unwrapDI<DIType>(Ty),
- DINodeArray(unwrapDI<MDTuple>(Subscripts))));
-}
-
-extern "C" LLVMMetadataRef
LLVMRustDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, int64_t Lo,
int64_t Count) {
return wrap(unwrap(Builder)->getOrCreateSubrange(Lo, Count));