diff options
author | Jan Hubicka <jh@suse.cz> | 2021-11-10 16:00:40 +0100 |
---|---|---|
committer | Jan Hubicka <jh@suse.cz> | 2021-11-10 16:00:40 +0100 |
commit | 992644c3511acd58248db784f1ac43e2f053ebcc (patch) | |
tree | f5fee4afb22e7567234c3a08c1020605e94fb613 /gcc/ipa-utils.h | |
parent | a5c9b9bc2b60845624b105a98297bdf854c289da (diff) | |
download | gcc-992644c3511acd58248db784f1ac43e2f053ebcc.zip gcc-992644c3511acd58248db784f1ac43e2f053ebcc.tar.gz gcc-992644c3511acd58248db784f1ac43e2f053ebcc.tar.bz2 |
Extend modref by side-effect analysis
Make modref to also collect info whether function has side
effects. This allows pure/const function detection and also handling
functions which do store some memory in similar way as we handle
pure/consts now.
The code is symmetric to what ipa-pure-const does. Modref is actually more
capable on proving that a given function is pure/const (since it understands
that non-pure function can be called when it only modifies data on stack)
so we could retire ipa-pure-const's pure-const discovery at some point.
However this patch only does the anlaysis - the consumers of this flag
will come next.
Bootstrapped/regtested x86_64-linux. I plan to commit it later today
if there are no complains.
gcc/ChangeLog:
* ipa-modref.c: Include tree-eh.h
(modref_summary::modref_summary): Initialize side_effects.
(struct modref_summary_lto): New bool field side_effects.
(modref_summary_lto::modref_summary_lto): Initialize side_effects.
(modref_summary::dump): Dump side_effects.
(modref_summary_lto::dump): Dump side_effects.
(merge_call_side_effects): Merge side effects.
(process_fnspec): Calls to non-const/pure or looping
function is a side effect.
(analyze_call): Self-recursion is a side-effect; handle
special builtins.
(analyze_load): Watch for volatile and throwing memory.
(analyze_store): Likewise.
(analyze_stmt): Watch for volatitle asm.
(analyze_function): Handle side_effects.
(modref_summaries::duplicate): Duplicate side_effects.
(modref_summaries_lto::duplicate): Likewise.
(modref_write): Stream side_effects.
(read_section): Likewise.
(update_signature): Update.
(propagate_unknown_call): Handle side_effects.
(modref_propagate_in_scc): Likewise.
* ipa-modref.h (struct modref_summary): Add side_effects.
* ipa-pure-const.c (special_builtin_state): Rename to ...
(builtin_safe_for_const_function_p): ... this one.
(check_call): Update.
(finite_function_p): Break out from ...
(propagate_pure_const): ... here
* ipa-utils.h (finite_function): Declare.
Diffstat (limited to 'gcc/ipa-utils.h')
-rw-r--r-- | gcc/ipa-utils.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h index 3cfaf2d..824780f 100644 --- a/gcc/ipa-utils.h +++ b/gcc/ipa-utils.h @@ -47,6 +47,10 @@ void ipa_merge_profiles (struct cgraph_node *dst, struct cgraph_node *src, bool preserve_body = false); bool recursive_call_p (tree, tree); +/* In ipa-pure-const.c */ +bool finite_function_p (); +bool builtin_safe_for_const_function_p (bool *, tree); + /* In ipa-profile.c */ bool ipa_propagate_frequency (struct cgraph_node *node); |