Skip to content

Debuginfo locals #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
let mut debug_context = cx
.debug_context
.as_mut()
.map(|debug_context| FunctionDebugContext::new(tcx, debug_context, mir, func_id, &name, &sig));
.map(|debug_context| FunctionDebugContext::new(debug_context, instance, func_id, &name));

// Make FunctionBuilder
let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig);
func.collect_debug_info();
let mut func_ctx = FunctionBuilderContext::new();
let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx);

Expand Down Expand Up @@ -60,6 +61,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
let instance = fx.instance;
let clif_comments = fx.clif_comments;
let source_info_set = fx.source_info_set;
let local_map = fx.local_map;

#[cfg(debug_assertions)]
crate::pretty_clif::write_clif_file(cx.tcx, "unopt", instance, &func, &clif_comments, None);
Expand All @@ -72,26 +74,28 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
context.func = func;
cx.module.define_function(func_id, context).unwrap();

let value_ranges = context
.build_value_labels_ranges(cx.module.isa())
.expect("value location ranges");

// Write optimized function to file for debugging
#[cfg(debug_assertions)]
crate::pretty_clif::write_clif_file(
cx.tcx,
"opt",
instance,
&context.func,
&clif_comments,
Some(&value_ranges),
);
{
let value_ranges = context
.build_value_labels_ranges(cx.module.isa())
.expect("value location ranges");

crate::pretty_clif::write_clif_file(
cx.tcx,
"opt",
instance,
&context.func,
&clif_comments,
Some(&value_ranges),
);
}

// Define debuginfo for function
let isa = cx.module.isa();
debug_context
.as_mut()
.map(|x| x.define(tcx, context, isa, &source_info_set));
.map(|x| x.define(context, isa, &source_info_set, local_map));

// Clear context to make it usable for the next function
context.clear();
Expand Down
Loading