#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
#include "stringpool.h"
#include "gimple.h"
#include "diagnostic-core.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-pass.h"
#include "target.h"
#include "attribs.h"
#include "pretty-print.h"
#include "gimple-iterator.h"
#include "gimple-walk.h"
#include "tree-inline.h"
#include "intl.h"
Functions | |
static tree | replace_function_decl (tree *op, int *walk_subtrees, void *data) |
static void | create_dispatcher_calls (struct cgraph_node *node) |
static int | get_attr_str (tree arglist, char *attr_str) |
static int | separate_attrs (char *attr_str, char **attrs, int attrnum) |
static bool | is_valid_asm_symbol (char c) |
static void | create_new_asm_name (char *old_asm_name, char *new_asm_name) |
static cgraph_node * | create_target_clone (cgraph_node *node, bool definition, char *name, tree attributes) |
static bool | expand_target_clones (struct cgraph_node *node, bool definition) |
static void | redirect_to_specific_clone (cgraph_node *node) |
static unsigned int | ipa_target_clone (void) |
simple_ipa_opt_pass * | make_pass_target_clone (gcc::context *ctxt) |
|
static |
If the call in NODE has multiple target attribute with multiple fields, replace it with dispatcher call and create dispatcher (once).
References symtab_node::add_to_same_comdat_group(), symtab_node::alias, symtab_node::alias_target, symtab_node::analyzed, cgraph_node::callers, clone_function_name(), symtab_node::create_reference(), symtab_node::decl, DECL_ARTIFICIAL, DECL_INITIAL, DECL_SOURCE_LOCATION, symtab_node::definition, dyn_cast(), error_at(), symtab_node::externally_visible, FOR_EACH_VEC_ELT, symtab_node::force_output, symtab_node::forced_by_abi, cgraph_node::function_version(), gcc_assert, gcc_unreachable, cgraph_node::get(), symtab_node::get_comdat_group(), gsi_for_stmt(), i, IPA_REF_ADDR, IPA_REF_ALIAS, symtab_node::iterate_referring(), symtab_node::make_decl_local(), cgraph_edge::next_caller, NULL, cgraph_edge::redirect_call_stmt_to_callee(), cgraph_edge::redirect_callee(), ipa_ref::referring, symtab_node::remove_from_same_comdat_group(), ipa_ref::remove_reference(), replace_function_decl(), symtab_node::resolve_alias(), symtab_node::same_comdat_group, symtab_node::set_comdat_group(), symtab_node::set_section(), ipa_ref::stmt, symtab, targetm, ipa_ref::use, walk_gimple_stmt(), and walk_tree.
Referenced by ipa_target_clone().
|
static |
Replace all not valid assembler symbols with '_'.
References i, and is_valid_asm_symbol().
Referenced by expand_target_clones().
|
static |
Creates target clone of NODE.
References clone_function_name(), copy_node(), cgraph_node::create_version_clone_with_body(), symtab_node::decl, DECL_ATTRIBUTES, symtab_node::force_output, cgraph_node::get_create(), NULL, symtab, and vNULL.
Referenced by expand_target_clones().
|
static |
If the function in NODE has multiple target attributes create the appropriate clone for each valid target attribute.
References symtab_node::alias, copy_forbidden(), create_new_asm_name(), create_target_clone(), symtab_node::decl, DECL_ATTRIBUTES, DECL_FUNCTION_VERSIONED, DECL_SOURCE_LOCATION, DECL_STRUCT_FUNCTION, symtab_node::definition, error_at(), cgraph_node::function_version(), G_, get_attr_str(), get_target_clone_attr_len(), i, inform(), cgraph_node::insert_new_function_version(), cgraph_node::local, lookup_attribute(), make_attribute(), cgraph_function_version_info::next, NULL, cgraph_function_version_info::prev, separate_attrs(), TARGET_HAS_FMV_TARGET_ATTRIBUTE, TREE_VALUE, tree_versionable_function_p(), and warning_at().
Referenced by ipa_target_clone().
|
static |
Create string with attributes separated by TARGET_CLONES_ATTR_SEPARATOR. Return number of attributes.
References TARGET_CLONES_ATTR_SEPARATOR, TREE_CHAIN, TREE_STRING_POINTER, and TREE_VALUE.
Referenced by expand_target_clones().
|
static |
|
static |
Return true if symbol is valid in assembler name.
Referenced by create_new_asm_name().
simple_ipa_opt_pass * make_pass_target_clone | ( | gcc::context * | ctxt | ) |
|
static |
When NODE is a target clone, consider all callees and redirect to a clone with equal target attributes. That prevents multiple multi-versioning dispatches and a call-chain can be optimized. This optimisation might pick the wrong version in some cases, since knowing that we meet the target requirements for a matching callee version does not tell us that we won't also meet the target requirements for a higher priority callee version at runtime. Since this is longstanding behaviour for x86 and powerpc, we preserve it for those targets, but skip the optimisation for targets that use the "target_version" attribute for multi-versioning.
References attribute_value_equal(), cgraph_node::callees, symtab_node::decl, DECL_ATTRIBUTES, cgraph_node::function_version(), gcc_assert, lookup_attribute(), cgraph_function_version_info::next, cgraph_edge::next_callee, NULL, NULL_TREE, cgraph_function_version_info::prev, cgraph_edge::redirect_call_stmt_to_callee(), TARGET_HAS_FMV_TARGET_ATTRIBUTE, and cgraph_function_version_info::this_node.
Referenced by ipa_target_clone().
Pass for parsing functions with multiple target attributes. Contributed by Evgeny Stupachenko <evstupac@gmail.com> Copyright (C) 2015-2025 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
Walker callback that replaces all FUNCTION_DECL of a function that's going to be versioned.
References walk_stmt_info::info, NULL, and TREE_CODE.
Referenced by create_dispatcher_calls().
|
static |
Return number of attributes separated by TARGET_CLONES_ATTR_SEPARATOR and put them into ARGS. If there is no DEFAULT attribute return -1. If there is an empty string in attribute return -2. If there are multiple DEFAULT attributes return -3.
References i, NULL, and TARGET_CLONES_ATTR_SEPARATOR.
Referenced by expand_target_clones().