diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2016-05-26 03:13:32 +0300 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2016-05-26 03:25:23 +0300 |
| commit | 0d2a84c97db7969e69fd58354fea7643bde7297f (patch) | |
| tree | 9aaba6e4c8faa78c14f2342f513ea66f0ae1f929 | |
| parent | b9d014b73adc34c9c19c0f6a5ae13998e46fbb6e (diff) | |
| download | rust-0d2a84c97db7969e69fd58354fea7643bde7297f.tar.gz rust-0d2a84c97db7969e69fd58354fea7643bde7297f.zip | |
Fix the fix/hack interaction with debuginfo
| -rw-r--r-- | src/librustc_trans/base.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 5a9b4e109a5..f190015d024 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -1721,16 +1721,19 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> { }; let pat = &hir_arg.pat; - bcx = if let Some(name) = simple_name(pat) { - // Generate nicer LLVM for the common case of fn a pattern - // like `x: T` - set_value_name(arg_datum.val, &bcx.name(name)); - self.lllocals.borrow_mut().insert(pat.id, arg_datum); - bcx - } else { - // General path. Copy out the values that are used in the - // pattern. - _match::bind_irrefutable_pat(bcx, pat, arg_datum.match_input(), arg_scope_id) + bcx = match simple_name(pat) { + // The check for alloca is necessary because above for the immediate argument case + // we had to cast. At this point arg_datum is not an alloca anymore and thus + // breaks debuginfo if we allow this optimisation. + Some(name) + if unsafe { llvm::LLVMIsAAllocaInst(arg_datum.val) != ::std::ptr::null_mut() } => { + // Generate nicer LLVM for the common case of fn a pattern + // like `x: T` + set_value_name(arg_datum.val, &bcx.name(name)); + self.lllocals.borrow_mut().insert(pat.id, arg_datum); + bcx + }, + _ => _match::bind_irrefutable_pat(bcx, pat, arg_datum.match_input(), arg_scope_id) }; debuginfo::create_argument_metadata(bcx, hir_arg); } |
