From 839b422f0838f87583907b8146e9fc7ad111cad0 Mon Sep 17 00:00:00 2001
From: Richard Biener <rguenther@suse.de>
Date: Thu, 21 Mar 2013 11:53:39 +0000
Subject: [PATCH] tree.h (DECL_DEBUG_EXPR_IS_FROM): Rename to ...

2013-03-21  Richard Biener  <rguenther@suse.de>

	* tree.h (DECL_DEBUG_EXPR_IS_FROM): Rename to ...
	(DECL_HAS_DEBUG_EXPR_P): ... this.  Guard properly.
	* tree.c (copy_node_stat): Do not copy DECL_HAS_DEBUG_EXPR_P.
	* dwarf2out.c (add_var_loc_to_decl): Use DECL_HAS_DEBUG_EXPR_P
	instead of DECL_DEBUG_EXPR_IS_FROM.
	* gimplify.c (gimplify_modify_expr): Likewise.
	* tree-cfg.c (verify_expr_location_1): Likewise.
	* tree-complex.c (create_one_component_var): Likewise.
	* tree-sra.c (create_access_replacement): Likewise.
	* tree-ssa-live.c (clear_unused_block_pointer_1): Likewise.
	(clear_unused_block_pointer): Likewise.
	* tree-streamer-in.c (unpack_ts_decl_common_value_fields): Likewise.
	* tree-streamer-out.c (pack_ts_decl_common_value_fields): Likewise.
	* var-tracking.c (var_debug_decl): Likewise.
	(track_expr_p): Likewise.
	* tree-inline.c (add_local_variables): Likewise.  Set
	DECL_HAS_DEBUG_EXPR_P after copying it.
	* tree-diagnostic.c (default_tree_printer): Use DECL_HAS_DEBUG_EXPR_P
	instead of DECL_DEBUG_EXPR_IS_FROM.  Guard properly.

	c/
	* c-objc-common.c (c_tree_printer): Use DECL_HAS_DEBUG_EXPR_P
	instead of DECL_DEBUG_EXPR_IS_FROM.  Guard properly.

	cp/
	* error.c (cp_printer): Use DECL_HAS_DEBUG_EXPR_P instead of
	DECL_DEBUG_EXPR_IS_FROM.  Guard properly.

From-SVN: r196864
---
 gcc/ChangeLog           | 22 ++++++++++++++++++++++
 gcc/c/ChangeLog         |  5 +++++
 gcc/c/c-objc-common.c   |  2 +-
 gcc/cp/ChangeLog        |  5 +++++
 gcc/cp/error.c          |  4 ++--
 gcc/dwarf2out.c         | 10 +++++-----
 gcc/gimplify.c          |  2 +-
 gcc/tree-cfg.c          |  2 +-
 gcc/tree-complex.c      |  2 +-
 gcc/tree-diagnostic.c   |  2 +-
 gcc/tree-inline.c       |  3 ++-
 gcc/tree-sra.c          |  2 +-
 gcc/tree-ssa-live.c     |  4 ++--
 gcc/tree-streamer-in.c  |  6 ++++--
 gcc/tree-streamer-out.c |  6 ++++--
 gcc/tree.c              |  3 +++
 gcc/tree.h              |  8 +++-----
 gcc/var-tracking.c      | 12 +++++-------
 18 files changed, 68 insertions(+), 32 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bdbe7671a778..499e9d30fb77 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,25 @@
+2013-03-21  Richard Biener  <rguenther@suse.de>
+
+	* tree.h (DECL_DEBUG_EXPR_IS_FROM): Rename to ...
+	(DECL_HAS_DEBUG_EXPR_P): ... this.  Guard properly.
+	* tree.c (copy_node_stat): Do not copy DECL_HAS_DEBUG_EXPR_P.
+	* dwarf2out.c (add_var_loc_to_decl): Use DECL_HAS_DEBUG_EXPR_P
+	instead of DECL_DEBUG_EXPR_IS_FROM.
+	* gimplify.c (gimplify_modify_expr): Likewise.
+	* tree-cfg.c (verify_expr_location_1): Likewise.
+	* tree-complex.c (create_one_component_var): Likewise.
+	* tree-sra.c (create_access_replacement): Likewise.
+	* tree-ssa-live.c (clear_unused_block_pointer_1): Likewise.
+	(clear_unused_block_pointer): Likewise.
+	* tree-streamer-in.c (unpack_ts_decl_common_value_fields): Likewise.
+	* tree-streamer-out.c (pack_ts_decl_common_value_fields): Likewise.
+	* var-tracking.c (var_debug_decl): Likewise.
+	(track_expr_p): Likewise.
+	* tree-inline.c (add_local_variables): Likewise.  Set
+	DECL_HAS_DEBUG_EXPR_P after copying it.
+	* tree-diagnostic.c (default_tree_printer): Use DECL_HAS_DEBUG_EXPR_P
+	instead of DECL_DEBUG_EXPR_IS_FROM.  Guard properly.
+
 2013-03-21  Uros Bizjak  <ubizjak@gmail.com>
 
 	PR bootstrap/56656
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 4c8e455e9d27..a76fb3e88621 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-21  Richard Biener  <rguenther@suse.de>
+
+	* c-objc-common.c (c_tree_printer): Use DECL_HAS_DEBUG_EXPR_P
+	instead of DECL_DEBUG_EXPR_IS_FROM.  Guard properly.
+
 2013-02-12  Marek Polacek  <polacek@redhat.com>
 
 	PR c/44938
diff --git a/gcc/c/c-objc-common.c b/gcc/c/c-objc-common.c
index 6020c028da40..8e73856ac188 100644
--- a/gcc/c/c-objc-common.c
+++ b/gcc/c/c-objc-common.c
@@ -112,7 +112,7 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
   switch (*spec)
     {
     case 'D':
-      if (DECL_DEBUG_EXPR_IS_FROM (t) && DECL_DEBUG_EXPR (t))
+      if (TREE_CODE (t) == VAR_DECL && DECL_HAS_DEBUG_EXPR_P (t))
 	{
 	  t = DECL_DEBUG_EXPR (t);
 	  if (!DECL_P (t))
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 704583802e58..89a828f4ad29 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-21  Richard Biener  <rguenther@suse.de>
+
+	* error.c (cp_printer): Use DECL_HAS_DEBUG_EXPR_P instead of
+	DECL_DEBUG_EXPR_IS_FROM.  Guard properly.
+
 2013-03-20  Jason Merrill  <jason@redhat.com>
 
 	PR c++/56646
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index c3dce1dd5b3f..bcb0274c1b61 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -3283,8 +3283,8 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec,
     case 'D':
       {
 	tree temp = next_tree;
-	if (DECL_P (temp)
-	    && DECL_DEBUG_EXPR_IS_FROM (temp) && DECL_DEBUG_EXPR (temp))
+	if (TREE_CODE (temp) == VAR_DECL
+	    && DECL_HAS_DEBUG_EXPR_P (temp))
 	  {
 	    temp = DECL_DEBUG_EXPR (temp);
 	    if (!DECL_P (temp))
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 51e57378dad7..a5d5dc408a23 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -5020,13 +5020,13 @@ add_var_loc_to_decl (tree decl, rtx loc_note, const char *label)
   struct var_loc_node *loc = NULL;
   HOST_WIDE_INT bitsize = -1, bitpos = -1;
 
-  if (DECL_DEBUG_EXPR_IS_FROM (decl))
+  if (TREE_CODE (decl) == VAR_DECL
+      && DECL_HAS_DEBUG_EXPR_P (decl))
     {
       tree realdecl = DECL_DEBUG_EXPR (decl);
-      if (realdecl
-	  && (handled_component_p (realdecl)
-	      || (TREE_CODE (realdecl) == MEM_REF
-		  && TREE_CODE (TREE_OPERAND (realdecl, 0)) == ADDR_EXPR)))
+      if (handled_component_p (realdecl)
+	  || (TREE_CODE (realdecl) == MEM_REF
+	      && TREE_CODE (TREE_OPERAND (realdecl, 0)) == ADDR_EXPR))
 	{
 	  HOST_WIDE_INT maxsize;
 	  tree innerdecl;
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index e7119283ff37..a6a6565ce04f 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4947,7 +4947,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
       if (!DECL_NAME (*from_p) && DECL_NAME (*to_p))
 	DECL_NAME (*from_p)
 	  = create_tmp_var_name (IDENTIFIER_POINTER (DECL_NAME (*to_p)));
-      DECL_DEBUG_EXPR_IS_FROM (*from_p) = 1;
+      DECL_HAS_DEBUG_EXPR_P (*from_p) = 1;
       SET_DECL_DEBUG_EXPR (*from_p, *to_p);
    }
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 5466e8b43a1f..6e6b2c5525d7 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4524,7 +4524,7 @@ verify_expr_location_1 (tree *tp, int *walk_subtrees, void *data)
   struct pointer_set_t *blocks = (struct pointer_set_t *) data;
 
   if (TREE_CODE (*tp) == VAR_DECL
-      && DECL_DEBUG_EXPR_IS_FROM (*tp))
+      && DECL_HAS_DEBUG_EXPR_P (*tp))
     {
       tree t = DECL_DEBUG_EXPR (*tp);
       tree addr = walk_tree (&t, verify_expr_location_1, blocks, NULL);
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 2745d751d740..f8dbe0a8519d 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -428,7 +428,7 @@ create_one_component_var (tree type, tree orig, const char *prefix,
       DECL_NAME (r) = get_identifier (ACONCAT ((name, suffix, NULL)));
 
       SET_DECL_DEBUG_EXPR (r, build1 (code, type, orig));
-      DECL_DEBUG_EXPR_IS_FROM (r) = 1;
+      DECL_HAS_DEBUG_EXPR_P (r) = 1;
       DECL_IGNORED_P (r) = 0;
       TREE_NO_WARNING (r) = TREE_NO_WARNING (orig);
     }
diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c
index 08866a46f178..087cf6acb715 100644
--- a/gcc/tree-diagnostic.c
+++ b/gcc/tree-diagnostic.c
@@ -268,7 +268,7 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
 
     case 'D':
       t = va_arg (*text->args_ptr, tree);
-      if (DECL_DEBUG_EXPR_IS_FROM (t) && DECL_DEBUG_EXPR (t))
+      if (TREE_CODE (t) == VAR_DECL && DECL_HAS_DEBUG_EXPR_P (t))
 	t = DECL_DEBUG_EXPR (t);
       break;
 
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index b7f76c839f35..a41dd5aeb825 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -3762,7 +3762,7 @@ add_local_variables (struct function *callee, struct function *caller,
 
         /* Remap debug-expressions.  */
 	if (TREE_CODE (new_var) == VAR_DECL
-	    && DECL_DEBUG_EXPR_IS_FROM (new_var)
+	    && DECL_HAS_DEBUG_EXPR_P (var)
 	    && new_var != var)
 	  {
 	    tree tem = DECL_DEBUG_EXPR (var);
@@ -3772,6 +3772,7 @@ add_local_variables (struct function *callee, struct function *caller,
 	    id->remapping_type_depth--;
 	    id->regimplify = old_regimplify;
 	    SET_DECL_DEBUG_EXPR (new_var, tem);
+	    DECL_HAS_DEBUG_EXPR_P (new_var) = 1;
 	  }
 	add_local_decl (caller, new_var);
       }
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 35dcd4327123..93446c2151ae 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1961,7 +1961,7 @@ create_access_replacement (struct access *access)
       if (!fail)
 	{
 	  SET_DECL_DEBUG_EXPR (repl, debug_expr);
-	  DECL_DEBUG_EXPR_IS_FROM (repl) = 1;
+	  DECL_HAS_DEBUG_EXPR_P (repl) = 1;
 	}
       if (access->grp_no_warning)
 	TREE_NO_WARNING (repl) = 1;
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index a72e9d5a6b63..713458f8e98a 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -620,7 +620,7 @@ clear_unused_block_pointer_1 (tree *tp, int *, void *)
   if (EXPR_P (*tp) && TREE_BLOCK (*tp)
       && !TREE_USED (TREE_BLOCK (*tp)))
     TREE_SET_BLOCK (*tp, NULL);
-  if (TREE_CODE (*tp) == VAR_DECL && DECL_DEBUG_EXPR_IS_FROM (*tp))
+  if (TREE_CODE (*tp) == VAR_DECL && DECL_HAS_DEBUG_EXPR_P (*tp))
     {
       tree debug_expr = DECL_DEBUG_EXPR (*tp);
       walk_tree (&debug_expr, clear_unused_block_pointer_1, NULL, NULL);
@@ -640,7 +640,7 @@ clear_unused_block_pointer (void)
   unsigned i;
 
   FOR_EACH_LOCAL_DECL (cfun, i, t)
-    if (TREE_CODE (t) == VAR_DECL && DECL_DEBUG_EXPR_IS_FROM (t))
+    if (TREE_CODE (t) == VAR_DECL && DECL_HAS_DEBUG_EXPR_P (t))
       {
 	tree debug_expr = DECL_DEBUG_EXPR (t);
 	walk_tree (&debug_expr, clear_unused_block_pointer_1, NULL, NULL);
diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c
index ca2e5e9e35ee..b5ead0f9eb72 100644
--- a/gcc/tree-streamer-in.c
+++ b/gcc/tree-streamer-in.c
@@ -203,7 +203,6 @@ unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
   DECL_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_PRESERVE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
-  DECL_DEBUG_EXPR_IS_FROM (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_EXTERNAL (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_GIMPLE_REG_P (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_ALIGN (expr) = (unsigned) bp_unpack_var_len_unsigned (bp);
@@ -226,7 +225,10 @@ unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
     }
 
   if (TREE_CODE (expr) == VAR_DECL)
-    DECL_NONLOCAL_FRAME (expr) = (unsigned) bp_unpack_value (bp, 1);
+    {
+      DECL_HAS_DEBUG_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
+      DECL_NONLOCAL_FRAME (expr) = (unsigned) bp_unpack_value (bp, 1);
+    }
 
   if (TREE_CODE (expr) == RESULT_DECL
       || TREE_CODE (expr) == PARM_DECL
diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c
index 0ccd41371d13..2625dd6b42f7 100644
--- a/gcc/tree-streamer-out.c
+++ b/gcc/tree-streamer-out.c
@@ -170,7 +170,6 @@ pack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
   bp_pack_value (bp, DECL_ARTIFICIAL (expr), 1);
   bp_pack_value (bp, DECL_USER_ALIGN (expr), 1);
   bp_pack_value (bp, DECL_PRESERVE_P (expr), 1);
-  bp_pack_value (bp, DECL_DEBUG_EXPR_IS_FROM (expr), 1);
   bp_pack_value (bp, DECL_EXTERNAL (expr), 1);
   bp_pack_value (bp, DECL_GIMPLE_REG_P (expr), 1);
   bp_pack_var_len_unsigned (bp, DECL_ALIGN (expr));
@@ -192,7 +191,10 @@ pack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
     }
 
   if (TREE_CODE (expr) == VAR_DECL)
-    bp_pack_value (bp, DECL_NONLOCAL_FRAME (expr), 1);
+    {
+      bp_pack_value (bp, DECL_HAS_DEBUG_EXPR_P (expr), 1);
+      bp_pack_value (bp, DECL_NONLOCAL_FRAME (expr), 1);
+    }
 
   if (TREE_CODE (expr) == RESULT_DECL
       || TREE_CODE (expr) == PARM_DECL
diff --git a/gcc/tree.c b/gcc/tree.c
index 31f8037deb89..65bc15f76379 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -975,6 +975,9 @@ copy_node_stat (tree node MEM_STAT_DECL)
 	  SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (node));
 	  DECL_HAS_VALUE_EXPR_P (t) = 1;
 	}
+      /* DECL_DEBUG_EXPR is copied explicitely by callers.  */
+      if (TREE_CODE (node) == VAR_DECL)
+	DECL_HAS_DEBUG_EXPR_P (t) = 0;
       if (TREE_CODE (node) == VAR_DECL && DECL_HAS_INIT_PRIORITY_P (node))
 	{
 	  SET_DECL_INIT_PRIORITY (t, DECL_INIT_PRIORITY (node));
diff --git a/gcc/tree.h b/gcc/tree.h
index b852f1d9434a..9aae8df17bc9 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2709,8 +2709,6 @@ struct GTY(()) tree_decl_minimal {
    checked before any access to the former.  */
 #define DECL_FUNCTION_CODE(NODE) \
   (FUNCTION_DECL_CHECK (NODE)->function_decl.function_code)
-#define DECL_DEBUG_EXPR_IS_FROM(NODE) \
-  (DECL_COMMON_CHECK (NODE)->decl_common.debug_expr_is_from)
 
 #define DECL_FUNCTION_PERSONALITY(NODE) \
   (FUNCTION_DECL_CHECK (NODE)->function_decl.personality)
@@ -3223,9 +3221,9 @@ struct GTY(()) tree_decl_with_vis {
 
 extern tree decl_debug_expr_lookup (tree);
 extern void decl_debug_expr_insert (tree, tree);
-/* For VAR_DECL, this is set to either an expression that it was split
-   from (if DECL_DEBUG_EXPR_IS_FROM is true), otherwise a tree_list of
-   subexpressions that it was split into.  */
+/* For VAR_DECL, this is set to an expression that it was split from.  */
+#define DECL_HAS_DEBUG_EXPR_P(NODE) \
+  (VAR_DECL_CHECK (NODE)->decl_common.debug_expr_is_from)
 #define DECL_DEBUG_EXPR(NODE) \
   (decl_debug_expr_lookup (VAR_DECL_CHECK (NODE)))
 
diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 0db15625b709..4855fb155b3c 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -1780,11 +1780,11 @@ vars_copy (htab_t dst, htab_t src)
 static inline tree
 var_debug_decl (tree decl)
 {
-  if (decl && DECL_P (decl)
-      && DECL_DEBUG_EXPR_IS_FROM (decl))
+  if (decl && TREE_CODE (decl) == VAR_DECL
+      && DECL_HAS_DEBUG_EXPR_P (decl))
     {
       tree debugdecl = DECL_DEBUG_EXPR (decl);
-      if (debugdecl && DECL_P (debugdecl))
+      if (DECL_P (debugdecl))
 	decl = debugdecl;
     }
 
@@ -5041,12 +5041,10 @@ track_expr_p (tree expr, bool need_rtl)
      don't need to track this expression if the ultimate declaration is
      ignored.  */
   realdecl = expr;
-  if (DECL_DEBUG_EXPR_IS_FROM (realdecl))
+  if (TREE_CODE (realdecl) == VAR_DECL && DECL_HAS_DEBUG_EXPR_P (realdecl))
     {
       realdecl = DECL_DEBUG_EXPR (realdecl);
-      if (realdecl == NULL_TREE)
-	realdecl = expr;
-      else if (!DECL_P (realdecl))
+      if (!DECL_P (realdecl))
 	{
 	  if (handled_component_p (realdecl)
 	      || (TREE_CODE (realdecl) == MEM_REF
-- 
GitLab