[backport from gcc-4.8/trunk r188998 <mikpe@it.uu.se>]

From: Alexandre Oliva <aoliva at redhat dot com>
Subject: Re: [PR49888, VTA] don't keep VALUEs bound to modified MEMs
Date: Thu, 21 Jun 2012 22:58:05 -0300
List-Archive: <http://gcc.gnu.org/ml/gcc-patches/>

Here's one more patch that addresses a problem I found out while
investigating the PR53671 regressions: rather than recording incoming
stack args as MEMs with non-VALUE expressions, it's more consistent (and
less surprising) if we emit them as VALUE expressions, like other MEMs.

Regstrapped on x86_64-linux-gnu and i686-linux-gnu.  Ok?

gcc/

2012-06-26  Alexandre Oliva  <aoliva@redhat.com>

	* var-tracking.c (vt_add_function_parameter): Use a preserved
	VALUE for the MEM address of an incoming parameter.

--- gcc-4.7.1/gcc/var-tracking.c.~1~	2012-08-12 13:17:14.000000000 +0200
+++ gcc-4.7.1/gcc/var-tracking.c	2012-08-12 13:22:52.000000000 +0200
@@ -9416,6 +9416,17 @@ vt_add_function_parameter (tree parm)
 			     VAR_INIT_STATUS_INITIALIZED, NULL, INSERT);
 	  dv = dv_from_value (val->val_rtx);
 	}
+
+      if (MEM_P (incoming))
+	{
+	  val = cselib_lookup_from_insn (XEXP (incoming, 0), mode, true,
+					 VOIDmode, get_insns ());
+	  if (val)
+	    {
+	      preserve_value (val);
+	      incoming = replace_equiv_address_nv (incoming, val->val_rtx);
+	    }
+	}
     }
 
   if (REG_P (incoming))
