aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-utils.h
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2021-11-11 18:14:45 +0100
committerJan Hubicka <jh@suse.cz>2021-11-11 18:14:45 +0100
commit494bdadf28d0fb3505ff8dce5afa587e0ff46544 (patch)
tree9924cba8140a7768bc2b1a4e4997f1d1eec9fa07 /gcc/ipa-utils.h
parentabdff441a07f55d16e3d0e5ced3123c83d210a0a (diff)
downloadgcc-494bdadf28d0fb3505ff8dce5afa587e0ff46544.zip
gcc-494bdadf28d0fb3505ff8dce5afa587e0ff46544.tar.gz
gcc-494bdadf28d0fb3505ff8dce5afa587e0ff46544.tar.bz2
Enable pure-const discovery in modref.
We newly can handle some extra cases, for example: struct a {int a,b,c;}; __attribute__ ((noinline)) int init (struct a *a) { a->a=1; a->b=2; a->c=3; } int const_fn () { struct a a; init (&a); return a.a + a.b + a.c; } Here pure/const stops on the fact that const_fn calls non-const init, while modref knows that the memory it initializes is local to const_fn. I ended up reordering passes so early modref is done after early pure-const mostly to avoid need to change testsuite which greps for const functions being detects in pure-const. Stil some testuiste compensation is needed. gcc/ChangeLog: 2021-11-11 Jan Hubicka <hubicka@ucw.cz> * ipa-modref.c (analyze_function): Do pure/const discovery, return true on success. (pass_modref::execute): If pure/const is discovered fixup cfg. (ignore_edge): Do not ignore pure/const edges. (modref_propagate_in_scc): Do pure/const discovery, return true if cdtor was promoted pure/const. (pass_ipa_modref::execute): If needed remove unreachable functions. * ipa-pure-const.c (warn_function_noreturn): Fix whitespace. (warn_function_cold): Likewise. (skip_function_for_local_pure_const): Move earlier. (ipa_make_function_const): Break out from ... (ipa_make_function_pure): Break out from ... (propagate_pure_const): ... here. (pass_local_pure_const::execute): Use it. * ipa-utils.h (ipa_make_function_const): Declare. (ipa_make_function_pure): Declare. * passes.def: Move early modref after pure-const. gcc/testsuite/ChangeLog: 2021-11-11 Jan Hubicka <hubicka@ucw.cz> * c-c++-common/tm/inline-asm.c: Disable pure-const. * g++.dg/ipa/modref-1.C: Update template. * gcc.dg/tree-ssa/modref-11.c: Disable pure-const. * gcc.dg/tree-ssa/modref-14.c: New test. * gcc.dg/tree-ssa/modref-8.c: Do not optimize sibling calls. * gfortran.dg/do_subscript_3.f90: Add -O0.
Diffstat (limited to 'gcc/ipa-utils.h')
-rw-r--r--gcc/ipa-utils.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h
index 824780f..e2440a1 100644
--- a/gcc/ipa-utils.h
+++ b/gcc/ipa-utils.h
@@ -50,6 +50,8 @@ bool recursive_call_p (tree, tree);
/* In ipa-pure-const.c */
bool finite_function_p ();
bool builtin_safe_for_const_function_p (bool *, tree);
+bool ipa_make_function_const (cgraph_node *, bool, bool);
+bool ipa_make_function_pure (cgraph_node *, bool, bool);
/* In ipa-profile.c */
bool ipa_propagate_frequency (struct cgraph_node *node);