From 45e472aa4bdcec7a5bfd8cdaa10dd00435242162 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Fri, 13 Dec 2013 13:19:11 +0100 Subject: [PATCH] debuginfo: Get rid of redundant argument copying with debuginfo activated --- src/librustc/middle/trans/_match.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 091614b6bc74..745c9a2a29a7 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -220,6 +220,7 @@ use util::common::indenter; use util::ppaux::{Repr, vec_map_to_str}; use std::hashmap::HashMap; +use std::ptr; use std::vec; use syntax::ast; use syntax::ast::Ident; @@ -2046,7 +2047,10 @@ pub fn store_arg(mut bcx: @mut Block, // Debug information (the llvm.dbg.declare intrinsic to be precise) always expects to get an // alloca, which only is the case on the general path, so lets disable the optimized path when // debug info is enabled. - let fast_path = !bcx.ccx().sess.opts.extra_debuginfo && simple_identifier(pat).is_some(); + let arg_is_alloca = unsafe { llvm::LLVMIsAAllocaInst(llval) != ptr::null() }; + + let fast_path = (arg_is_alloca || !bcx.ccx().sess.opts.extra_debuginfo) + && simple_identifier(pat).is_some(); if fast_path { // Optimized path for `x: T` case. This just adopts