PR tree-optimization/55736
PR tree-optimization/55703
* 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.
* gcc.dg/lto/pr55703_0.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194609
138bc75d-0d04-0410-961f-
82ee72b054a4
+2012-12-19 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/55736
+ PR tree-optimization/55703
+ * 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.
+
2012-12-19 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* target.def: Define canonicalize_comparison hook.
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
}
}
-/* 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
if (constant && EXPR_P (constant))
SET_EXPR_LOCATION (constant, UNKNOWN_LOCATION);
jfunc->type = IPA_JF_CONST;
- jfunc->value.constant = prune_expression_for_jf (constant);
+ jfunc->value.constant = unshare_expr_without_location (constant);
}
/* Set JFUNC to be a simple pass-through jump function. */
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.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;
{
struct ipa_agg_jf_item item;
item.offset = list->offset - arg_offset;
- item.value = prune_expression_for_jf (list->constant);
+ item.value = unshare_expr_without_location (list->constant);
jfunc->agg.items->quick_push (item);
}
list = list->next;
+2012-12-19 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/55736
+ PR tree-optimization/55703
+ * gcc.dg/lto/pr55703_0.c: New testcase.
+
2012-12-19 Jakub Jelinek <jakub@redhat.com>
PR debug/55730
--- /dev/null
+/* { dg-lto-do run } */
+/* { dg-lto-options { { -O2 -flto -fno-tree-copy-prop -fno-tree-dce } } } */
+
+int try (int num) {
+ __label__ lab1, lab2, lab3, lab4, lab5, lab6, default_lab;
+
+ void *do_switch (int num) {
+ switch(num) {
+ case 1:
+ return &&lab1;
+ case 2:
+ return &&lab2;
+ case 3:
+ return &&lab3;
+ case 4:
+ return &&lab4;
+ case 5:
+ return &&lab5;
+ case 6:
+ return &&lab6;
+ default:
+ return &&default_lab;
+ }
+ }
+
+ goto *do_switch (num);
+
+ lab1:
+ return 1;
+
+ lab2:
+ return 2;
+
+ lab3:
+ return 3;
+
+ lab4:
+ return 4;
+
+ lab5:
+ return 5;
+
+ lab6:
+ return 6;
+
+ default_lab:
+ return -1;
+}
+
+main()
+{
+ int i;
+ for (i = 1; i <= 6; i++)
+ {
+ if (try (i) != i)
+ __builtin_abort();
+ }
+ __builtin_exit(0);
+}
constructor_elt elt;
elt.index = int_const_binop (MINUS_EXPR, pos, info->range_min);
- elt.value = info->default_values[k];
+ elt.value
+ = unshare_expr_without_location (info->default_values[k]);
info->constructors[k]->quick_push (elt);
}
constructor_elt elt;
elt.index = int_const_binop (MINUS_EXPR, pos, info->range_min);
- elt.value = val;
+ elt.value = unshare_expr_without_location (val);
info->constructors[j]->quick_push (elt);
pos = int_const_binop (PLUS_EXPR, pos, integer_one_node);
\f
/* In gimplify.c */
extern tree unshare_expr (tree);
+extern tree unshare_expr_without_location (tree);
\f
/* In stmt.c */