Skip to content

Commit 6230db2

Browse files
committed
Use LLVMDIBuilderCreateArrayType
1 parent 71e8169 commit 6230db2

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
@@ -1687,6 +1687,15 @@ unsafe extern "C" {
16871687
UniqueId: *const c_uchar,
16881688
UniqueIdLen: size_t,
16891689
) -> &'ll Metadata;
1690+
1691+
pub(crate) fn LLVMDIBuilderCreateArrayType<'ll>(
1692+
Builder: &DIBuilder<'ll>,
1693+
Size: u64,
1694+
AlignInBits: u32,
1695+
Ty: &'ll Metadata,
1696+
Subscripts: *const &'ll Metadata,
1697+
NumSubscripts: c_uint,
1698+
) -> &'ll Metadata;
16901699
}
16911700

16921701
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2138,14 +2147,6 @@ unsafe extern "C" {
21382147
AlignInBits: u32,
21392148
) -> &'a DIVariable;
21402149

2141-
pub fn LLVMRustDIBuilderCreateArrayType<'a>(
2142-
Builder: &DIBuilder<'a>,
2143-
Size: u64,
2144-
AlignInBits: u32,
2145-
Ty: &'a DIType,
2146-
Subscripts: &'a DIArray,
2147-
) -> &'a DIType;
2148-
21492150
pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
21502151
Builder: &DIBuilder<'a>,
21512152
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)