public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR55736
@ 2012-12-19 11:40 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2012-12-19 11:40 UTC (permalink / raw)
  To: gcc-patches


Switch conversion currently makes no effort to hide BLOCKs from
locations of expressions it puts into the static constructors built.
This causes issues at least for LTO where dead references to BLOCKs
end up being produced for the varpool global initializers.  But
I can very well imagine that later CCP can re-expose these BLOCKs
after they have been collected in a regular compilation as well.

The patch moves the function that strips expressions of their
location from ipa-prop.c next to unshare_expr and calls it
unshare_expr_without_location.

LTO bootstrap and regtest ongoing on x86_64-unknown-linux-gnu.

Richard.

2012-12-19  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/55736
	* gimplify.c (prune_expr_location): New function.
	(unshare_expr_without_location): Likewise.
	* tree.h (unshare_expr_without_location): Declare.
	* ipa-prop.c (prune_expression_for_jf): Remove.
	(prune_expression_for_jf_1): Likewise.
	(ipa_set_jf_constant): Use unshare_expr_without_location.
	(ipa_set_jf_arith_pass_through): Likewise.
	(determine_known_aggregate_parts): Likewise.
	* tree-switch-conversion.c (build_constructors): Use
	unshare_expr_without_location on all constructor elements.

Index: gcc/gimplify.c
===================================================================
*** gcc/gimplify.c	(revision 194578)
--- gcc/gimplify.c	(working copy)
*************** unshare_expr (tree expr)
*** 1059,1064 ****
--- 1059,1088 ----
    walk_tree (&expr, mostly_copy_tree_r, NULL, NULL);
    return expr;
  }
+ 
+ /* Worker for unshare_expr_without_location.  */
+ 
+ static tree
+ prune_expr_location (tree *tp, int *walk_subtrees, void *)
+ {
+   if (EXPR_P (*tp))
+     SET_EXPR_LOCATION (*tp, UNKNOWN_LOCATION);
+   else
+     *walk_subtrees = 0;
+   return NULL_TREE;
+ }
+ 
+ /* Similar to unshare_expr but also prune all expression locations
+    from EXPR.  */
+ 
+ tree
+ unshare_expr_without_location (tree expr)
+ {
+   walk_tree (&expr, mostly_copy_tree_r, NULL, NULL);
+   if (EXPR_P (expr))
+     walk_tree (&expr, prune_expr_location, NULL, NULL);
+   return expr;
+ }
  \f
  /* WRAPPER is a code such as BIND_EXPR or CLEANUP_POINT_EXPR which can both
     contain statements and have a value.  Assign its value to a temporary
Index: gcc/tree.h
===================================================================
*** gcc/tree.h	(revision 194578)
--- gcc/tree.h	(working copy)
*************** extern void change_decl_assembler_name (
*** 5606,5611 ****
--- 5606,5612 ----
  \f
  /* In gimplify.c */
  extern tree unshare_expr (tree);
+ extern tree unshare_expr_without_location (tree);
  \f
  /* In stmt.c */
  
Index: gcc/ipa-prop.c
===================================================================
*** gcc/ipa-prop.c	(revision 194578)
--- gcc/ipa-prop.c	(working copy)
*************** ipa_print_all_jump_functions (FILE *f)
*** 295,325 ****
      }
  }
  
- /* Worker for prune_expression_for_jf.  */
- 
- static tree
- prune_expression_for_jf_1 (tree *tp, int *walk_subtrees, void *)
- {
-   if (EXPR_P (*tp))
-     SET_EXPR_LOCATION (*tp, UNKNOWN_LOCATION);
-   else
-     *walk_subtrees = 0;
-   return NULL_TREE;
- }
- 
- /* Return the expression tree EXPR unshared and with location stripped off.  */
- 
- static tree
- prune_expression_for_jf (tree exp)
- {
-   if (EXPR_P (exp))
-     {
-       exp = unshare_expr (exp);
-       walk_tree (&exp, prune_expression_for_jf_1, NULL, NULL);
-     }
-   return exp;
- }
- 
  /* Set JFUNC to be a known type jump function.  */
  
  static void
--- 295,300 ----
*************** ipa_set_jf_constant (struct ipa_jump_fun
*** 341,347 ****
    if (constant && EXPR_P (constant))
      SET_EXPR_LOCATION (constant, UNKNOWN_LOCATION);
    jfunc->type = IPA_JF_CONST;
!   jfunc->value.constant = prune_expression_for_jf (constant);
  }
  
  /* Set JFUNC to be a simple pass-through jump function.  */
--- 316,322 ----
    if (constant && EXPR_P (constant))
      SET_EXPR_LOCATION (constant, UNKNOWN_LOCATION);
    jfunc->type = IPA_JF_CONST;
!   jfunc->value.constant = unshare_expr_without_location (constant);
  }
  
  /* Set JFUNC to be a simple pass-through jump function.  */
*************** ipa_set_jf_arith_pass_through (struct ip
*** 363,369 ****
  			       tree operand, enum tree_code operation)
  {
    jfunc->type = IPA_JF_PASS_THROUGH;
!   jfunc->value.pass_through.operand = prune_expression_for_jf (operand);
    jfunc->value.pass_through.formal_id = formal_id;
    jfunc->value.pass_through.operation = operation;
    jfunc->value.pass_through.agg_preserved = false;
--- 338,344 ----
  			       tree operand, enum tree_code operation)
  {
    jfunc->type = IPA_JF_PASS_THROUGH;
!   jfunc->value.pass_through.operand = unshare_expr_without_location (operand);
    jfunc->value.pass_through.formal_id = formal_id;
    jfunc->value.pass_through.operation = operation;
    jfunc->value.pass_through.agg_preserved = false;
*************** determine_known_aggregate_parts (gimple
*** 1385,1391 ****
  	    {
  	      struct ipa_agg_jf_item item;
  	      item.offset = list->offset - arg_offset;
! 	      item.value = prune_expression_for_jf (list->constant);
  	      jfunc->agg.items->quick_push (item);
  	    }
  	  list = list->next;
--- 1360,1366 ----
  	    {
  	      struct ipa_agg_jf_item item;
  	      item.offset = list->offset - arg_offset;
! 	      item.value = unshare_expr_without_location (list->constant);
  	      jfunc->agg.items->quick_push (item);
  	    }
  	  list = list->next;
Index: gcc/tree-switch-conversion.c
===================================================================
*** gcc/tree-switch-conversion.c	(revision 194578)
--- gcc/tree-switch-conversion.c	(working copy)
*************** build_constructors (gimple swtch, struct
*** 873,879 ****
  	      constructor_elt elt;
  
  	      elt.index = int_const_binop (MINUS_EXPR, pos, info->range_min);
! 	      elt.value = info->default_values[k];
  	      info->constructors[k]->quick_push (elt);
  	    }
  
--- 873,880 ----
  	      constructor_elt elt;
  
  	      elt.index = int_const_binop (MINUS_EXPR, pos, info->range_min);
! 	      elt.value
! 		= unshare_expr_without_location (info->default_values[k]);
  	      info->constructors[k]->quick_push (elt);
  	    }
  
*************** build_constructors (gimple swtch, struct
*** 899,905 ****
  	      constructor_elt elt;
  
  	      elt.index = int_const_binop (MINUS_EXPR, pos, info->range_min);
! 	      elt.value = val;
  	      info->constructors[j]->quick_push (elt);
  
  	      pos = int_const_binop (PLUS_EXPR, pos, integer_one_node);
--- 900,906 ----
  	      constructor_elt elt;
  
  	      elt.index = int_const_binop (MINUS_EXPR, pos, info->range_min);
! 	      elt.value = unshare_expr_without_location (val);
  	      info->constructors[j]->quick_push (elt);
  
  	      pos = int_const_binop (PLUS_EXPR, pos, integer_one_node);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-12-19 11:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-19 11:40 [PATCH] Fix PR55736 Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).