summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSimonas Kazlauskas <git@kazlauskas.me>2016-05-26 03:13:32 +0300
committerAlex Crichton <alex@alexcrichton.com>2016-05-26 09:49:20 -0700
commit11c30fa3aa56e90c62fbb1c7ac9eba2a49d12ff5 (patch)
treeae20bb4c2d08eda07f91013bb480e8f6f86b686c /src
parentc612b8358ce751a3a70ef01c42bcbfa35a9150c0 (diff)
downloadrust-11c30fa3aa56e90c62fbb1c7ac9eba2a49d12ff5.tar.gz
rust-11c30fa3aa56e90c62fbb1c7ac9eba2a49d12ff5.zip
Fix the fix/hack interaction with debuginfo
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/base.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs
index de89973d7ed..10585e5d112 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);
         }