GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "tree-pass.h"
#include "cgraph.h"
Functions | |
tree | propagate_comdat_group (struct symtab_node *symbol, tree newgroup, hash_map< symtab_node *, tree > &map) |
void | enqueue_references (symtab_node **first, symtab_node *symbol) |
bool | set_comdat_group (symtab_node *symbol, void *head_p) |
bool | set_comdat_group_1 (cgraph_node *symbol, void *head_p) |
static unsigned int | ipa_comdats (void) |
ipa_opt_pass_d * | make_pass_ipa_comdats (gcc::context *ctxt) |
void enqueue_references | ( | symtab_node ** | first, |
symtab_node * | symbol ) |
Add all references of SYMBOL that are defined into queue started by FIRST and linked by AUX pointer (unless they are already enqueued). Walk recursively inlined functions.
References symtab_node::aux, symtab_node::definition, dyn_cast(), enqueue_references(), i, is_a(), symtab_node::iterate_reference(), NULL, ipa_ref::referred, and symtab_node::ultimate_alias_target().
Referenced by enqueue_references(), and ipa_comdats().
|
static |
The actual pass with the main dataflow loop.
References symtab_node::alias, symtab_node::aux, symtab_node::call_for_symbol_and_aliases(), symtab_node::decl, DECL_STATIC_CONSTRUCTOR, DECL_STATIC_DESTRUCTOR, symtab_node::dump(), dump_file, dyn_cast(), enqueue_references(), error_mark_node, symtab_node::externally_visible, FOR_EACH_DEFINED_FUNCTION, FOR_EACH_DEFINED_SYMBOL, symtab_node::force_output, gcc_assert, hash_map< KeyId, Value, Traits >::get(), symtab_node::get_comdat_group(), symtab_node::get_section(), IDENTIFIER_POINTER, is_a(), map, NULL, propagate_comdat_group(), hash_map< KeyId, Value, Traits >::put(), symtab_node::real_symbol_p(), set_comdat_group(), set_comdat_group_1(), cgraph_node::thunk, TREE_CODE, TREE_THIS_VOLATILE, symtab_node::ultimate_alias_target(), and symtab_node::used_from_other_partition.
ipa_opt_pass_d * make_pass_ipa_comdats | ( | gcc::context * | ctxt | ) |
tree propagate_comdat_group | ( | struct symtab_node * | symbol, |
tree | newgroup, | ||
hash_map< symtab_node *, tree > & | map ) |
Localize comdats. Copyright (C) 2014-2024 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/>.
This is very simple pass that looks for static symbols that are used exclusively by symbol within one comdat group. In this case it makes sense to bring the symbol itself into the group to avoid dead code that would arrise when the comdat group from current unit is replaced by a different copy. Consider for example: static int q(void) { .... } inline int t(void) { return q(); } if Q is used only by T, it makes sense to put Q into T's comdat group. The pass solve simple dataflow across the callgraph trying to prove what symbols are used exclusively from a given comdat group. The implementation maintains a queue linked by AUX pointer terminated by pointer value 1. Lattice values are NULL for TOP, actual comdat group, or ERROR_MARK_NODE for bottom. TODO: When symbol is used only by comdat symbols, but from different groups, it would make sense to produce a new comdat group for it with anonymous name. TODO2: We can't mix variables and functions within one group. Currently we just give up on references of symbols of different types. We also should handle this by anonymous comdat group section.
Main dataflow loop propagating comdat groups across the symbol table. All references to SYMBOL are examined and NEWGROUP is updated accordingly. MAP holds current lattice values for individual symbols.
References cgraph_node::callers, dyn_cast(), error_mark_node, i, IPA_REF_ALIAS, symtab_node::iterate_referring(), map, cgraph_edge::next_caller, propagate_comdat_group(), ipa_ref::referring, symtab_node::type, and ipa_ref::use.
Referenced by ipa_comdats(), and propagate_comdat_group().
bool set_comdat_group | ( | symtab_node * | symbol, |
void * | head_p ) |
Set comdat group of SYMBOL to GROUP. Callback for for_node_and_aliases.
References symtab_node::add_to_same_comdat_group(), gcc_assert, symtab_node::get_comdat_group(), symtab_node::real_symbol_p(), and symtab_node::set_comdat_group().
Referenced by ipa_comdats(), and set_comdat_group_1().
bool set_comdat_group_1 | ( | cgraph_node * | symbol, |
void * | head_p ) |
Set comdat group of SYMBOL to GROUP. Callback for for_node_thunks_and_aliases.
References set_comdat_group().
Referenced by ipa_comdats().