Skip to content

Commit 0d2a84c

Browse files
committed
Fix the fix/hack interaction with debuginfo
1 parent b9d014b commit 0d2a84c

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/librustc_trans/base.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,16 +1721,19 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
17211721
};
17221722

17231723
let pat = &hir_arg.pat;
1724-
bcx = if let Some(name) = simple_name(pat) {
1725-
// Generate nicer LLVM for the common case of fn a pattern
1726-
// like `x: T`
1727-
set_value_name(arg_datum.val, &bcx.name(name));
1728-
self.lllocals.borrow_mut().insert(pat.id, arg_datum);
1729-
bcx
1730-
} else {
1731-
// General path. Copy out the values that are used in the
1732-
// pattern.
1733-
_match::bind_irrefutable_pat(bcx, pat, arg_datum.match_input(), arg_scope_id)
1724+
bcx = match simple_name(pat) {
1725+
// The check for alloca is necessary because above for the immediate argument case
1726+
// we had to cast. At this point arg_datum is not an alloca anymore and thus
1727+
// breaks debuginfo if we allow this optimisation.
1728+
Some(name)
1729+
if unsafe { llvm::LLVMIsAAllocaInst(arg_datum.val) != ::std::ptr::null_mut() } => {
1730+
// Generate nicer LLVM for the common case of fn a pattern
1731+
// like `x: T`
1732+
set_value_name(arg_datum.val, &bcx.name(name));
1733+
self.lllocals.borrow_mut().insert(pat.id, arg_datum);
1734+
bcx
1735+
},
1736+
_ => _match::bind_irrefutable_pat(bcx, pat, arg_datum.match_input(), arg_scope_id)
17341737
};
17351738
debuginfo::create_argument_metadata(bcx, hir_arg);
17361739
}

0 commit comments

Comments
 (0)