Skip to content

Commit b2ee387

Browse files
committed
Use LLVMDIBuilderCreateSubroutineType
1 parent e8f3af5 commit b2ee387

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
@@ -1660,6 +1660,14 @@ unsafe extern "C" {
16601660
Scope: &'ll Metadata,
16611661
InlinedAt: Option<&'ll Metadata>,
16621662
) -> &'ll Metadata;
1663+
1664+
pub(crate) fn LLVMDIBuilderCreateSubroutineType<'ll>(
1665+
Builder: &DIBuilder<'ll>,
1666+
File: Option<&'ll Metadata>, // (unused)
1667+
ParameterTypes: *const Option<&'ll Metadata>,
1668+
NumParameterTypes: c_uint,
1669+
Flags: DIFlags,
1670+
) -> &'ll Metadata;
16631671
}
16641672

16651673
#[link(name = "llvm-wrapper", kind = "static")]
@@ -1959,11 +1967,6 @@ unsafe extern "C" {
19591967
SourceLen: size_t,
19601968
) -> &'a DIFile;
19611969

1962-
pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(
1963-
Builder: &DIBuilder<'a>,
1964-
ParameterTypes: &'a DIArray,
1965-
) -> &'a DICompositeType;
1966-
19671970
pub fn LLVMRustDIBuilderCreateFunction<'a>(
19681971
Builder: &DIBuilder<'a>,
19691972
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)