GCC Middle and Back End API Reference
multiple_target.cc File Reference
#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"
Include dependency graph for multiple_target.cc:

Functions

static tree replace_function_decl (tree *op, int *walk_subtrees, void *data)
static void create_dispatcher_calls (struct cgraph_node *node)
static cgraph_nodecreate_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 bool is_simple_target_clones_case (cgraph_node *node)
static unsigned int ipa_target_clone (bool early)
simple_ipa_opt_passmake_pass_target_clone (gcc::context *ctxt)

Function Documentation

◆ create_dispatcher_calls()

void create_dispatcher_calls ( struct cgraph_node * node)
static
In target FMV attributes, if the call in NODE has multiple target attribute
with multiple fields, replace it with calls to the dispatched symbol and
create the dispatcher body (once).

In target_version semantics, if it is a lone annotated default, then
the dispatched symbol is changed to be an alias and no resolver is
required.  Otherwise, redirect all calls and references to the dispatched
symbol, but only create the resolver body if the default version is
implemented.   

References symtab_node::add_to_same_comdat_group(), symtab_node::alias, symtab_node::alias_target, symtab_node::analyzed, cgraph_node::callers, symtab_node::create_reference(), symtab_node::decl, DECL_ARTIFICIAL, DECL_ASSEMBLER_NAME, DECL_ATTRIBUTES, DECL_EXTERNAL, 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, IDENTIFIER_POINTER, IPA_REF_ADDR, IPA_REF_ALIAS, symtab_node::iterate_referring(), make_attribute(), symtab_node::make_decl_local(), cgraph_function_version_info::next, NULL, cgraph_edge::redirect_call_stmt_to_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, TARGET_HAS_FMV_TARGET_ATTRIBUTE, targetm, cgraph_function_version_info::this_node, TREE_STATIC, TREE_USED, ipa_ref::use, walk_gimple_stmt(), and walk_tree.

Referenced by ipa_target_clone().

◆ create_target_clone()

cgraph_node * create_target_clone ( cgraph_node * node,
bool definition,
char * name,
tree attributes )
static

◆ expand_target_clones()

◆ ipa_target_clone()

◆ is_simple_target_clones_case()

bool is_simple_target_clones_case ( cgraph_node * node)
static
Checks if NODE is in the 'simple' target_clones case, which is where NODE
is a declaration annotated with target_clones containing the default, and it
is the sole function declaration in the FMV function set.   

References symtab_node::decl, cgraph_node::function_version(), get_clone_versions(), cgraph_function_version_info::next, cgraph_function_version_info::prev, and TARGET_HAS_FMV_TARGET_ATTRIBUTE.

Referenced by ipa_target_clone().

◆ make_pass_target_clone()

simple_ipa_opt_pass * make_pass_target_clone ( gcc::context * ctxt)

◆ redirect_to_specific_clone()

void redirect_to_specific_clone ( cgraph_node * node)
static
When NODE is part of an FMV function set, consider all callees and check if
any can provably always resolve a certain version and then call that version
directly.   

References symtab_node::binds_to_current_def_p(), cgraph_node::callees, symtab_node::decl, gcc_assert, is_function_default_version(), cgraph_function_version_info::next, NULL, cgraph_function_version_info::prev, cgraph_edge::redirect_call_stmt_to_callee(), targetm, and cgraph_function_version_info::this_node.

Referenced by ipa_target_clone().

◆ replace_function_decl()

tree replace_function_decl ( tree * op,
int * walk_subtrees,
void * data )
static
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().