Skip to content

Commit

Permalink
debuginfo: Fix ICE when compiling for-loops with lines-tables-only.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Jan 15, 2015
1 parent 1c78ad9 commit 45c6423
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 32 deletions.
11 changes: 2 additions & 9 deletions src/librustc_trans/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,16 +857,9 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
bcx.fcx.schedule_lifetime_end(cs, binding_info.llmatch);
}

debug!("binding {} to {}",
binding_info.id,
bcx.val_to_string(llval));
debug!("binding {} to {}", binding_info.id, bcx.val_to_string(llval));
bcx.fcx.lllocals.borrow_mut().insert(binding_info.id, datum);

if bcx.sess().opts.debuginfo == FullDebugInfo {
debuginfo::create_match_binding_metadata(bcx,
ident,
binding_info);
}
debuginfo::create_match_binding_metadata(bcx, ident, binding_info);
}
bcx
}
Expand Down
17 changes: 5 additions & 12 deletions src/librustc_trans/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use middle::subst;
use middle::weak_lang_items;
use middle::subst::{Subst, Substs};
use middle::ty::{self, Ty, UnboxedClosureTyper};
use session::config::{self, NoDebugInfo, FullDebugInfo};
use session::config::{self, NoDebugInfo};
use session::Session;
use trans::_match;
use trans::adt;
Expand Down Expand Up @@ -1626,9 +1626,8 @@ fn create_datums_for_fn_args_under_call_abi<'blk, 'tcx>(
result
}

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

bcx = _match::store_arg(bcx, &*args[i].pat, arg_datum, arg_scope_id);

if fcx.ccx.sess().opts.debuginfo == FullDebugInfo {
debuginfo::create_argument_metadata(bcx, &args[i]);
}
debuginfo::create_argument_metadata(bcx, &args[i]);
}

bcx
Expand Down Expand Up @@ -1702,9 +1698,7 @@ fn copy_unboxed_closure_args_to_allocas<'blk, 'tcx>(
tuple_element_datum,
arg_scope_id);

if bcx.fcx.ccx.sess().opts.debuginfo == FullDebugInfo {
debuginfo::create_argument_metadata(bcx, &args[j]);
}
debuginfo::create_argument_metadata(bcx, &args[j]);
}

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

bcx = match closure_env.kind {
closure::NotClosure | closure::BoxedClosure(..) => {
copy_args_to_allocas(&fcx,
copy_args_to_allocas(bcx,
arg_scope,
bcx,
&decl.inputs[],
arg_datums)
}
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_trans/trans/controlflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use trans::type_::Type;
use trans;
use middle::ty;
use middle::ty::MethodCall;
use session::config::FullDebugInfo;
use util::ppaux::Repr;
use util::ppaux;

Expand Down Expand Up @@ -66,10 +65,7 @@ pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
match d.node {
ast::DeclLocal(ref local) => {
bcx = init_local(bcx, &**local);
if cx.sess().opts.debuginfo == FullDebugInfo {
trans::debuginfo::create_local_var_metadata(bcx,
&**local);
}
debuginfo::create_local_var_metadata(bcx, &**local);
}
// Inner items are visited by `trans_item`/`trans_meth`.
ast::DeclItem(_) => {},
Expand Down
20 changes: 15 additions & 5 deletions src/librustc_trans/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,9 @@ pub fn create_global_var_metadata(cx: &CrateContext,
/// local in `bcx.fcx.lllocals`.
/// Adds the created metadata nodes directly to the crate's IR.
pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) {
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
if bcx.unreachable.get() ||
fn_should_be_ignored(bcx.fcx) ||
bcx.sess().opts.debuginfo != FullDebugInfo {
return;
}

Expand Down Expand Up @@ -922,7 +924,9 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
env_index: uint,
captured_by_ref: bool,
span: Span) {
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
if bcx.unreachable.get() ||
fn_should_be_ignored(bcx.fcx) ||
bcx.sess().opts.debuginfo != FullDebugInfo {
return;
}

Expand Down Expand Up @@ -1005,7 +1009,9 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
variable_ident: ast::Ident,
binding: BindingInfo<'tcx>) {
if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
if bcx.unreachable.get() ||
fn_should_be_ignored(bcx.fcx) ||
bcx.sess().opts.debuginfo != FullDebugInfo {
return;
}

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

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

Expand Down
6 changes: 5 additions & 1 deletion src/test/debuginfo/limited-debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ fn zzz() {()}
fn some_function(a: int, b: int) {
let some_variable = Struct { a: 11, b: 22 };
let some_other_variable = 23i;
zzz(); // #break

for x in range(0, 1) {
zzz(); // #break
}
}

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

0 comments on commit 45c6423

Please sign in to comment.