GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "gimple.h"
#include "tree-inline.h"
#include "tree-pass.h"
#include "pointer-set.h"
#include "splay-tree.h"
#include "ggc.h"
#include "ipa-utils.h"
#include "ipa-reference.h"
#include "flags.h"
#include "diagnostic.h"
#include "data-streamer.h"
#include "lto-streamer.h"
Data Structures | |
struct | ipa_reference_local_vars_info_d |
struct | ipa_reference_global_vars_info_d |
struct | ipa_reference_optimization_summary_d |
struct | ipa_reference_vars_info_d |
Typedefs | |
typedef struct ipa_reference_local_vars_info_d * | ipa_reference_local_vars_info_t |
typedef struct ipa_reference_global_vars_info_d * | ipa_reference_global_vars_info_t |
typedef struct ipa_reference_optimization_summary_d * | ipa_reference_optimization_summary_t |
typedef struct ipa_reference_vars_info_d * | ipa_reference_vars_info_t |
Variables | |
static splay_tree | reference_vars_to_consider |
static bitmap | all_module_statics |
static bitmap_obstack | local_info_obstack |
static bitmap_obstack | optimization_summary_obstack |
static struct cgraph_2node_hook_list * | node_duplication_hook_holder |
static struct cgraph_node_hook_list * | node_removal_hook_holder |
static vec < ipa_reference_vars_info_t > | ipa_reference_vars_vector |
static vec < ipa_reference_optimization_summary_t > | ipa_reference_opt_sum_vector |
typedef struct ipa_reference_global_vars_info_d* ipa_reference_global_vars_info_t |
typedef struct ipa_reference_local_vars_info_d* ipa_reference_local_vars_info_t |
typedef struct ipa_reference_vars_info_d* ipa_reference_vars_info_t |
|
inlinestatic |
Add VAR to all_module_statics and the two reference_vars_to_consider* sets.
|
static |
This is the main routine for finding the reference patterns for global variables within a function FN.
References copy_static_var_set(), get_reference_optimization_summary(), set_reference_optimization_summary(), ipa_reference_optimization_summary_d::statics_not_read, and ipa_reference_optimization_summary_d::statics_not_written.
Referenced by duplicate_node_data().
|
static |
Return a copy of SET on the bitmap obstack containing SET. But if SET is NULL or the maximum set, return that instead.
Referenced by analyze_function().
|
static |
Dump a set of static vars to FILE.
References all_module_statics, and BITMAP_FREE.
|
static |
Called when new clone is inserted to callgraph late.
References analyze_function(), dump_file, EXECUTE_IF_SET_IN_BITMAP, FOR_EACH_DEFINED_FUNCTION, get_static_name(), and ipa_init().
|
static |
Don't bother doing anything if the program has errors.
|
static |
Analyze each function in the cgraph to see which global or statics are read or written.
Process all of the functions next.
References dump_file, and get_static_name().
|
static |
Set READ_ALL/WRITE_ALL based on decl flags of NODE or any member in the cycle of NODE.
When function is overwritable, we can not assume anything.
|
inlinestatic |
Return the ipa_reference_vars structure starting from the cgraph NODE.
Referenced by analyze_function(), ipa_reference_get_not_read_global(), and set_reference_optimization_summary().
|
inlinestatic |
Return the ipa_reference_vars structure starting from the cgraph NODE.
Referenced by remove_node_data().
|
static |
Lookup the tree node for the static variable that has UID and convert the name to a string for debugging.
Referenced by duplicate_node_data(), generate_summary(), and remove_node_data().
|
static |
Set up the persistent info for FN.
Add the info to the tree's annotation.
|
static |
Compute X &= Y, taking into account the possibility that X may become the maximum set.
As with union_static_var_sets, reducing to the maximum set as early as possible is an overall win.
|
static |
The init routine for analyzing global static variable usage. See comments at top for description.
Referenced by duplicate_node_data().
bitmap ipa_reference_get_not_read_global | ( | ) |
Return a bitmap indexed by DECL_UID for the static variables that are not read during the execution of the function FN. Returns NULL if no data is available.
References all_module_statics, symtab_node_base::decl, ECF_LEAF, flags_from_decl_or_type(), get_reference_optimization_summary(), NULL, and ipa_reference_optimization_summary_d::statics_not_written.
bitmap ipa_reference_get_not_written_global | ( | ) |
Return a bitmap indexed by DECL_UID for the static variables that are not written during the execution of the function FN. Note that variables written may or may not be read during the function call. Returns NULL if no data is available.
References bitmap_set_bit, DECL_UID, dump_file, gcc_assert, reference_vars_to_consider, and TREE_CODE.
|
static |
Deserialize the ipa info for lto.
Set the statics not read.
Set the statics not written.
Fatal error here. We do not want to support compiling ltrans units with different version of compiler or different flags than the WPA unit, so this should never happen.
|
static |
Serialize the ipa info for lto.
See what variables we are interested in.
Process all of the functions.
|
inlinestatic |
Return true if the variable T is the right kind of static variable to perform compilation unit scope escape analysis.
If the variable has the "used" attribute, treat it as if it had a been touched by the devil.
Do not want to do anything with volatile except mark any function that uses one to be not const or pure.
We do not need to analyze readonly vars, we already know they do not alias.
This is a variable we care about. Check if we have seen it before, and if not add it the set of variables we care about.
ipa_opt_pass_d* make_pass_ipa_reference | ( | ) |
|
static |
Produce the global information by preforming a transitive closure on the local information that was produced by ipa_analyze_function.
Now we know what vars are really statics; prune out those that aren't.
Forget info we collected "just for fun" on variables that turned out to be non-local.
Propagate the local information through the call graph to produce the global information. All the nodes within a cycle will have the same info so we collapse cycles first. Then we can do the propagation in one pass from the leaves to the roots.
If any node in a cycle is read_all or write_all, they all are.
Initialized the bitmaps global sets for the reduced node.
Merge the sets of this cycle with all sets of callees reached from this cycle.
All nodes within a cycle have the same global info bitmaps.
Cleanup.
Create the complimentary sets.
|
static |
Compute the union all of the statics read and written by every callee of X into X_GLOBAL->statics_read and X_GLOBAL->statics_written. X_GLOBAL is actually the set representing the cycle containing X. If the read and written sets of X_GLOBAL has been reduced to the maximum set, we don't have to look at the remaining callees.
Only look into nodes we can propagate something.
Calls in the current cycle do not have their global set computed yet (but everything else does because we're visiting nodes in topological order).
If the function is const, it reads no memory even if it seems so to local analysis.
If the function is pure, it has no stores even if it seems so to local analysis. If we cannot return from the function, we can safely ignore the call.
|
static |
Set READ_ALL/WRITE_ALL based on decl flags of NODE.
TODO: To be able to produce sane results, we should also handle common builtins, in particular throw.
References AVAIL_OVERWRITABLE, cgraph_edge::callee, cgraph_function_node(), and gcc_checking_assert.
|
static |
Callgraph based analysis of static variables. Copyright (C) 2004-2013 Free Software Foundation, Inc. Contributed by Kenneth Zadeck zadec k@na tural brid ge.co m
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 file gathers information about how variables whose scope is confined to the compilation unit are used.
The transitive call site specific clobber effects are computed for the variables whose scope is contained within this compilation unit.
First each function and static variable initialization is analyzed to determine which local static variables are either read, written, or have their address taken. Any local static that has its address taken is removed from consideration. Once the local read and writes are determined, a transitive closure of this information is performed over the call graph to determine the worst case set of side effects of each call. In later parts of the compiler, these local and global sets are examined to make the call clobbering less traumatic, promote some statics to registers, and improve aliasing information.
|
static |
Called when node is removed.
References cgraph_node_asm_name(), dump_file, EXECUTE_IF_SET_IN_BITMAP, get_reference_vars_info(), get_static_name(), ipa_reference_vars_info_d::local, symtab_node_base::order, ipa_reference_local_vars_info_d::statics_read, and ipa_reference_local_vars_info_d::statics_written.
|
inlinestatic |
Return the ipa_reference_vars structure starting from the cgraph NODE.
References all_module_statics, cgraph_function_node(), symtab_node_base::decl, ECF_LEAF, flags_from_decl_or_type(), get_reference_optimization_summary(), NULL, and ipa_reference_optimization_summary_d::statics_not_read.
Referenced by analyze_function().
|
inlinestatic |
Return the ipa_reference_vars structure starting from the cgraph NODE.
|
static |
Stream out BITS<RANS_STATICS as list of decls to OB. LTRANS_STATICS_BITCOUNT specify number of bits in LTRANS_STATICS or -1. When it is positive, just output -1 when BITS<RANS_STATICS == BITS<RANS_STATICS.
|
static |
Compute X |= Y, taking into account the possibility that either X or Y is already the maximum set. Return true if X is the maximum set after taking the union with Y.
The union may have reduced X to the maximum set. In that case, we want to make that visible explicitly. Even though bitmap_equal_p can be very expensive, it turns out to be an overall win to check this here for an LTO bootstrap of GCC itself. Liberally extrapoliate that result to be applicable to all cases.
References all_module_statics, bitmap_and_into(), bitmap_equal_p(), and BITMAP_FREE.
|
static |
Return true if we need to write summary of NODE.
See if we have (non-empty) info.
See if we want to encode it. Encode also referenced functions since constant folding might turn it into a direct call. In future we might also want to include summaries of functions references by initializers of constant variables references in current unit.
See if the info has non-empty intersections with vars we want to encode.
References lto_simple_output_block::decl_state, lto_output_var_decl_index(), lto_simple_output_block::main_stream, and reference_vars_to_consider.
|
static |
Set of all interesting module statics. A bit is set for every module static we are considering. This is added to the local info when asm code is found that clobbers all memory.
Referenced by dump_static_vars_set_to_file(), ipa_reference_get_not_read_global(), set_reference_optimization_summary(), and union_static_var_sets().
|
static |
|
static |
Vector where the reference var infos are actually stored. Indexed by UID of call graph nodes.
|
static |
Obstack holding bitmaps of local analysis (live from analysis to propagation)
|
static |
Holders of ipa cgraph hooks:
|
static |
|
static |
Obstack holding global analysis live forever.
|
static |
This splay tree contains all of the static variables that are being considered by the compilation level alias analysis.
Referenced by ipa_reference_get_not_written_global(), and write_node_summary_p().