From 5d1c1f55d54adb95d9fa3bdfa28170d87c830d9c Mon Sep 17 00:00:00 2001
From: ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 13 Nov 2013 12:15:47 +0000
Subject: 	* cfgexpand.c (expand_used_vars): Allocate space for
 partitions based 	on PARM_DECLs or RESULT_DECLs only if they are ignored
 for debug info 	or if optimization is enabled. 	* tree-ssa-coalesce.c
 (coalesce_ssa_name): If optimization is disabled, 	require that all the
 names based on a PARM_DECL or a RESULT_DECL that 	isn't ignored for
 debug info be coalesced.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204742 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/tree-ssa-coalesce.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

(limited to 'gcc/tree-ssa-coalesce.c')

diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
index c445c78626e..252fc33a7f0 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -1256,8 +1256,8 @@ coalesce_ssa_name (void)
   cl = create_coalesce_list ();
   map = create_outofssa_var_map (cl, used_in_copies);
 
-  /* We need to coalesce all names originating same SSA_NAME_VAR
-     so debug info remains undisturbed.  */
+  /* If optimization is disabled, we need to coalesce all the names originating
+     from the same SSA_NAME_VAR so debug info remains undisturbed.  */
   if (!optimize)
     {
       hash_table <ssa_name_var_hash> ssa_name_hash;
@@ -1278,8 +1278,16 @@ coalesce_ssa_name (void)
 		*slot = a;
 	      else
 		{
-		  add_coalesce (cl, SSA_NAME_VERSION (a), SSA_NAME_VERSION (*slot),
-				MUST_COALESCE_COST - 1);
+		  /* If the variable is a PARM_DECL or a RESULT_DECL, we
+		     _require_ that all the names originating from it be
+		     coalesced, because there must be a single partition
+		     containing all the names so that it can be assigned
+		     the canonical RTL location of the DECL safely.  */
+		  const int cost
+		    = TREE_CODE (SSA_NAME_VAR (a)) == VAR_DECL
+		      ? MUST_COALESCE_COST - 1 : MUST_COALESCE_COST;
+		  add_coalesce (cl, SSA_NAME_VERSION (a),
+				SSA_NAME_VERSION (*slot), cost);
 		  bitmap_set_bit (used_in_copies, SSA_NAME_VERSION (a));
 		  bitmap_set_bit (used_in_copies, SSA_NAME_VERSION (*slot));
 		}
-- 
cgit v1.2.1