Skip to content

Commit 5419896

Browse files
committed
Use LLVMDIBuilderCreateSubroutineType
1 parent 9d82de1 commit 5419896

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
318318

319319
debug_context(cx).type_map.unique_id_to_di_node.borrow_mut().remove(&unique_type_id);
320320

321-
let fn_di_node = create_subroutine_type(cx, create_DIArray(DIB(cx), &signature_di_nodes[..]));
321+
let fn_di_node = create_subroutine_type(cx, &signature_di_nodes[..]);
322322

323323
// This is actually a function pointer, so wrap it in pointer DI.
324324
let name = compute_debuginfo_type_name(cx.tcx, fn_ty, false);
@@ -346,9 +346,17 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
346346

347347
pub(super) fn create_subroutine_type<'ll>(
348348
cx: &CodegenCx<'ll, '_>,
349-
signature: &'ll DICompositeType,
349+
signature: &[Option<&'ll llvm::Metadata>],
350350
) -> &'ll DICompositeType {
351-
unsafe { llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(cx), signature) }
351+
unsafe {
352+
llvm::LLVMDIBuilderCreateSubroutineType(
353+
DIB(cx),
354+
None, // ("File" is ignored and has no effect)
355+
signature.as_ptr(),
356+
signature.len() as c_uint,
357+
DIFlags::FlagZero, // (default value)
358+
)
359+
}
352360
}
353361

354362
/// Create debuginfo for `dyn SomeTrait` types. Currently these are empty structs

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
349349
let file_metadata = file_metadata(self, &loc.file);
350350

351351
let function_type_metadata =
352-
create_subroutine_type(self, get_function_signature(self, fn_abi));
352+
create_subroutine_type(self, &get_function_signature(self, fn_abi));
353353

354354
let mut name = String::with_capacity(64);
355355
type_names::push_item_name(tcx, def_id, false, &mut name);
@@ -441,9 +441,9 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
441441
fn get_function_signature<'ll, 'tcx>(
442442
cx: &CodegenCx<'ll, 'tcx>,
443443
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
444-
) -> &'ll DIArray {
444+
) -> Vec<Option<&'ll llvm::Metadata>> {
445445
if cx.sess().opts.debuginfo != DebugInfo::Full {
446-
return create_DIArray(DIB(cx), &[]);
446+
return vec![];
447447
}
448448

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

487-
create_DIArray(DIB(cx), &signature[..])
487+
signature
488488
}
489489

490490
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
@@ -1870,6 +1870,14 @@ unsafe extern "C" {
18701870
Scope: &'ll Metadata,
18711871
InlinedAt: Option<&'ll Metadata>,
18721872
) -> &'ll Metadata;
1873+
1874+
pub(crate) fn LLVMDIBuilderCreateSubroutineType<'ll>(
1875+
Builder: &DIBuilder<'ll>,
1876+
File: Option<&'ll Metadata>, // (ignored and has no effect)
1877+
ParameterTypes: *const Option<&'ll Metadata>,
1878+
NumParameterTypes: c_uint,
1879+
Flags: DIFlags, // (default is `DIFlags::DIFlagZero`)
1880+
) -> &'ll Metadata;
18731881
}
18741882

18751883
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2172,11 +2180,6 @@ unsafe extern "C" {
21722180
SourceLen: size_t,
21732181
) -> &'a DIFile;
21742182

2175-
pub(crate) fn LLVMRustDIBuilderCreateSubroutineType<'a>(
2176-
Builder: &DIBuilder<'a>,
2177-
ParameterTypes: &'a DIArray,
2178-
) -> &'a DICompositeType;
2179-
21802183
pub(crate) fn LLVMRustDIBuilderCreateFunction<'a>(
21812184
Builder: &DIBuilder<'a>,
21822185
Scope: &'a DIDescriptor,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,13 +1026,6 @@ LLVMRustDIBuilderCreateFile(LLVMDIBuilderRef Builder, const char *Filename,
10261026
CSInfo, oSource));
10271027
}
10281028

1029-
extern "C" LLVMMetadataRef
1030-
LLVMRustDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder,
1031-
LLVMMetadataRef ParameterTypes) {
1032-
return wrap(unwrap(Builder)->createSubroutineType(
1033-
DITypeRefArray(unwrap<MDTuple>(ParameterTypes))));
1034-
}
1035-
10361029
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
10371030
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
10381031
size_t NameLen, const char *LinkageName, size_t LinkageNameLen,

0 commit comments

Comments
 (0)