Define return type for functions in debuginfo
This commit is contained in:
parent
0634aedbb7
commit
4f0cde1e51
@ -11,7 +11,7 @@
|
||||
use rustc_monomorphize::is_call_from_compiler_builtins_to_upstream_monomorphization;
|
||||
|
||||
use crate::constant::ConstantCx;
|
||||
use crate::debuginfo::FunctionDebugContext;
|
||||
use crate::debuginfo::{FunctionDebugContext, TypeDebugContext};
|
||||
use crate::prelude::*;
|
||||
use crate::pretty_clif::CommentWriter;
|
||||
|
||||
@ -26,6 +26,7 @@ pub(crate) struct CodegenedFunction {
|
||||
pub(crate) fn codegen_fn<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
cx: &mut crate::CodegenCx,
|
||||
type_dbg: &mut TypeDebugContext<'tcx>,
|
||||
cached_func: Function,
|
||||
module: &mut dyn Module,
|
||||
instance: Instance<'tcx>,
|
||||
@ -69,8 +70,10 @@ pub(crate) fn codegen_fn<'tcx>(
|
||||
let pointer_type = target_config.pointer_type();
|
||||
let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance);
|
||||
|
||||
let fn_abi = RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty());
|
||||
|
||||
let func_debug_cx = if let Some(debug_context) = &mut cx.debug_context {
|
||||
Some(debug_context.define_function(tcx, instance, &symbol_name, mir.span))
|
||||
Some(debug_context.define_function(tcx, type_dbg, instance, fn_abi, &symbol_name, mir.span))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@ -87,7 +90,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
||||
instance,
|
||||
symbol_name,
|
||||
mir,
|
||||
fn_abi: RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty()),
|
||||
fn_abi,
|
||||
|
||||
bcx,
|
||||
block_map,
|
||||
|
@ -20,6 +20,7 @@
|
||||
use rustc_hir::def_id::DefIdMap;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::{SourceFileHash, StableSourceFileId};
|
||||
use rustc_target::abi::call::FnAbi;
|
||||
|
||||
pub(crate) use self::emit::{DebugReloc, DebugRelocName};
|
||||
pub(crate) use self::types::TypeDebugContext;
|
||||
@ -188,7 +189,9 @@ fn item_namespace(&mut self, tcx: TyCtxt<'_>, def_id: DefId) -> UnitEntryId {
|
||||
pub(crate) fn define_function<'tcx>(
|
||||
&mut self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
type_dbg: &mut TypeDebugContext<'tcx>,
|
||||
instance: Instance<'tcx>,
|
||||
fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
|
||||
linkage_name: &str,
|
||||
function_span: Span,
|
||||
) -> FunctionDebugContext {
|
||||
@ -240,7 +243,14 @@ pub(crate) fn define_function<'tcx>(
|
||||
entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(Some(file_id)));
|
||||
entry.set(gimli::DW_AT_decl_line, AttributeValue::Udata(line));
|
||||
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
let return_dw_ty = self.debug_type(tcx, type_dbg, fn_abi.ret.layout.ty);
|
||||
let entry = self.dwarf.unit.get_mut(entry_id);
|
||||
entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(return_dw_ty));
|
||||
}
|
||||
|
||||
if tcx.is_reachable_non_generic(instance.def_id()) {
|
||||
let entry = self.dwarf.unit.get_mut(entry_id);
|
||||
entry.set(gimli::DW_AT_external, AttributeValue::FlagPresent);
|
||||
}
|
||||
|
||||
|
@ -470,6 +470,7 @@ fn module_codegen(
|
||||
let codegened_function = crate::base::codegen_fn(
|
||||
tcx,
|
||||
&mut cx,
|
||||
&mut type_dbg,
|
||||
Function::new(),
|
||||
&mut module,
|
||||
inst,
|
||||
|
@ -12,6 +12,7 @@
|
||||
use rustc_session::Session;
|
||||
use rustc_span::Symbol;
|
||||
|
||||
use crate::debuginfo::TypeDebugContext;
|
||||
use crate::{prelude::*, BackendConfig};
|
||||
use crate::{CodegenCx, CodegenMode};
|
||||
|
||||
@ -229,7 +230,14 @@ pub(crate) fn codegen_and_compile_fn<'tcx>(
|
||||
crate::PrintOnPanic(|| format!("{:?} {}", instance, tcx.symbol_name(instance).name));
|
||||
|
||||
let cached_func = std::mem::replace(&mut cached_context.func, Function::new());
|
||||
let codegened_func = crate::base::codegen_fn(tcx, cx, cached_func, module, instance);
|
||||
let codegened_func = crate::base::codegen_fn(
|
||||
tcx,
|
||||
cx,
|
||||
&mut TypeDebugContext::default(),
|
||||
cached_func,
|
||||
module,
|
||||
instance,
|
||||
);
|
||||
|
||||
crate::base::compile_fn(cx, cached_context, module, codegened_func);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user