Skip to content

Commit 8be241f

Browse files
committed
rustc_codegen_llvm: rewrite debuginfo::get_function_signature to use FnAbi.
1 parent 0e70c4d commit 8be241f

File tree

1 file changed

+12
-33
lines changed
  • src/librustc_codegen_llvm/debuginfo

1 file changed

+12
-33
lines changed

src/librustc_codegen_llvm/debuginfo/mod.rs

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc::hir::CodegenFnAttrFlags;
1616
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
1717
use rustc::ty::subst::{SubstsRef, GenericArgKind};
1818

19-
use crate::abi::{Abi, FnAbi};
19+
use crate::abi::FnAbi;
2020
use crate::common::CodegenCx;
2121
use crate::builder::Builder;
2222
use crate::value::Value;
@@ -308,13 +308,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
308308
let file_metadata = file_metadata(self, &loc.file.name, def_id.krate);
309309

310310
let function_type_metadata = unsafe {
311-
// FIXME(eddyb) avoid this `Instance::fn_sig` call, by
312-
// rewriting `get_function_signature` to use `fn_abi` instead.
313-
let sig = self.tcx().normalize_erasing_late_bound_regions(
314-
ty::ParamEnv::reveal_all(),
315-
&instance.fn_sig(self.tcx()),
316-
);
317-
let fn_signature = get_function_signature(self, sig);
311+
let fn_signature = get_function_signature(self, fn_abi);
318312
llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(self), file_metadata, fn_signature)
319313
};
320314

@@ -396,28 +390,22 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
396390

397391
return Some(fn_debug_context);
398392

399-
// FIXME(eddyb) rewrite this to be based on `FnAbi` instead of `FnSig`.
400393
fn get_function_signature<'ll, 'tcx>(
401394
cx: &CodegenCx<'ll, 'tcx>,
402-
sig: ty::FnSig<'tcx>,
395+
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
403396
) -> &'ll DIArray {
404397
if cx.sess().opts.debuginfo == DebugInfo::Limited {
405398
return create_DIArray(DIB(cx), &[]);
406399
}
407400

408-
let mut signature = Vec::with_capacity(sig.inputs().len() + 1);
401+
let mut signature = Vec::with_capacity(fn_abi.args.len() + 1);
409402

410403
// Return type -- llvm::DIBuilder wants this at index 0
411-
signature.push(match sig.output().kind {
412-
ty::Tuple(ref tys) if tys.is_empty() => None,
413-
_ => Some(type_metadata(cx, sig.output(), syntax_pos::DUMMY_SP))
414-
});
415-
416-
let inputs = if sig.abi == Abi::RustCall {
417-
&sig.inputs()[..sig.inputs().len() - 1]
404+
signature.push(if fn_abi.ret.is_ignore() {
405+
None
418406
} else {
419-
sig.inputs()
420-
};
407+
Some(type_metadata(cx, fn_abi.ret.layout.ty, syntax_pos::DUMMY_SP))
408+
});
421409

422410
// Arguments types
423411
if cx.sess().target.target.options.is_like_msvc {
@@ -431,7 +419,8 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
431419
// and a function `fn bar(x: [(); 7])` as `fn bar(x: *const ())`.
432420
// This transformed type is wrong, but these function types are
433421
// already inaccurate due to ABI adjustments (see #42800).
434-
signature.extend(inputs.iter().map(|&t| {
422+
signature.extend(fn_abi.args.iter().map(|arg| {
423+
let t = arg.layout.ty;
435424
let t = match t.kind {
436425
ty::Array(ct, _)
437426
if (ct == cx.tcx.types.u8) || cx.layout_of(ct).is_zst() => {
@@ -442,21 +431,11 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
442431
Some(type_metadata(cx, t, syntax_pos::DUMMY_SP))
443432
}));
444433
} else {
445-
signature.extend(inputs.iter().map(|t| {
446-
Some(type_metadata(cx, t, syntax_pos::DUMMY_SP))
434+
signature.extend(fn_abi.args.iter().map(|arg| {
435+
Some(type_metadata(cx, arg.layout.ty, syntax_pos::DUMMY_SP))
447436
}));
448437
}
449438

450-
if sig.abi == Abi::RustCall && !sig.inputs().is_empty() {
451-
if let ty::Tuple(args) = sig.inputs()[sig.inputs().len() - 1].kind {
452-
signature.extend(
453-
args.iter().map(|argument_type| {
454-
Some(type_metadata(cx, argument_type.expect_ty(), syntax_pos::DUMMY_SP))
455-
})
456-
);
457-
}
458-
}
459-
460439
create_DIArray(DIB(cx), &signature[..])
461440
}
462441

0 commit comments

Comments
 (0)