Skip to content

Commit f89cfb2

Browse files
committed
---
yaml --- r: 85715 b: refs/heads/dist-snap c: f8c4f0e h: refs/heads/master i: 85713: 602dc0b 85711: d13cdcf v: v3
1 parent b02eca1 commit f89cfb2

File tree

4 files changed

+192
-137
lines changed

4 files changed

+192
-137
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 0983ebe5310d4eb6d289f636f7ed0536c08bbc0e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 943f9aaa4a0302cee1b28c2fec3f23fc1c43fd61
9+
refs/heads/dist-snap: f8c4f0ea9c96218dbc81081799e77875fbb071de
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/trans/base.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ fn fcx_has_nonzero_span(fcx: &FunctionContext) -> bool {
137137
}
138138
}
139139

140+
fn span_is_empty(opt_span: &Option<span>) -> bool {
141+
match *opt_span {
142+
None => true,
143+
Some(span) => *span.lo == 0 && *span.hi == 0
144+
}
145+
}
146+
140147
struct StatRecorder<'self> {
141148
ccx: @mut CrateContext,
142149
name: &'self str,
@@ -1624,6 +1631,13 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
16241631
}
16251632
};
16261633
let uses_outptr = type_of::return_uses_outptr(ccx.tcx, substd_output_type);
1634+
1635+
let debug_context = if id != -1 && ccx.sess.opts.debuginfo && !span_is_empty(&sp) {
1636+
Some(debuginfo::create_function_debug_context(ccx, id, param_substs, llfndecl))
1637+
} else {
1638+
None
1639+
};
1640+
16271641
let fcx = @mut FunctionContext {
16281642
llfn: llfndecl,
16291643
llenv: unsafe {
@@ -1644,7 +1658,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
16441658
span: sp,
16451659
path: path,
16461660
ccx: ccx,
1647-
debug_context: None,
1661+
debug_context: debug_context,
16481662
};
16491663
fcx.llenv = unsafe {
16501664
llvm::LLVMGetParam(llfndecl, fcx.env_arg_pos() as c_uint)
@@ -1877,6 +1891,7 @@ pub fn trans_closure(ccx: @mut CrateContext,
18771891
param_substs,
18781892
body.info(),
18791893
Some(body.span));
1894+
18801895
let raw_llargs = create_llargs_for_fn_args(fcx, self_arg, decl.inputs);
18811896

18821897
// Set the fixed stack segment flag if necessary.
@@ -1885,10 +1900,6 @@ pub fn trans_closure(ccx: @mut CrateContext,
18851900
set_fixed_stack_segment(fcx.llfn);
18861901
}
18871902

1888-
if ccx.sess.opts.debuginfo && fcx_has_nonzero_span(fcx) {
1889-
debuginfo::create_function_metadata(fcx);
1890-
}
1891-
18921903
// Create the first basic block in the function and keep a handle on it to
18931904
// pass to finish_fn later.
18941905
let bcx_top = fcx.entry_bcx.unwrap();
@@ -1900,6 +1911,11 @@ pub fn trans_closure(ccx: @mut CrateContext,
19001911

19011912
maybe_load_env(fcx);
19021913

1914+
// Up until here, IR instructions for this function have explicitly not been annotated with
1915+
// source code location, so we don't step into call setup code. From here on, source location
1916+
// emitting should be enabled.
1917+
debuginfo::start_emitting_source_locations(fcx);
1918+
19031919
// This call to trans_block is the place where we bridge between
19041920
// translation calls that don't have a return value (trans_crate,
19051921
// trans_mod, trans_item, et cetera) and those that do

0 commit comments

Comments
 (0)