Skip to content

Commit 19d8f46

Browse files
committed
Use LLVMDIBuilderCreateSubroutineType
1 parent b60a737 commit 19d8f46

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
@@ -324,9 +324,12 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
324324
debug_context(cx).type_map.unique_id_to_di_node.borrow_mut().remove(&unique_type_id);
325325

326326
let fn_di_node = unsafe {
327-
llvm::LLVMRustDIBuilderCreateSubroutineType(
327+
llvm::LLVMDIBuilderCreateSubroutineType(
328328
DIB(cx),
329-
create_DIArray(DIB(cx), &signature_di_nodes[..]),
329+
/* File (unused) */ None,
330+
signature_di_nodes.as_ptr(),
331+
signature_di_nodes.len() as c_uint,
332+
DIFlags::FlagZero,
330333
)
331334
};
332335

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

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

319319
let function_type_metadata = unsafe {
320320
let fn_signature = get_function_signature(self, fn_abi);
321-
llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(self), fn_signature)
321+
llvm::LLVMDIBuilderCreateSubroutineType(
322+
DIB(self),
323+
/* File (unused) */ None,
324+
fn_signature.as_ptr(),
325+
fn_signature.len() as c_uint,
326+
DIFlags::FlagZero,
327+
)
322328
};
323329

324330
let mut name = String::with_capacity(64);
@@ -411,9 +417,9 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
411417
fn get_function_signature<'ll, 'tcx>(
412418
cx: &CodegenCx<'ll, 'tcx>,
413419
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
414-
) -> &'ll DIArray {
420+
) -> Vec<Option<&'ll llvm::Metadata>> {
415421
if cx.sess().opts.debuginfo != DebugInfo::Full {
416-
return create_DIArray(DIB(cx), &[]);
422+
return vec![];
417423
}
418424

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

457-
create_DIArray(DIB(cx), &signature[..])
463+
signature
458464
}
459465

460466
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
@@ -1654,6 +1654,14 @@ unsafe extern "C" {
16541654
Scope: &'ll Metadata,
16551655
InlinedAt: Option<&'ll Metadata>,
16561656
) -> &'ll Metadata;
1657+
1658+
pub(crate) fn LLVMDIBuilderCreateSubroutineType<'ll>(
1659+
Builder: &DIBuilder<'ll>,
1660+
File: Option<&'ll Metadata>, // (unused)
1661+
ParameterTypes: *const Option<&'ll Metadata>,
1662+
NumParameterTypes: c_uint,
1663+
Flags: DIFlags, // (optional; default is `DIFlags::FlagZero`)
1664+
) -> &'ll Metadata;
16571665
}
16581666

16591667
#[link(name = "llvm-wrapper", kind = "static")]
@@ -1953,11 +1961,6 @@ unsafe extern "C" {
19531961
SourceLen: size_t,
19541962
) -> &'a DIFile;
19551963

1956-
pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(
1957-
Builder: &DIBuilder<'a>,
1958-
ParameterTypes: &'a DIArray,
1959-
) -> &'a DICompositeType;
1960-
19611964
pub fn LLVMRustDIBuilderCreateFunction<'a>(
19621965
Builder: &DIBuilder<'a>,
19631966
Scope: &'a DIDescriptor,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,13 +1019,6 @@ LLVMRustDIBuilderCreateFile(LLVMRustDIBuilderRef Builder, const char *Filename,
10191019
oSource));
10201020
}
10211021

1022-
extern "C" LLVMMetadataRef
1023-
LLVMRustDIBuilderCreateSubroutineType(LLVMRustDIBuilderRef Builder,
1024-
LLVMMetadataRef ParameterTypes) {
1025-
return wrap(Builder->createSubroutineType(
1026-
DITypeRefArray(unwrap<MDTuple>(ParameterTypes))));
1027-
}
1028-
10291022
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
10301023
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
10311024
size_t NameLen, const char *LinkageName, size_t LinkageNameLen,

0 commit comments

Comments
 (0)