Skip to content
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

debuginfo: Support for generic functions and self arguments #8554

Closed
wants to merge 12 commits into from
Closed
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
8 changes: 8 additions & 0 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,14 @@ pub fn build_session_options(binary: @str,
let extra_debuginfo = debugging_opts & session::extra_debug_info != 0;
let debuginfo = debugging_opts & session::debug_info != 0 ||
extra_debuginfo;

// If debugging info is generated, do not collapse monomorphized function instances.
// Functions with equivalent llvm code still need separate debugging descriptions because names
// might differ.
if debuginfo {
debugging_opts |= session::no_monomorphic_collapse;
}

let statik = debugging_opts & session::statik != 0;

let addl_lib_search_paths = getopts::opt_strs(matches, "L").map(|s| Path(*s));
Expand Down
10 changes: 10 additions & 0 deletions src/librustc/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,16 @@ pub mod llvm {

#[fast_ffi]
pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);

#[fast_ffi]
pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
Scope: ValueRef,
Name: *c_char,
Ty: ValueRef,
File: ValueRef,
LineNo: c_uint,
ColumnNo: c_uint)
-> ValueRef;
}
}

Expand Down
17 changes: 10 additions & 7 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt {

fn fcx_has_nonzero_span(fcx: &FunctionContext) -> bool {
match fcx.span {
None => true,
None => false,
Some(span) => *span.lo != 0 || *span.hi != 0
}
}
Expand Down Expand Up @@ -1739,6 +1739,10 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext,

fcx.llself = Some(ValSelfData {v: self_val, ..slf});
add_clean(bcx, self_val, slf.t);

if fcx.ccx.sess.opts.extra_debuginfo && fcx_has_nonzero_span(fcx) {
debuginfo::create_self_argument_metadata(bcx, slf.t, self_val);
}
}
_ => {}
}
Expand Down Expand Up @@ -1859,6 +1863,10 @@ pub fn trans_closure(ccx: @mut CrateContext,
set_fixed_stack_segment(fcx.llfn);
}

if ccx.sess.opts.debuginfo && fcx_has_nonzero_span(fcx) {
debuginfo::create_function_metadata(fcx);
}

// Create the first basic block in the function and keep a handle on it to
// pass to finish_fn later.
let bcx_top = fcx.entry_bcx.unwrap();
Expand Down Expand Up @@ -1929,12 +1937,7 @@ pub fn trans_fn(ccx: @mut CrateContext,
id,
attrs,
output_type,
|fcx| {
if ccx.sess.opts.debuginfo
&& fcx_has_nonzero_span(fcx) {
debuginfo::create_function_metadata(fcx);
}
});
|_fcx| { });
}

fn insert_synthetic_type_entries(bcx: @mut Block,
Expand Down
Loading