Skip to content

Commit 03224ee

Browse files
committed
Use LLVMDIBuilderCreateArrayType
1 parent 14f48d9 commit 03224ee

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
@@ -26,9 +26,7 @@ use self::type_map::{DINodeCreationResult, Stub, UniqueTypeId};
2626
use super::CodegenUnitDebugContext;
2727
use super::namespace::mangled_name_of_instance;
2828
use super::type_names::{compute_debuginfo_type_name, compute_debuginfo_vtable_name};
29-
use super::utils::{
30-
DIB, create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit,
31-
};
29+
use super::utils::{DIB, debug_context, get_namespace_for_item, is_node_local_to_unit};
3230
use crate::common::{AsCCharPtr, CodegenCx};
3331
use crate::debuginfo::metadata::type_map::build_type_with_children;
3432
use crate::debuginfo::utils::{WidePtrKind, wide_pointer_kind};
@@ -126,17 +124,17 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>(
126124
.try_to_target_usize(cx.tcx)
127125
.expect("expected monomorphic const in codegen") as c_longlong;
128126

129-
let subrange =
130-
unsafe { Some(llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound)) };
127+
let subrange = unsafe { llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound) };
131128

132-
let subscripts = create_DIArray(DIB(cx), &[subrange]);
129+
let subscripts = &[subrange];
133130
let di_node = unsafe {
134-
llvm::LLVMRustDIBuilderCreateArrayType(
131+
llvm::LLVMDIBuilderCreateArrayType(
135132
DIB(cx),
136133
size.bits(),
137134
align.bits() as u32,
138135
element_type_di_node,
139-
subscripts,
136+
subscripts.as_ptr(),
137+
subscripts.len() as c_uint,
140138
)
141139
};
142140

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,15 @@ unsafe extern "C" {
16891689
UniqueId: *const c_uchar,
16901690
UniqueIdLen: size_t,
16911691
) -> &'ll Metadata;
1692+
1693+
pub(crate) fn LLVMDIBuilderCreateArrayType<'ll>(
1694+
Builder: &DIBuilder<'ll>,
1695+
Size: u64,
1696+
AlignInBits: u32,
1697+
Ty: &'ll Metadata,
1698+
Subscripts: *const &'ll Metadata,
1699+
NumSubscripts: c_uint,
1700+
) -> &'ll Metadata;
16921701
}
16931702

16941703
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2140,14 +2149,6 @@ unsafe extern "C" {
21402149
AlignInBits: u32,
21412150
) -> &'a DIVariable;
21422151

2143-
pub fn LLVMRustDIBuilderCreateArrayType<'a>(
2144-
Builder: &DIBuilder<'a>,
2145-
Size: u64,
2146-
AlignInBits: u32,
2147-
Ty: &'a DIType,
2148-
Subscripts: &'a DIArray,
2149-
) -> &'a DIType;
2150-
21512152
pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
21522153
Builder: &DIBuilder<'a>,
21532154
Lo: i64,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,15 +1120,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
11201120
}
11211121
}
11221122

1123-
extern "C" LLVMMetadataRef
1124-
LLVMRustDIBuilderCreateArrayType(LLVMRustDIBuilderRef Builder, uint64_t Size,
1125-
uint32_t AlignInBits, LLVMMetadataRef Ty,
1126-
LLVMMetadataRef Subscripts) {
1127-
return wrap(
1128-
Builder->createArrayType(Size, AlignInBits, unwrapDI<DIType>(Ty),
1129-
DINodeArray(unwrapDI<MDTuple>(Subscripts))));
1130-
}
1131-
11321123
extern "C" LLVMMetadataRef
11331124
LLVMRustDIBuilderGetOrCreateSubrange(LLVMRustDIBuilderRef Builder, int64_t Lo,
11341125
int64_t Count) {

0 commit comments

Comments
 (0)