Skip to content

Commit e270f72

Browse files
committed
Use LLVMDIBuilderCreateSubroutineType
1 parent 4415a9a commit e270f72

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
@@ -1664,6 +1664,14 @@ unsafe extern "C" {
16641664
Scope: &'ll Metadata,
16651665
InlinedAt: Option<&'ll Metadata>,
16661666
) -> &'ll Metadata;
1667+
1668+
pub(crate) fn LLVMDIBuilderCreateSubroutineType<'ll>(
1669+
Builder: &DIBuilder<'ll>,
1670+
File: Option<&'ll Metadata>, // (unused)
1671+
ParameterTypes: *const Option<&'ll Metadata>,
1672+
NumParameterTypes: c_uint,
1673+
Flags: DIFlags, // (optional; default is `DIFlags::FlagZero`)
1674+
) -> &'ll Metadata;
16671675
}
16681676

16691677
#[link(name = "llvm-wrapper", kind = "static")]
@@ -1963,11 +1971,6 @@ unsafe extern "C" {
19631971
SourceLen: size_t,
19641972
) -> &'a DIFile;
19651973

1966-
pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(
1967-
Builder: &DIBuilder<'a>,
1968-
ParameterTypes: &'a DIArray,
1969-
) -> &'a DICompositeType;
1970-
19711974
pub fn LLVMRustDIBuilderCreateFunction<'a>(
19721975
Builder: &DIBuilder<'a>,
19731976
Scope: &'a DIDescriptor,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -942,13 +942,6 @@ LLVMRustDIBuilderCreateFile(LLVMRustDIBuilderRef Builder, const char *Filename,
942942
oSource));
943943
}
944944

945-
extern "C" LLVMMetadataRef
946-
LLVMRustDIBuilderCreateSubroutineType(LLVMRustDIBuilderRef Builder,
947-
LLVMMetadataRef ParameterTypes) {
948-
return wrap(Builder->createSubroutineType(
949-
DITypeRefArray(unwrap<MDTuple>(ParameterTypes))));
950-
}
951-
952945
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
953946
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
954947
size_t NameLen, const char *LinkageName, size_t LinkageNameLen,

0 commit comments

Comments
 (0)