Skip to content

Commit 73383d3

Browse files
committed
Use LLVMDIBuilderCreateSubroutineType
1 parent 6cc2a28 commit 73383d3

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,12 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
325325
debug_context(cx).type_map.unique_id_to_di_node.borrow_mut().remove(&unique_type_id);
326326

327327
let fn_di_node = unsafe {
328-
llvm::LLVMRustDIBuilderCreateSubroutineType(
328+
llvm::LLVMDIBuilderCreateSubroutineType(
329329
DIB(cx),
330-
create_DIArray(DIB(cx), &signature_di_nodes[..]),
330+
None,
331+
signature_di_nodes.as_ptr(),
332+
signature_di_nodes.len() as c_uint,
333+
DIFlags::FlagZero,
331334
)
332335
};
333336

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,13 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
319319

320320
let function_type_metadata = unsafe {
321321
let fn_signature = get_function_signature(self, fn_abi);
322-
llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(self), fn_signature)
322+
llvm::LLVMDIBuilderCreateSubroutineType(
323+
DIB(self),
324+
None,
325+
fn_signature.as_ptr(),
326+
fn_signature.len() as c_uint,
327+
DIFlags::FlagZero,
328+
)
323329
};
324330

325331
let mut name = String::with_capacity(64);
@@ -412,9 +418,9 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
412418
fn get_function_signature<'ll, 'tcx>(
413419
cx: &CodegenCx<'ll, 'tcx>,
414420
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
415-
) -> &'ll DIArray {
421+
) -> Vec<Option<&'ll llvm::Metadata>> {
416422
if cx.sess().opts.debuginfo != DebugInfo::Full {
417-
return create_DIArray(DIB(cx), &[]);
423+
return vec![];
418424
}
419425

420426
let mut signature = Vec::with_capacity(fn_abi.args.len() + 1);
@@ -455,7 +461,7 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
455461
.extend(fn_abi.args.iter().map(|arg| Some(type_di_node(cx, arg.layout.ty))));
456462
}
457463

458-
create_DIArray(DIB(cx), &signature[..])
464+
signature
459465
}
460466

461467
fn get_template_parameters<'ll, 'tcx>(

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,14 @@ unsafe extern "C" {
16621662
Scope: &'ll Metadata,
16631663
InlinedAt: Option<&'ll Metadata>,
16641664
) -> &'ll Metadata;
1665+
1666+
pub(crate) fn LLVMDIBuilderCreateSubroutineType<'ll>(
1667+
Builder: &DIBuilder<'ll>,
1668+
File: Option<&'ll Metadata>, // (unused)
1669+
ParameterTypes: *const Option<&'ll Metadata>,
1670+
NumParameterTypes: c_uint,
1671+
Flags: DIFlags,
1672+
) -> &'ll Metadata;
16651673
}
16661674

16671675
#[link(name = "llvm-wrapper", kind = "static")]
@@ -1961,11 +1969,6 @@ unsafe extern "C" {
19611969
SourceLen: size_t,
19621970
) -> &'a DIFile;
19631971

1964-
pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(
1965-
Builder: &DIBuilder<'a>,
1966-
ParameterTypes: &'a DIArray,
1967-
) -> &'a DICompositeType;
1968-
19691972
pub fn LLVMRustDIBuilderCreateFunction<'a>(
19701973
Builder: &DIBuilder<'a>,
19711974
Scope: &'a DIDescriptor,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -929,13 +929,6 @@ LLVMRustDIBuilderCreateFile(LLVMRustDIBuilderRef Builder, const char *Filename,
929929
oSource));
930930
}
931931

932-
extern "C" LLVMMetadataRef
933-
LLVMRustDIBuilderCreateSubroutineType(LLVMRustDIBuilderRef Builder,
934-
LLVMMetadataRef ParameterTypes) {
935-
return wrap(Builder->createSubroutineType(
936-
DITypeRefArray(unwrap<MDTuple>(ParameterTypes))));
937-
}
938-
939932
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
940933
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
941934
size_t NameLen, const char *LinkageName, size_t LinkageNameLen,

0 commit comments

Comments
 (0)