GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "cgraph.h"
#include "langhooks.h"
#include "diagnostic-core.h"
#include "hashtab.h"
#include "ggc.h"
#include "timevar.h"
#include "debug.h"
#include "target.h"
#include "output.h"
#include "gimple.h"
#include "flags.h"
Data Structures | |
struct | varpool_node_hook_list |
Variables | |
struct varpool_node_hook_list * | first_varpool_node_removal_hook |
struct varpool_node_hook_list * | first_varpool_variable_insertion_hook |
tree add_new_static_var | ( | ) |
Create a new global variable of type TYPE.
|
static |
Assemble thunks and aliases associated to NODE.
References targetm.
enum availability cgraph_variable_initializer_availability | ( | ) |
Return variable availability. See cgraph.h for description of individual return values.
If the variable can be overwritten, return OVERWRITABLE. Takes care of at least one notable extension - the COMDAT variables used to share template instantiations in C++.
References align_variable(), cgraph_function_flags_ready, and gcc_assert.
tree ctor_for_folding | ( | ) |
Return if DECL is constant and its initial value is known (so we can do constant folding using DECL_INITIAL (decl)). Return ERROR_MARK_NODE when value is unknown.
Do not care about automatic variables. Those are never initialized anyway, because gimplifier exapnds the code
See if we are dealing with alias. In most cases alias is just alternative symbol pointing to a given constructor. This allows us to use interposition rules of DECL constructor of REAL_NODE. However weakrefs are special by being just alternative name of their target (if defined).
Vtables are defined by their types and must match no matter of interposition rules.
If thre is no constructor, we have nothing to do.
Non-readonly alias of readonly variable is also de-facto readonly, because the variable itself is in readonly section. We also honnor READONLY flag on alias assuming that user knows what he is doing.
Variables declared 'const' without an initializer have zero as the initializer if they may not be overridden at link or run time.
Variables declared `const' with an initializer are considered to not be overwritable with different initializer by default. ??? Previously we behaved so for scalar variables but not for array accesses.
DEBUG_FUNCTION void debug_varpool | ( | void | ) |
Dump the variable pool to stderr.
References error_mark_node, and TREE_CODE.
void dump_varpool | ( | ) |
Dump the variable pool.
References dyn_cast(), NULL, and symtab_node_for_asm().
void dump_varpool_node | ( | ) |
Dump given cgraph node.
References dump_varpool_node(), and FOR_EACH_VARIABLE.
|
static |
Add NODE to queue starting at FIRST. The queue is linked via AUX pointers and terminated by pointer to 1.
References symtab_node_base::analyzed, dyn_cast(), symtab_node_base::next, and symtab_node_base::same_comdat_group.
Referenced by varpool_remove_unreferenced_decls().
void varpool_add_new_variable | ( | ) |
Add the variable DECL to the varpool. Unlike varpool_finalize_decl function is intended to be used by middle end and allows insertion of new variable at arbitrary point of compilation.
|
read |
Register HOOK to be called with DATA on each removed node.
|
read |
Register HOOK to be called with DATA on each inserted node.
void varpool_analyze_node | ( | ) |
When reading back varpool at LTO time, we re-construct the queue in order to have "needed" list right by inserting all needed nodes into varpool. We however don't want to re-analyze already analyzed nodes.
Compute the alignment early so function body expanders are already informed about increased alignment.
bool varpool_assemble_decl | ( | ) |
Output one variable, if necessary. Return whether we output it.
Aliases are outout when their target is produced or by output_weakrefs.
Constant pool is output from RTL land when the reference survive till this level.
Decls with VALUE_EXPR should not be in the varpool at all. They are not real variables, but just info for debugging and codegen. Unfortunately at the moment emutls is not updating varpool correctly after turning real vars into value_expr vars.
Hard register vars do not need to be output.
|
static |
Call all node removal hooks.
Referenced by varpool_node_for_decl().
void varpool_call_variable_insertion_hooks | ( | ) |
Call all node insertion hooks.
References SYMTAB_VARIABLE.
|
read |
Allocate new callgraph node and insert it into basic data structures.
|
read |
Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful. Extra name aliases are output whenever DECL is output.
References AVAIL_OVERWRITABLE, cgraph_variable_initializer_availability(), IPA_REF_ALIAS, ipa_ref_list_referring_iterate, ipa_ref_referring_varpool_node(), symtab_node_base::ref_list, and varpool_for_node_and_aliases().
|
read |
Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful. Extra name aliases are output whenever DECL is output.
If aliases aren't supported by the assembler, fail.
Extra name alias mechanizm creates aliases really late via DECL_ASSEMBLER_NAME mechanizm. This is unfortunate because they are not going through the standard channels. Ensure they get output.
void varpool_finalize_named_section_flags | ( | ) |
For variables in named sections make sure get_variable_section is called before we switch to those sections. Then section conflicts between read-only and read-only requiring relocations sections can be resolved.
bool varpool_for_node_and_aliases | ( | struct varpool_node * | node, |
bool(*)(struct varpool_node *, void *) | callback, | ||
void * | data, | ||
bool | include_overwritable | ||
) |
Call calback on NODE and aliases associated to NODE. When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are skipped.
Referenced by varpool_create_variable_alias().
|
read |
Given an assembler name, lookup node.
|
read |
Return varpool node assigned to DECL. Create new one when needed.
References ctor_for_folding(), symtab_node_base::decl, DECL_INITIAL, error_mark_node, symtab_unregister_node(), varpool_call_node_removal_hooks(), and varpool_remove_initializer().
bool varpool_output_variables | ( | void | ) |
Output all variables enqueued to be assembled.
References symtab_node_base::alias, symtab_node_base::alias_target, symtab_node_base::decl, DECL_ATTRIBUTES, symtab_node_base::definition, gcc_assert, lookup_attribute(), NULL, TREE_CODE, varpool_node_for_decl(), and symtab_node_base::weakref.
void varpool_remove_initializer | ( | ) |
Renove node initializer when it is no longer needed.
Keep vtables for BINFO folding.
FIXME: http://gcc.gnu.org/PR55395
When doing declaration merging we have duplicate entries for given decl. Do not attempt to remove the boides, or we will end up remiving wrong one.
References cgraph_availability_names, cgraph_function_flags_ready, cgraph_variable_initializer_availability(), ctor_for_folding(), symtab_node_base::decl, DECL_INITIAL, dump_symtab_base(), error_mark_node, varpool_node::output, and TREE_READONLY.
void varpool_remove_node | ( | ) |
Remove node from the varpool.
Because we remove references from external functions before final compilation, we may end up removing useful constructors. FIXME: We probably want to trace boundaries better.
void varpool_remove_node_removal_hook | ( | ) |
Remove ENTRY from the list of hooks called on removing nodes.
|
static |
Optimization of function bodies might've rendered some variables as unnecessary so we want to avoid these from being compiled. Re-do reachability starting from variables that are either externally visible or was referred from the asm output routines.
We just expanded all function bodies. See if any of them needed the variable.
References symtab_node_base::alias, symtab_node_base::analyzed, symtab_node_base::decl, DECL_EXTERNAL, dyn_cast(), enqueue_node(), and ipa_ref::referred.
void varpool_remove_variable_insertion_hook | ( | ) |
Remove ENTRY from the list of hooks called on inserted nodes.
References varpool_node_hook_list::data, first_varpool_variable_insertion_hook, varpool_node_hook_list::hook, and varpool_node_hook_list::next.
struct varpool_node_hook_list* first_varpool_node_removal_hook |
List of hooks triggered when a node is removed.
struct varpool_node_hook_list* first_varpool_variable_insertion_hook |
List of hooks triggered when an variable is inserted.
Referenced by varpool_remove_variable_insertion_hook().