From 6cef01c32817b3d08af2cadcdb0e23c72ceed426 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Fri, 6 Nov 2020 10:23:58 +0100 Subject: Add fnspec handling to ipa mode of ipa-modef. gcc/: * attr-fnspec.h (attr_fnspec::get_str): New accessor * ipa-fnsummary.c (read_ipa_call_summary): Store also parm info for builtins. * ipa-modref.c (class fnspec_summary): New type. (class fnspec_summaries_t): New type. (modref_summary::modref_summary): Initialize writes_errno. (struct modref_summary_lto): Add writes_errno. (modref_summary_lto::modref_summary_lto): Initialize writes_errno. (modref_summary::dump): Check for NULL pointers. (modref_summary_lto::dump): Dump writes_errno. (collapse_loads): Move up in source file. (collapse_stores): New function. (process_fnspec): Handle also internal calls. (analyze_call): Likewise. (analyze_stmt): Store fnspec string if needed. (analyze_function): Initialize fnspec_sumarries. (modref_summaries_lto::duplicate): Copy writes_errno. (modref_write): Store writes_errno and fnspec summaries. (read_section): Read writes_errno and fnspec summaries. (modref_read): Initialize fnspec summaries. (update_signature): Fix formating. (compute_parm_map): Return true if sucessful. (get_parm_type): New function. (get_access_for_fnspec): New function. (propagate_unknown_call): New function. (modref_propagate_in_scc): Use it. (pass_ipa_modref::execute): Delete fnspec_summaries. (ipa_modref_c_finalize): Delete fnspec_summaries. * ipa-prop.c: Include attr-fnspec.h. (ipa_compute_jump_functions_for_bb): Also compute jump functions for functions with fnspecs. (ipa_read_edge_info): Read jump functions for builtins. gcc/testsuite/ChangeLog: * gcc.dg/ipa/modref-2.c: New test. * gcc.dg/lto/modref-2_0.c: New test. --- gcc/ipa-prop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gcc/ipa-prop.c') diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index d4ef6ff..7a5fa59 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -54,6 +54,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-cfgcleanup.h" #include "options.h" #include "symtab-clones.h" +#include "attr-fnspec.h" /* Function summary where the parameter infos are actually stored. */ ipa_node_params_t *ipa_node_params_sum = NULL; @@ -2364,7 +2365,8 @@ ipa_compute_jump_functions_for_bb (struct ipa_func_body_info *fbi, basic_block b callee = callee->ultimate_alias_target (); /* We do not need to bother analyzing calls to unknown functions unless they may become known during lto/whopr. */ - if (!callee->definition && !flag_lto) + if (!callee->definition && !flag_lto + && !gimple_call_fnspec (cs->call_stmt).known_p ()) continue; } ipa_compute_jump_functions_for_edge (fbi, cs); @@ -4974,7 +4976,11 @@ ipa_read_edge_info (class lto_input_block *ib, count /= 2; if (!count) return; - if (prevails && e->possibly_call_in_translation_unit_p ()) + if (prevails + && (e->possibly_call_in_translation_unit_p () + /* Also stream in jump functions to builtins in hope that they + will get fnspecs. */ + || fndecl_built_in_p (e->callee->decl, BUILT_IN_NORMAL))) { class ipa_edge_args *args = IPA_EDGE_REF_GET_CREATE (e); vec_safe_grow_cleared (args->jump_functions, count, true); -- cgit v1.1