diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-12-19 13:53:18 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-12-19 13:53:18 +0000 |
commit | 827e392be72812c2ace9e54e7e00ed188fc6828d (patch) | |
tree | 16f545224cd8116189b4ccd1992329c439c78de9 | |
parent | d5065e6e5546d31ca14bdf7105d94ca845b2a885 (diff) | |
download | ppe42-gcc-827e392be72812c2ace9e54e7e00ed188fc6828d.tar.gz ppe42-gcc-827e392be72812c2ace9e54e7e00ed188fc6828d.zip |
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.
* 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
-rw-r--r-- | gcc/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/gimplify.c | 24 | ||||
-rw-r--r-- | gcc/ipa-prop.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/lto/pr55703_0.c | 59 | ||||
-rw-r--r-- | gcc/tree-switch-conversion.c | 5 | ||||
-rw-r--r-- | gcc/tree.h | 1 |
7 files changed, 111 insertions, 30 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fe52e01a93c..c7f3643ef7b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +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. diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 384adb21c35..f628b8ab3c0 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1059,6 +1059,30 @@ unshare_expr (tree expr) 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; +} /* 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 diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 4f887a0acc4..d225b85f7d0 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -295,31 +295,6 @@ ipa_print_all_jump_functions (FILE *f) } } -/* 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 @@ -341,7 +316,7 @@ ipa_set_jf_constant (struct ipa_jump_func *jfunc, tree constant) 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. */ @@ -363,7 +338,7 @@ ipa_set_jf_arith_pass_through (struct ipa_jump_func *jfunc, int formal_id, 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; @@ -1385,7 +1360,7 @@ determine_known_aggregate_parts (gimple call, tree arg, { 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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 81693bf15ff..8ae2361e46c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/gcc/testsuite/gcc.dg/lto/pr55703_0.c b/gcc/testsuite/gcc.dg/lto/pr55703_0.c new file mode 100644 index 00000000000..1c4e04b3a37 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr55703_0.c @@ -0,0 +1,59 @@ +/* { 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); +} diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index 9eed5e0e6a4..d250a94567a 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -873,7 +873,8 @@ build_constructors (gimple swtch, struct switch_conv_info *info) 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); } @@ -899,7 +900,7 @@ build_constructors (gimple swtch, struct switch_conv_info *info) 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); diff --git a/gcc/tree.h b/gcc/tree.h index 01e81b2ee19..b68328ec2af 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -5606,6 +5606,7 @@ extern void change_decl_assembler_name (tree, tree); /* In gimplify.c */ extern tree unshare_expr (tree); +extern tree unshare_expr_without_location (tree); /* In stmt.c */ |