Skip to content

Commit 2d49342

Browse files
michaelwoeristerbrson
authored andcommitted
debuginfo: Create debuginfo for re-aggregated spread_arg instead of for the individual pieces.
1 parent f6859b0 commit 2d49342

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

Diff for: src/librustc_trans/mir/mod.rs

+13-22
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use machine;
2222
use type_of;
2323

2424
use syntax_pos::DUMMY_SP;
25-
use syntax::parse::token::keywords;
2625

2726
use std::ops::Deref;
2827
use std::rc::Rc;
@@ -301,7 +300,6 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
301300
_ => bug!("spread argument isn't a tuple?!")
302301
};
303302

304-
let lltuplety = type_of::type_of(bcx.ccx(), arg_ty);
305303
let lltemp = bcx.with_block(|bcx| {
306304
base::alloc_ty(bcx, arg_ty, &format!("arg{}", arg_index))
307305
});
@@ -319,27 +317,20 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
319317
} else {
320318
arg.store_fn_arg(bcx, &mut llarg_idx, dst);
321319
}
322-
323-
bcx.with_block(|bcx| arg_scope.map(|scope| {
324-
let byte_offset_of_var_in_tuple =
325-
machine::llelement_offset(bcx.ccx(), lltuplety, i);
326-
327-
let ops = unsafe {
328-
[llvm::LLVMRustDIBuilderCreateOpDeref(),
329-
llvm::LLVMRustDIBuilderCreateOpPlus(),
330-
byte_offset_of_var_in_tuple as i64]
331-
};
332-
333-
let variable_access = VariableAccess::IndirectVariable {
334-
alloca: lltemp,
335-
address_operations: &ops
336-
};
337-
declare_local(bcx, keywords::Invalid.name(),
338-
tupled_arg_ty, scope, variable_access,
339-
VariableKind::ArgumentVariable(arg_index + i + 1),
340-
bcx.fcx().span.unwrap_or(DUMMY_SP));
341-
}));
342320
}
321+
322+
// Now that we have one alloca that contains the aggregate value,
323+
// we can create one debuginfo entry for the argument.
324+
bcx.with_block(|bcx| arg_scope.map(|scope| {
325+
let variable_access = VariableAccess::DirectVariable {
326+
alloca: lltemp
327+
};
328+
declare_local(bcx, arg_decl.debug_name,
329+
arg_ty, scope, variable_access,
330+
VariableKind::ArgumentVariable(arg_index + 1),
331+
bcx.fcx().span.unwrap_or(DUMMY_SP));
332+
}));
333+
343334
return LocalRef::Lvalue(LvalueRef::new_sized(lltemp, LvalueTy::from_ty(arg_ty)));
344335
}
345336

0 commit comments

Comments
 (0)