Skip to content

Commit

Permalink
Use LLVMDIBuilderCreateSubroutineType
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalathar committed Jan 3, 2025
1 parent b60a737 commit 19d8f46
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
7 changes: 5 additions & 2 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,12 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
debug_context(cx).type_map.unique_id_to_di_node.borrow_mut().remove(&unique_type_id);

let fn_di_node = unsafe {
llvm::LLVMRustDIBuilderCreateSubroutineType(
llvm::LLVMDIBuilderCreateSubroutineType(
DIB(cx),
create_DIArray(DIB(cx), &signature_di_nodes[..]),
/* File (unused) */ None,
signature_di_nodes.as_ptr(),
signature_di_nodes.len() as c_uint,
DIFlags::FlagZero,
)
};

Expand Down
14 changes: 10 additions & 4 deletions compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,13 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {

let function_type_metadata = unsafe {
let fn_signature = get_function_signature(self, fn_abi);
llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(self), fn_signature)
llvm::LLVMDIBuilderCreateSubroutineType(
DIB(self),
/* File (unused) */ None,
fn_signature.as_ptr(),
fn_signature.len() as c_uint,
DIFlags::FlagZero,
)
};

let mut name = String::with_capacity(64);
Expand Down Expand Up @@ -411,9 +417,9 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
fn get_function_signature<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
) -> &'ll DIArray {
) -> Vec<Option<&'ll llvm::Metadata>> {
if cx.sess().opts.debuginfo != DebugInfo::Full {
return create_DIArray(DIB(cx), &[]);
return vec![];
}

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

create_DIArray(DIB(cx), &signature[..])
signature
}

fn get_template_parameters<'ll, 'tcx>(
Expand Down
13 changes: 8 additions & 5 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,14 @@ unsafe extern "C" {
Scope: &'ll Metadata,
InlinedAt: Option<&'ll Metadata>,
) -> &'ll Metadata;

pub(crate) fn LLVMDIBuilderCreateSubroutineType<'ll>(
Builder: &DIBuilder<'ll>,
File: Option<&'ll Metadata>, // (unused)
ParameterTypes: *const Option<&'ll Metadata>,
NumParameterTypes: c_uint,
Flags: DIFlags, // (optional; default is `DIFlags::FlagZero`)
) -> &'ll Metadata;
}

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

pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(
Builder: &DIBuilder<'a>,
ParameterTypes: &'a DIArray,
) -> &'a DICompositeType;

pub fn LLVMRustDIBuilderCreateFunction<'a>(
Builder: &DIBuilder<'a>,
Scope: &'a DIDescriptor,
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,13 +1019,6 @@ LLVMRustDIBuilderCreateFile(LLVMRustDIBuilderRef Builder, const char *Filename,
oSource));
}

extern "C" LLVMMetadataRef
LLVMRustDIBuilderCreateSubroutineType(LLVMRustDIBuilderRef Builder,
LLVMMetadataRef ParameterTypes) {
return wrap(Builder->createSubroutineType(
DITypeRefArray(unwrap<MDTuple>(ParameterTypes))));
}

extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
size_t NameLen, const char *LinkageName, size_t LinkageNameLen,
Expand Down

0 comments on commit 19d8f46

Please sign in to comment.