Skip to content

Commit 45c6423

Browse files
debuginfo: Fix ICE when compiling for-loops with lines-tables-only.
1 parent 1c78ad9 commit 45c6423

File tree

5 files changed

+28
-32
lines changed

5 files changed

+28
-32
lines changed

src/librustc_trans/trans/_match.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -857,16 +857,9 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
857857
bcx.fcx.schedule_lifetime_end(cs, binding_info.llmatch);
858858
}
859859

860-
debug!("binding {} to {}",
861-
binding_info.id,
862-
bcx.val_to_string(llval));
860+
debug!("binding {} to {}", binding_info.id, bcx.val_to_string(llval));
863861
bcx.fcx.lllocals.borrow_mut().insert(binding_info.id, datum);
864-
865-
if bcx.sess().opts.debuginfo == FullDebugInfo {
866-
debuginfo::create_match_binding_metadata(bcx,
867-
ident,
868-
binding_info);
869-
}
862+
debuginfo::create_match_binding_metadata(bcx, ident, binding_info);
870863
}
871864
bcx
872865
}

src/librustc_trans/trans/base.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use middle::subst;
4444
use middle::weak_lang_items;
4545
use middle::subst::{Subst, Substs};
4646
use middle::ty::{self, Ty, UnboxedClosureTyper};
47-
use session::config::{self, NoDebugInfo, FullDebugInfo};
47+
use session::config::{self, NoDebugInfo};
4848
use session::Session;
4949
use trans::_match;
5050
use trans::adt;
@@ -1626,9 +1626,8 @@ fn create_datums_for_fn_args_under_call_abi<'blk, 'tcx>(
16261626
result
16271627
}
16281628

1629-
fn copy_args_to_allocas<'blk, 'tcx>(fcx: &FunctionContext<'blk, 'tcx>,
1629+
fn copy_args_to_allocas<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
16301630
arg_scope: cleanup::CustomScopeIndex,
1631-
bcx: Block<'blk, 'tcx>,
16321631
args: &[ast::Arg],
16331632
arg_datums: Vec<RvalueDatum<'tcx>>)
16341633
-> Block<'blk, 'tcx> {
@@ -1649,10 +1648,7 @@ fn copy_args_to_allocas<'blk, 'tcx>(fcx: &FunctionContext<'blk, 'tcx>,
16491648
// the event it's not truly needed.
16501649

16511650
bcx = _match::store_arg(bcx, &*args[i].pat, arg_datum, arg_scope_id);
1652-
1653-
if fcx.ccx.sess().opts.debuginfo == FullDebugInfo {
1654-
debuginfo::create_argument_metadata(bcx, &args[i]);
1655-
}
1651+
debuginfo::create_argument_metadata(bcx, &args[i]);
16561652
}
16571653

16581654
bcx
@@ -1702,9 +1698,7 @@ fn copy_unboxed_closure_args_to_allocas<'blk, 'tcx>(
17021698
tuple_element_datum,
17031699
arg_scope_id);
17041700

1705-
if bcx.fcx.ccx.sess().opts.debuginfo == FullDebugInfo {
1706-
debuginfo::create_argument_metadata(bcx, &args[j]);
1707-
}
1701+
debuginfo::create_argument_metadata(bcx, &args[j]);
17081702
}
17091703

17101704
bcx
@@ -1877,9 +1871,8 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
18771871

18781872
bcx = match closure_env.kind {
18791873
closure::NotClosure | closure::BoxedClosure(..) => {
1880-
copy_args_to_allocas(&fcx,
1874+
copy_args_to_allocas(bcx,
18811875
arg_scope,
1882-
bcx,
18831876
&decl.inputs[],
18841877
arg_datums)
18851878
}

src/librustc_trans/trans/controlflow.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use trans::type_::Type;
2828
use trans;
2929
use middle::ty;
3030
use middle::ty::MethodCall;
31-
use session::config::FullDebugInfo;
3231
use util::ppaux::Repr;
3332
use util::ppaux;
3433

@@ -66,10 +65,7 @@ pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
6665
match d.node {
6766
ast::DeclLocal(ref local) => {
6867
bcx = init_local(bcx, &**local);
69-
if cx.sess().opts.debuginfo == FullDebugInfo {
70-
trans::debuginfo::create_local_var_metadata(bcx,
71-
&**local);
72-
}
68+
debuginfo::create_local_var_metadata(bcx, &**local);
7369
}
7470
// Inner items are visited by `trans_item`/`trans_meth`.
7571
ast::DeclItem(_) => {},

src/librustc_trans/trans/debuginfo.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,9 @@ pub fn create_global_var_metadata(cx: &CrateContext,
878878
/// local in `bcx.fcx.lllocals`.
879879
/// Adds the created metadata nodes directly to the crate's IR.
880880
pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) {
881-
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
881+
if bcx.unreachable.get() ||
882+
fn_should_be_ignored(bcx.fcx) ||
883+
bcx.sess().opts.debuginfo != FullDebugInfo {
882884
return;
883885
}
884886

@@ -922,7 +924,9 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
922924
env_index: uint,
923925
captured_by_ref: bool,
924926
span: Span) {
925-
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
927+
if bcx.unreachable.get() ||
928+
fn_should_be_ignored(bcx.fcx) ||
929+
bcx.sess().opts.debuginfo != FullDebugInfo {
926930
return;
927931
}
928932

@@ -1005,7 +1009,9 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
10051009
pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
10061010
variable_ident: ast::Ident,
10071011
binding: BindingInfo<'tcx>) {
1008-
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
1012+
if bcx.unreachable.get() ||
1013+
fn_should_be_ignored(bcx.fcx) ||
1014+
bcx.sess().opts.debuginfo != FullDebugInfo {
10091015
return;
10101016
}
10111017

@@ -1045,7 +1051,9 @@ pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
10451051
/// argument in `bcx.fcx.lllocals`.
10461052
/// Adds the created metadata nodes directly to the crate's IR.
10471053
pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
1048-
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
1054+
if bcx.unreachable.get() ||
1055+
fn_should_be_ignored(bcx.fcx) ||
1056+
bcx.sess().opts.debuginfo != FullDebugInfo {
10491057
return;
10501058
}
10511059

@@ -1099,7 +1107,9 @@ pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
10991107
/// loop variable in `bcx.fcx.lllocals`.
11001108
/// Adds the created metadata nodes directly to the crate's IR.
11011109
pub fn create_for_loop_var_metadata(bcx: Block, pat: &ast::Pat) {
1102-
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
1110+
if bcx.unreachable.get() ||
1111+
fn_should_be_ignored(bcx.fcx) ||
1112+
bcx.sess().opts.debuginfo != FullDebugInfo {
11031113
return;
11041114
}
11051115

src/test/debuginfo/limited-debuginfo.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ fn zzz() {()}
4848
fn some_function(a: int, b: int) {
4949
let some_variable = Struct { a: 11, b: 22 };
5050
let some_other_variable = 23i;
51-
zzz(); // #break
51+
52+
for x in range(0, 1) {
53+
zzz(); // #break
54+
}
5255
}
5356

5457
fn some_other_function(a: int, b: int) -> bool { true }
58+

0 commit comments

Comments
 (0)