diff options
author | Martin Jambor <mjambor@suse.cz> | 2013-05-13 12:16:09 +0200 |
---|---|---|
committer | Martin Jambor <jamborm@gcc.gnu.org> | 2013-05-13 12:16:09 +0200 |
commit | 4502fe8dfcb1cc2c59b50b868ac75fb5cdd742fc (patch) | |
tree | eb36587215072023d7faafc93b4cb03eb6f629f3 /gcc/testsuite | |
parent | 0864bfc257a3d3198ba182c562b729ba1e96466d (diff) | |
download | gcc-4502fe8dfcb1cc2c59b50b868ac75fb5cdd742fc.zip gcc-4502fe8dfcb1cc2c59b50b868ac75fb5cdd742fc.tar.gz gcc-4502fe8dfcb1cc2c59b50b868ac75fb5cdd742fc.tar.bz2 |
re PR middle-end/42371 (dead code not eliminated during folding with whole-program)
2013-05-13 Martin Jambor <mjambor@suse.cz>
PR middle-end/42371
* ipa-prop.h (IPA_UNDESCRIBED_USE): New macro.
(ipa_constant_data): New type.
(ipa_jump_func): Use ipa_constant_data to hold information about
constant jump functions.
(ipa_get_jf_constant): Adjust to jump function type changes.
(ipa_get_jf_constant_rdesc): New function.
(ipa_param_descriptor): New field controlled_uses.
(ipa_get_controlled_uses): New function.
(ipa_set_controlled_uses): Likewise.
* ipa-ref.h (ipa_find_reference): Declare.
* ipa-prop.c (ipa_cst_ref_desc): New type.
(ipa_print_node_jump_functions_for_edge): Adjust for jump function type
changes.
(ipa_set_jf_constant): Likewise. Also create reference descriptions.
New parameter cs. Adjust all callers.
(ipa_analyze_params_uses): Detect uncontrolled and controlled uses.
(remove_described_reference): New function.
(jfunc_rdesc_usable): Likewise.
(try_make_edge_direct_simple_call): Decrement controlled use count,
attempt to remove reference if it hits zero.
(combine_controlled_uses_counters): New function.
(propagate_controlled_uses): Likewise.
(ipa_propagate_indirect_call_infos): Call propagate_controlled_uses.
(ipa_edge_duplication_hook): Duplicate reference descriptions.
(ipa_print_node_params): Print described use counter.
(ipa_write_jump_function): Adjust to jump function type changes.
(ipa_read_jump_function): New parameter CS, pass it to
ipa_set_jf_constant. Adjust caller.
(ipa_write_node_info): Stream controlled use count
(ipa_read_node_info): Likewise.
* cgraph.c (cgraph_mark_address_taken_node): Bail out instead of
asserting.
* ipa-cp.c (ipcp_discover_new_direct_edges): Decrement controlled use
count. Remove cloning-added reference if it reaches zero.
* ipa-ref.c (ipa_find_reference): New function.
testsuite/
* gcc.dg/ipa/remref-0.c: New test.
* gcc.dg/ipa/remref-1a.c: Likewise.
* gcc.dg/ipa/remref-1b.c: Likewise.
* gcc.dg/ipa/remref-2a.c: Likewise.
* gcc.dg/ipa/remref-2b.c: Likewise.
From-SVN: r198821
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/remref-0.c | 30 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/remref-1a.c | 34 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/remref-1b.c | 37 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/remref-2a.c | 90 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/remref-2b.c | 94 |
6 files changed, 294 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1e59972..b4fc7f9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2013-05-13 Martin Jambor <mjambor@suse.cz> + + PR middle-end/42371 + * gcc.dg/ipa/remref-0.c: New test. + * gcc.dg/ipa/remref-1a.c: Likewise. + * gcc.dg/ipa/remref-1b.c: Likewise. + * gcc.dg/ipa/remref-2a.c: Likewise. + * gcc.dg/ipa/remref-2b.c: Likewise. + 2013-05-13 Marc Glisse <marc.glisse@inria.fr> * gcc.dg/vector-shift-2.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/ipa/remref-0.c b/gcc/testsuite/gcc.dg/ipa/remref-0.c new file mode 100644 index 0000000..a9e434a --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/remref-0.c @@ -0,0 +1,30 @@ +/* Verify that indirect inlining machinery can remove references to functions + passed as parameters that are never used. */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-early-inlining -fno-ipa-sra -fno-ipa-cp -fdump-ipa-inline -fdump-tree-optimized" } */ + +extern int __attribute__ ((noinline, noclone, used)) +stuff (int i) +{ + return 0; +} + +static void hooray () +{ + stuff (1); +} + +static int hiphip (void (*f)()) +{ + return stuff (2); +} + +int main (void) +{ + return hiphip (hooray); +} + +/* { dg-final { scan-ipa-dump "ipa-prop: Removed a reference" "inline" } } */ +/* { dg-final { scan-tree-dump-not "hooray" "optimized" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/remref-1a.c b/gcc/testsuite/gcc.dg/ipa/remref-1a.c new file mode 100644 index 0000000..9db2bd6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/remref-1a.c @@ -0,0 +1,34 @@ +/* Verify that indirect inlining can also remove references of the functions it + discovers calls for. */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-early-inlining -fno-ipa-cp -fdump-ipa-inline -fdump-tree-optimized" } */ + +int global; + +void __attribute__ ((noinline, noclone, used)) +stuff (int i) +{ + global = i; +} + +static void hooray () +{ + stuff (1); +} + +static void hiphip (void (*f)()) +{ + stuff (2); + f (); +} + +int main (void) +{ + hiphip (hooray); + return 0; +} + +/* { dg-final { scan-ipa-dump "ipa-prop: Removed a reference" "inline" } } */ +/* { dg-final { scan-tree-dump-not "hooray" "optimized" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/remref-1b.c b/gcc/testsuite/gcc.dg/ipa/remref-1b.c new file mode 100644 index 0000000..a17cf48 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/remref-1b.c @@ -0,0 +1,37 @@ +/* Verify that indirect inlining can also remove references of the functions it + discovers calls for, even when nodes being inlined are virtual IPA-CP + clones. */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-early-inlining -fdump-ipa-cp-details -fdump-ipa-inline -fdump-tree-optimized" } */ + +int global; + +void __attribute__ ((noinline, noclone, used)) +stuff (int i) +{ + global = i; +} + +static void hooray () +{ + stuff (1); +} + +static void hiphip (void (*f)()) +{ + stuff (2); + f (); +} + +int main (void) +{ + hiphip (hooray); + return 0; +} + +/* { dg-final { scan-ipa-dump "removing its cloning-created reference" "cp" } } */ +/* { dg-final { scan-ipa-dump "ipa-prop: Removed a reference" "inline" } } */ +/* { dg-final { scan-tree-dump-not "hooray" "optimized" } } */ +/* { dg-final { cleanup-ipa-dump "cp" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/remref-2a.c b/gcc/testsuite/gcc.dg/ipa/remref-2a.c new file mode 100644 index 0000000..1e0df2e --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/remref-2a.c @@ -0,0 +1,90 @@ +/* Verify that indirect inlining can also remove references of the functions it + discovers calls for. */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-early-inlining -fno-ipa-cp -fdump-ipa-inline -fdump-tree-optimized" } */ + +int global; + +void __attribute__ ((noinline, noclone, used)) +stuff (int i) +{ + global = i; +} + +int __attribute__ ((noinline,noclone)) get_input(void) +{ + return 1; +} + +static void +hooray_1 () +{ + stuff (1); +} + +static inline void +hip2_1 (void (*g)()) +{ + int i; + g (); + /* Some stuff to make the function bigger so that hip1_1 gets inlined + fiorst. */ + for (i = 0; i < get_input (); i++) + { + stuff (2); + stuff (2+2); + } +} + +static inline void +hip1_1 (void (*g)()) +{ + hip2_1 (g); +} + +static void +hooray_2 () +{ + stuff (1); +} + +static inline void +hip2_2 (void (*g)()) +{ + g (); +} + +static inline void +hip1_2 (void (*g)()) +{ + int i; + + hip2_2 (g); + + /* Some stuff to make the function bigger so that hip2_2 gets inlined + fiorst. */ + for (i = 0; i < get_input (); i++) + { + stuff (2); + stuff (2+2); + } +} + + +int +main (int argc, int *argv[]) +{ + int i; + + for (i = 0; i < get_input (); i++) + { + hip1_1 (hooray_1); + hip1_2 (hooray_2); + } + return 0; +} + +/* { dg-final { scan-ipa-dump-times "ipa-prop: Removed a reference" 2 "inline" } } */ +/* { dg-final { scan-tree-dump-not "hooray" "optimized" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/remref-2b.c b/gcc/testsuite/gcc.dg/ipa/remref-2b.c new file mode 100644 index 0000000..554f306 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/remref-2b.c @@ -0,0 +1,94 @@ +/* Verify that indirect inlining can also remove references of the functions it + discovers calls for, even when nodes being inlined are virtual IPA-CP + clones. */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-early-inlining -fdump-ipa-cp-details -fdump-ipa-inline -fdump-tree-optimized" } */ + + +int global; + +void __attribute__ ((noinline, noclone, used)) +stuff (int i) +{ + global = i; +} + +int __attribute__ ((noinline,noclone)) get_input(void) +{ + return 1; +} + +static void +hooray_1 () +{ + stuff (1); +} + +static inline void +hip2_1 (void (*g)()) +{ + int i; + g (); + /* Some stuff to make the function bigger so that hip1_1 gets inlined + fiorst. */ + for (i = 0; i < get_input (); i++) + { + stuff (2); + stuff (2+2); + } +} + +static inline void +hip1_1 (void (*g)()) +{ + hip2_1 (g); +} + +static void +hooray_2 () +{ + stuff (1); +} + +static inline void +hip2_2 (void (*g)()) +{ + g (); +} + +static inline void +hip1_2 (void (*g)()) +{ + int i; + + hip2_2 (g); + + /* Some stuff to make the function bigger so that hip2_2 gets inlined + fiorst. */ + for (i = 0; i < get_input (); i++) + { + stuff (2); + stuff (2+2); + } +} + +int +main (int argc, int *argv[]) +{ + int i; + + for (i = 0; i < get_input (); i++) + { + hip1_1 (hooray_1); + hip1_2 (hooray_2); + } + return 0; +} + +/* { dg-final { scan-ipa-dump-times "removing its cloning-created reference" 2 "cp" } } */ +/* { dg-final { scan-ipa-dump "ipa-prop: Removed a reference" "inline" } } */ +/* { dg-final { scan-ipa-dump-times "ipa-prop: Removing cloning-created reference" 2 "inline" } } */ +/* { dg-final { scan-tree-dump-not "hooray" "optimized" } } */ +/* { dg-final { cleanup-ipa-dump "cp" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ |