GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "tree.h"
#include "tm_p.h"
#include "hard-reg-set.h"
#include "basic-block.h"
#include "flags.h"
#include "insn-config.h"
#include "reload.h"
#include "sbitmap.h"
#include "alloc-pool.h"
#include "fibheap.h"
#include "hash-table.h"
#include "regs.h"
#include "expr.h"
#include "tree-pass.h"
#include "bitmap.h"
#include "tree-dfa.h"
#include "tree-ssa.h"
#include "cselib.h"
#include "target.h"
#include "params.h"
#include "diagnostic.h"
#include "tree-pretty-print.h"
#include "pointer-set.h"
#include "recog.h"
#include "alias.h"
Data Structures | |
struct | micro_operation_def |
struct | attrs_def |
struct | location_chain_def |
struct | loc_exp_dep_s |
struct | expand_depth_struct |
struct | onepart_aux |
struct | variable_part_def |
union | variable_part_def::variable_aux |
struct | variable_def |
struct | variable_hasher |
struct | emit_note_data_def |
struct | shared_hash_def |
struct | dataflow_set_def |
struct | variable_tracking_info_def |
struct | adjust_mem_data |
struct | overlapping_mems |
struct | variable_union_info |
struct | dfset_merge |
struct | dfset_post_merge |
struct | count_use_info |
struct | expand_loc_callback_data |
Macros | |
#define | MAX_VAR_PARTS 16 |
#define | VTI(BB) ((variable_tracking_info) (BB)->aux) |
#define | INT_MEM_OFFSET(mem) (MEM_OFFSET_KNOWN_P (mem) ? MEM_OFFSET (mem) : 0) |
#define | VAR_PART_OFFSET(var, i) ((var)->var_part[(i)].aux.offset) |
#define | VAR_LOC_1PAUX(var) ((var)->var_part[0].aux.onepaux) |
#define | VAR_LOC_DEP_LST(var) |
#define | VAR_LOC_DEP_LSTP(var) |
#define | VAR_LOC_FROM(var) (VAR_LOC_1PAUX (var)->from) |
#define | VAR_LOC_DEPTH(var) (VAR_LOC_1PAUX (var)->depth) |
#define | VAR_LOC_DEP_VEC(var) |
#define | VALUE_RECURSED_INTO(x) (RTL_FLAG_CHECK2 ("VALUE_RECURSED_INTO", (x), VALUE, DEBUG_EXPR)->used) |
#define | NO_LOC_P(x) (RTL_FLAG_CHECK2 ("NO_LOC_P", (x), VALUE, DEBUG_EXPR)->return_val) |
#define | VALUE_CHANGED(x) (RTL_FLAG_CHECK1 ("VALUE_CHANGED", (x), VALUE)->frame_related) |
#define | DECL_CHANGED(x) TREE_VISITED (x) |
#define | VAL_NEEDS_RESOLUTION(x) (RTL_FLAG_CHECK1 ("VAL_NEEDS_RESOLUTION", (x), CONCAT)->volatil) |
#define | VAL_HOLDS_TRACK_EXPR(x) (RTL_FLAG_CHECK1 ("VAL_HOLDS_TRACK_EXPR", (x), CONCAT)->used) |
#define | VAL_EXPR_IS_COPIED(x) (RTL_FLAG_CHECK1 ("VAL_EXPR_IS_COPIED", (x), CONCAT)->jump) |
#define | VAL_EXPR_IS_CLOBBERED(x) (RTL_FLAG_CHECK1 ("VAL_EXPR_IS_CLOBBERED", (x), CONCAT)->unchanging) |
#define | EXPR_DEPTH (INT_MAX) |
#define | EXPR_USE_DEPTH (PARAM_VALUE (PARAM_MAX_VARTRACK_EXPR_DEPTH)) |
#define | INIT_ELCD(d, v) |
#define | FINI_ELCD(d, l) |
Typedefs | |
typedef struct micro_operation_def | micro_operation |
typedef void * | decl_or_value |
typedef struct attrs_def * | attrs |
typedef struct location_chain_def * | location_chain |
typedef struct loc_exp_dep_s | loc_exp_dep |
typedef struct expand_depth_struct | expand_depth |
typedef struct variable_part_def | variable_part |
typedef enum onepart_enum | onepart_enum_t |
typedef struct variable_def * | variable |
typedef struct variable_def * | const_variable |
typedef unsigned int | dvuid |
typedef hash_table < variable_hasher > | variable_table_type |
typedef variable_table_type::iterator | variable_iterator_type |
typedef struct emit_note_data_def | emit_note_data |
typedef struct shared_hash_def * | shared_hash |
typedef struct dataflow_set_def | dataflow_set |
typedef struct variable_tracking_info_def * | variable_tracking_info |
Enumerations | |
enum | micro_operation_type { MO_USE, MO_USE_NO_VAR, MO_VAL_USE, MO_VAL_LOC, MO_VAL_SET, MO_SET, MO_COPY, MO_CLOBBER, MO_CALL, MO_ADJUST } |
enum | emit_note_where { EMIT_NOTE_BEFORE_INSN, EMIT_NOTE_AFTER_INSN, EMIT_NOTE_AFTER_CALL_INSN } |
enum | onepart_enum { NOT_ONEPART = 0, ONEPART_VDECL = 1, ONEPART_DEXPR = 2, ONEPART_VALUE = 3 } |
Variables | |
char | check_value_val [(int) VALUE==(int) IDENTIFIER_NODE?1:-1] |
static const char *const | micro_operation_type_name [] |
static alloc_pool | attrs_pool |
static alloc_pool | var_pool |
static alloc_pool | valvar_pool |
static alloc_pool | loc_chain_pool |
static alloc_pool | shared_hash_pool |
static alloc_pool | loc_exp_dep_pool |
static variable_table_type | changed_variables |
static bool | emit_notes |
static variable_table_type | dropped_values |
static shared_hash | empty_shared_hash |
static bitmap | scratch_regs = NULL |
static bool | cselib_hook_called |
static rtx | cfa_base_rtx |
static HOST_WIDE_INT | cfa_base_offset |
static HOST_WIDE_INT | hard_frame_pointer_adjustment = -1 |
static bool | dst_can_be_shared |
static struct pointer_map_t * | global_get_addr_cache |
static struct pointer_map_t * | local_get_addr_cache |
static struct variable_union_info * | vui_vec |
static int | vui_allocated |
static vec< rtx > | preserved_values |
static rtx | call_arguments |
static int | debug_label_num = 1 |
#define DECL_CHANGED | ( | x | ) | TREE_VISITED (x) |
Whether cur_loc in the decl needs to be (re)computed.
#define EXPR_DEPTH (INT_MAX) |
This is the value used during expansion of locations. We want it to be unbounded, so that variables expanded deep in a recursion nest are fully evaluated, so that their values are cached correctly. We avoid recursion cycles through other means, and we don't unshare RTL, so excess complexity is not a problem.
Referenced by loc_exp_insert_dep().
#define EXPR_USE_DEPTH (PARAM_VALUE (PARAM_MAX_VARTRACK_EXPR_DEPTH)) |
We use this to keep too-complex expressions from being emitted as location notes, and then to debug information. Users can trade compile time for ridiculously complex expressions, although they're seldom useful, and they may often have to be discarded as not representable anyway.
#define FINI_ELCD | ( | d, | |
l | |||
) |
Finalize expand_loc_callback_data D, resolved to location L.
Referenced by loc_exp_insert_dep().
#define INIT_ELCD | ( | d, | |
v | |||
) |
Initialize expand_loc_callback_data D with variable hash table V. It must be a macro because of alloca (vec stack).
Referenced by loc_exp_insert_dep().
#define INT_MEM_OFFSET | ( | mem | ) | (MEM_OFFSET_KNOWN_P (mem) ? MEM_OFFSET (mem) : 0) |
Macro to access MEM_OFFSET as an HOST_WIDE_INT. Evaluates MEM twice.
#define MAX_VAR_PARTS 16 |
Maximum number of location parts.
#define NO_LOC_P | ( | x | ) | (RTL_FLAG_CHECK2 ("NO_LOC_P", (x), VALUE, DEBUG_EXPR)->return_val) |
Whether no expansion was found, saving useless lookups. It must only be set when VALUE_CHANGED is clear.
Referenced by loc_exp_dep_clear().
#define VAL_EXPR_IS_CLOBBERED | ( | x | ) | (RTL_FLAG_CHECK1 ("VAL_EXPR_IS_CLOBBERED", (x), CONCAT)->unchanging) |
Whether the location in the CONCAT should be handled like a MO_CLOBBER as well.
#define VAL_EXPR_IS_COPIED | ( | x | ) | (RTL_FLAG_CHECK1 ("VAL_EXPR_IS_COPIED", (x), CONCAT)->jump) |
Whether the location in the CONCAT should be handled like a MO_COPY as well.
Referenced by remove_value_from_changed_variables().
#define VAL_HOLDS_TRACK_EXPR | ( | x | ) | (RTL_FLAG_CHECK1 ("VAL_HOLDS_TRACK_EXPR", (x), CONCAT)->used) |
Whether the location in the CONCAT is a tracked expression, that should also be handled like a MO_USE.
#define VAL_NEEDS_RESOLUTION | ( | x | ) | (RTL_FLAG_CHECK1 ("VAL_NEEDS_RESOLUTION", (x), CONCAT)->volatil) |
Tell whether the CONCAT used to holds a VALUE and its location needs value resolution, i.e., an attempt of mapping the location back to other incoming values.
#define VALUE_CHANGED | ( | x | ) | (RTL_FLAG_CHECK1 ("VALUE_CHANGED", (x), VALUE)->frame_related) |
Whether cur_loc in the value needs to be (re)computed.
#define VALUE_RECURSED_INTO | ( | x | ) | (RTL_FLAG_CHECK2 ("VALUE_RECURSED_INTO", (x), VALUE, DEBUG_EXPR)->used) |
Whether the value is currently being expanded.
Referenced by canonicalize_values_star(), dataflow_set_union(), and loc_exp_dep_clear().
#define VAR_LOC_1PAUX | ( | var | ) | ((var)->var_part[0].aux.onepaux) |
#define VAR_LOC_DEP_LST | ( | var | ) |
These are accessor macros for the one-part auxiliary data. When convenient for users, they're guarded by tests that the data was allocated.
#define VAR_LOC_DEP_LSTP | ( | var | ) |
#define VAR_LOC_DEP_VEC | ( | var | ) |
#define VAR_LOC_DEPTH | ( | var | ) | (VAR_LOC_1PAUX (var)->depth) |
#define VAR_LOC_FROM | ( | var | ) | (VAR_LOC_1PAUX (var)->from) |
Referenced by get_addr_from_local_cache(), and variable_post_merge_perm_vals().
#define VAR_PART_OFFSET | ( | var, | |
i | |||
) | ((var)->var_part[(i)].aux.offset) |
Referenced by canonicalize_values_star(), and dataflow_set_copy().
#define VTI | ( | BB | ) | ((variable_tracking_info) (BB)->aux) |
Pointer to the BB's information specific to variable tracking pass.
Referenced by find_src_set_src(), vt_add_function_parameter(), and vt_get_decl_and_offset().
Description of location of a part of a variable. The content of a physical register is described by a chain of these structures. The chains are pretty short (usually 1 or 2 elements) and thus chain is the best data structure.
typedef struct variable_def* const_variable |
typedef struct dataflow_set_def dataflow_set |
Structure holding the IN or OUT set for a basic block.
typedef void* decl_or_value |
A declaration of a variable, or an RTL value being handled like a declaration.
typedef unsigned int dvuid |
typedef struct emit_note_data_def emit_note_data |
Structure for passing some other parameters to function emit_note_insn_var_location.
typedef struct expand_depth_struct expand_depth |
This data structure holds information about the depth of a variable expansion.
typedef struct loc_exp_dep_s loc_exp_dep |
A vector of loc_exp_dep holds the active dependencies of a one-part DV on VALUEs, i.e., the VALUEs expanded so as to form the current location of DV. Each entry is also part of VALUE' s linked-list of backlinks back to DV.
typedef struct location_chain_def * location_chain |
Structure for chaining the locations.
typedef struct micro_operation_def micro_operation |
Structure holding information about micro operation.
typedef enum onepart_enum onepart_enum_t |
Enumeration type used to discriminate various types of one-part variables.
typedef struct shared_hash_def * shared_hash |
Structure holding a refcounted hash table. If refcount > 1, it must be first unshared before modified.
typedef struct variable_def * variable |
Structure describing where the variable is located.
typedef variable_table_type::iterator variable_iterator_type |
typedef struct variable_part_def variable_part |
Structure describing one part of variable.
typedef hash_table<variable_hasher> variable_table_type |
typedef struct variable_tracking_info_def * variable_tracking_info |
The structure (one for each basic block) containing the information needed for variable tracking.
enum emit_note_where |
enum micro_operation_type |
enum onepart_enum |
|
static |
Add stores (register and memory references) LOC which will be tracked to VTI (bb)->mos. EXPR is the RTL expression containing the store. CUIP->insn is instruction which the LOC is part of.
If this is an instruction copying (part of) a parameter passed by invisible reference to its register location, pretend it's a SET so that the initial memory location is discarded, as the parameter register can be reused for other purposes and we do not track locations based on generic registers.
Avoid the mode mismatch between oexpr and expr. No point in duplicating.
No point in duplicating.
The loc of a MO_VAL_SET may have various forms: (concat val dst): dst now holds val (concat val (set dst src)): dst now holds val, copied from src (concat (concat val dstv) dst): dst now holds val; dstv is dst after replacing mems and non-top-level regs with values. (concat (concat val dstv) (set dst src)): dst now holds val, copied from src. dstv is a value-based representation of dst, if it differs from dst. If resolution is needed, src is a REG, and its mode is the same as that of val. (concat (concat val (set dstv srcv)) (set dst src)): src copied to dst, holding val. dstv and srcv are value-based representations of dst and src, respectively.
References BITS_PER_WORD, cselib_lookup(), cselib_preserved_value_p(), GET_MODE, GET_MODE_BITSIZE, GET_MODE_CLASS, GET_MODE_WIDER_MODE, NULL_RTX, REG_P, simplify_subreg(), and cselib_val_struct::val_rtx.
|
static |
|
static |
Add uses (register and memory references) LOC which will be tracked to VTI (bb)->mos. INSN is instruction which the LOC is part of.
For constants don't look up any value.
The loc of a MO_VAL_USE may have two forms: (concat val src): val is at src, a value-based representation. (concat (concat val use) src): same as above, with use as the MO_USE tracked value, if it differs from src.
|
static |
|
static |
Helper function for finding all uses of REG/MEM in X in insn INSN.
|
static |
Callback for cselib_record_sets_hook, that records as micro operations uses and stores in an insn after cselib_record_sets has analyzed the sets in an insn, but before it modifies the stored values in the internal tables, unless cselib_record_sets doesn't call it directly (perhaps because we're not doing cselib in the first place, in which case sets and n_sets will be 0).
Order the MO_USEs to be before MO_USE_NO_VARs and MO_VAL_USE, and MO_VAL_LOC last.
This will record NEXT_INSN (insn), such that we can insert notes before it without worrying about any notes that MO_USEs might emit after the insn.
Order the MO_VAL_USEs first (note_stores does nothing on DEBUG_INSNs, so there are no MO_VAL_LOCs from this insn), then MO_CLOBBERs, then MO_SET/MO_COPY/MO_VAL_SET.
|
static |
Simplify INSN. Remove all {PRE,POST}_{INC,DEC,MODIFY} rtxes, replace them with their value in the insn and add the side-effects as other sets to the insn.
inline-asm with multiple sets is tiny bit more complicated, because the 3 vectors in ASM_OPERANDS need to be shared between all ASM_OPERANDS in the instruction. adjust_mems will not touch ASM_OPERANDS other than the first one, asm_noperands test above needs to be called before that (otherwise it would fail) and afterwards this code fixes it up.
For read-only MEMs containing some constant, prefer those constants.
Referenced by vt_get_decl_and_offset().
|
static |
Helper function for replacement of stores.
|
static |
Helper function for replacement of uses.
References COND_EXEC_CODE, GET_CODE, PATTERN, and XVECLEN.
|
static |
Helper function for adjusting used MEMs.
Don't do any sp or fp replacements outside of MEM addresses on the LHS.
First try without delegitimization of whole MEMs and avoid_constant_pool_reference, which is more likely to succeed.
Don't do any replacements in second and following ASM_OPERANDS of inline-asm with multiple sets. ASM_OPERANDS_INPUT_VEC, ASM_OPERANDS_INPUT_CONSTRAINT_VEC and ASM_OPERANDS_LABEL_VEC need to be equal between all the ASM_OPERANDs in the insn and adjust_insn will fix this up.
|
static |
Referenced by dv_from_value().
|
static |
Make the list *LISTP empty.
References hash_table< Descriptor, Allocator >::dispose(), gcc_checking_assert, shared_hash_def::htab, pool_free(), shared_hash_def::refcount, and shared_hash_pool.
|
static |
Copy all nodes from SRC and create a list *DSTP of the copies.
|
static |
Insert the triplet DECL, OFFSET, LOC to the list *LISTP.
Referenced by canonicalize_values_star(), and debug_dv().
|
static |
|
static |
Return true if the pair of DECL and OFFSET is the member of the LIST.
References hash_table< Descriptor, Allocator >::find_slot_with_hash(), shared_hash_htab(), shared_hash_shared(), and shared_hash_unshare().
|
static |
Combine nodes that are not onepart nodes from SRC and SRC2 into *DSTP.
References CSELIB_VAL_PTR.
|
static |
Add all nodes from SRC which are not in *DSTP to *DSTP.
References hash_table< Descriptor, Allocator >::find_with_hash(), and shared_hash_htab().
Referenced by dump_attrs_list().
|
inlinestatic |
Return true if TVAL is better than CVAL as a canonival value. We choose lowest-numbered VALUEs, using the RTX address as a tie-breaker. The idea is to arrange them into a star topology, such that all of them are at most one step away from the canonical value, and the canonical value has backlinks to all of them, in addition to all the actual locations. We don't enforce this topology throughout the entire dataflow analysis, though.
int canonicalize_values_mark | ( | ) |
Mark with VALUE_RECURSED_INTO values that have neighbors that are more likely to be chosen as canonical for an equivalence set. Ensure less likely values can reach more likely neighbors, making the connections bidirectional.
int canonicalize_values_star | ( | ) |
Remove redundant entries from equivalence lists in onepart variables, canonicalizing equivalence sets into star shapes.
Keep it marked so that we revisit it, either after visiting a child node, or after visiting a new parent that might be found out.
The canonical value was reset and dropped. Remove it.
Push values to the canonical one.
If it could have been a local minimum, it's not any more, since it's now neighbor to cval, so it may have to push to it. Conversely, if it wouldn't have prevailed over val, then whatever mark it has is fine: if it was to push, it will now push to a more canonical node, but if it wasn't, then it has already pushed any values it might have to.
Make sure we visit node->loc by ensuring we cval is visited too.
If we have no need to "recurse" into this node, it's already "canonicalized", so drop the link to the old parent.
Change an existing attribute referring to dv so that it refers to cdv, removing any duplicate this might introduce, and checking that no previous duplicates existed, all in a single pass.
Variable may have been unshared.
References attrs_list_insert(), delete_slot_part(), dfset_merge::dst, dst_can_be_shared, attrs_def::dv, variable_def::dv, dv_as_value(), dv_from_value(), dv_htab_hash(), dv_is_value_p(), gcc_assert, gcc_checking_assert, GET_CODE, GET_MODE, location_chain_def::init, intersect_loc_chains(), attrs_def::loc, location_chain_def::loc, variable_def::n_var_parts, attrs_def::next, location_chain_def::next, NULL, NULL_RTX, onepart_pool(), ONEPART_VALUE, onepart_variable_different_p(), pool_alloc(), variable_def::refcount, REGNO, dataflow_set_def::regs, set_slot_part(), set_variable_part(), shared_hash_find_1(), shared_hash_find_slot_noinsert(), shared_hash_find_slot_noinsert_1(), shared_hash_find_slot_unshare(), shared_hash_find_slot_unshare_1(), shared_hash_shared(), dfset_merge::src, dfset_merge::src_onepart_cnt, VALUE_RECURSED_INTO, VAR_LOC_1PAUX, VAR_PART_OFFSET, variable_union(), and dataflow_set_def::vars.
int canonicalize_vars_star | ( | ) |
Bind one-part variables to the canonical value in an equivalence set. Not doing this causes dataflow convergence failure in rare circumstances, see PR42873. Unfortunately we can't do this efficiently as part of canonicalize_values_star, since we may not have determined or even seen the canonical value of a set when we get to a variable that references another member of the set.
Push values to the canonical one.
CVAL is canonical if its value list contains non-VALUEs or VALUEs that are not “more canonical” than it.
CVAL was found to be non-canonical. Change the variable to point to the canonical VALUE.
|
static |
Remove from SET all VALUE bindings to MEMs that overlap with LOC.
References NULL, and vt_get_canonicalize_base().
Referenced by drop_overlapping_mem_locs().
|
static |
Remove all recorded register locations for the given variable part from dataflow set SET, except for those that are identical to loc. The variable part is specified by variable's declaration or value DV and offset OFFSET.
Remove the register locations from the dataflow set.
Remove the variable part from the register's list, but preserve any other variable parts that might be regarded as live in that same register.
|
static |
Remove all recorded register locations for the given variable part from dataflow set SET, except for those that are identical to loc. The variable part is specified by variable's declaration or value DV and offset OFFSET.
|
static |
|
static |
Compute the changes of variable locations in the basic block BB.
|
inlinestatic |
Compute a CFA-based value for an ADJUSTMENT made to stack_pointer_rtx or hard_frame_pointer_rtx.
|
static |
Return true if RTL X contains a SYMBOL_REF.
References GET_CODE.
|
static |
Just checking stuff and registering register attributes for now.
|
static |
|
static |
Delete the contents of dataflow set SET.
|
static |
Remove all variable-location information about call-clobbered registers, as well as associations between MEMs and VALUEs.
|
static |
|
static |
Copy the contents of dataflow set SRC to DST.
References location_chain_def::loc, location_chain_def::next, REG_P, and VAR_PART_OFFSET.
|
static |
|
static |
Free the contents of dataflow set SET.
References cselib_lookup(), get_address_mode(), GET_MODE, NULL, replace_equiv_address_nv(), cselib_val_struct::val_rtx, and XEXP.
|
static |
|
static |
Return true if dataflow sets OLD_SET and NEW_SET differ.
No need to traverse the second hashtab, if both have the same number of elements and the second one had all entries found in the first one, then it can't have any extra entries.
|
static |
Mark register equivalences.
If the list is empty or one entry, no need to canonicalize anything.
References attrs_def::dv, dv_as_value(), location_chain_def::init, NULL, and set_variable_part().
|
static |
|
static |
Initialize dataflow set SET to be empty. VARS_SIZE is the initial size of hash table VARS.
References location_chain_def::loc, location_chain_def::next, REG_P, REGNO, and rtx_equal_p().
|
static |
Combine dataflow set information from SRC2 into DST, using PDST to carry over information across passes.
int dataflow_set_preserve_mem_locs | ( | ) |
Remove all MEMs from the location list of a hash table entry for a one-part variable, except those whose MEM attributes map back to the variable itself, directly or within a VALUE.
We want to remove dying MEMs that doesn't refer to DECL.
We want to move here MEMs that do refer to DECL.
??? This picks up only one out of multiple MEMs that refer to the same variable. Do we ever need to be concerned about dealing with more than one, or, given that they should all map to the same variable location, their addresses will have been merged and they will be regarded as equivalent?
References dump_file, and dump_var().
int dataflow_set_remove_mem_locs | ( | ) |
Remove all MEMs from the location list of a hash table entry for a value.
If we have deleted the location which was last emitted we have to emit new location so add the variable to set of changed variables.
|
static |
|
static |
Compute union of dataflow sets SRC and DST and store it to DST.
References intersect_loc_chains(), location_chain_def::loc, and VALUE_RECURSED_INTO.
void debug_dv | ( | decl_or_value | dv | ) |
DEBUG_FUNCTION void debug_dv | ( | ) |
References attrs_list_insert(), attrs_def::dv, dv_onepart_p(), attrs_def::loc, and attrs_def::offset.
|
static |
Get rid of all debug insns from the insn stream.
|
static |
Delete the part of variable's location from dataflow set SET. The variable part is specified by its SET->vars slot SLOT and offset OFFSET and the part's location by LOC.
If the variable contains the location part we have to make a copy of the variable.
Delete the location part. If we have deleted the location which was last emitted we have to emit new location so add the variable to set of changed variables.
References expand_depth_struct::complexity, expand_depth_struct::entryvals, and GET_CODE.
Referenced by canonicalize_values_star().
|
static |
Delete the part of variable's location from dataflow set SET. The variable part is specified by variable's declaration or value DV and offset OFFSET and the part's location by LOC.
int drop_overlapping_mem_locs | ( | ) |
Remove all MEMs that overlap with COMS->LOC from the location list of a hash table entry for a value. COMS->ADDR must be a canonicalized form of COMS->LOC's address, and COMS->LOC must be canonicalized itself.
If we have deleted the location which was last emitted we have to emit new location so add the variable to set of changed variables.
References canonical_cselib_val(), clobber_overlapping_mems(), CSELIB_VAL_PTR, dv_from_value(), GET_CODE, elt_loc_list::loc, cselib_val_struct::locs, elt_loc_list::next, NULL_RTX, VAR_INIT_STATUS_INITIALIZED, var_mem_decl_set(), and XEXP.
|
static |
|
static |
Print the content of the LIST to dump file.
References canon_value_cmp(), and location_chain_def::loc.
|
static |
|
static |
Print the dataflow set SET to dump file.
|
static |
Print the IN and OUT sets for each basic block to dump file.
References shared_var_p(), and unshare_variable().
|
static |
Referenced by dataflow_set_preserve_mem_locs().
|
static |
Print the information about variable VAR to dump file.
References location_chain_def::loc, and REGNO.
int dump_var_tracking_slot | ( | ) |
Print the information about variable *SLOT to dump file.
Continue traversing the hash table.
|
static |
|
static |
Print the information about variables from hash table VARS to dump file.
|
inlinestatic |
Return the decl in the decl_or_value.
|
inlinestatic |
Return the opaque pointer in the decl_or_value.
|
inlinestatic |
Return the DEBUG_EXPR of a DEBUG_EXPR_DECL or the VALUE in DV.
|
inlinestatic |
Return the value in the decl_or_value.
References attrs_def::next.
Referenced by canonicalize_values_star(), dataflow_set_equiv_regs(), val_bind(), and var_mem_decl_set().
|
inlinestatic |
Return true if DV needs to have its cur_loc recomputed.
References gcc_assert, GET_MODE, loc_cmp(), MEM_P, and XEXP.
Referenced by loc_exp_dep_clear().
|
inlinestatic |
Build a decl_or_value out of a decl.
Referenced by shared_hash_find().
|
inlinestatic |
Return a value or the decl of a debug_expr as a decl_or_value.
Referenced by loc_exp_dep_clear().
|
inlinestatic |
Build a decl_or_value out of a value.
References attrs_list_clear(), attrs_pool, attrs_def::dv, attrs_def::loc, attrs_def::next, attrs_def::offset, and pool_alloc().
Referenced by canonicalize_values_star(), drop_overlapping_mem_locs(), unsuitable_loc(), and val_bind().
|
inlinestatic |
The hash function for a mask table in a shared_htab chain.
References variable_def::refcount.
Referenced by canonicalize_values_star(), shared_hash_find_slot_unshare(), and vt_find_locations().
|
inlinestatic |
Return true if a decl_or_value DV is a DECL or NULL.
References gcc_checking_assert.
|
inlinestatic |
Return true if a decl_or_value is a VALUE rtl.
References gcc_checking_assert.
Referenced by canonicalize_values_star(), and val_bind().
|
inlinestatic |
Return nonzero if a decl_or_value must not have more than one variable part. The returned value discriminates among various kinds of one-part DVs ccording to enum onepart_enum.
References attrs_pool, attrs_def::next, NULL, and pool_free().
Referenced by debug_dv().
|
inlinestatic |
Return the uid of DV.
|
inlinestatic |
Compute the hash from the uid.
int emit_note_insn_var_location | ( | ) |
Emit the NOTE_INSN_VAR_LOCATION for variable *VARP. DATA contains additional parameters: WHERE specifies whether the note shall be emitted before or after instruction INSN.
Attempt to merge adjacent registers or memory.
Make sure that the call related notes come first.
Continue traversing the hash table.
|
static |
Emit NOTE_INSN_VAR_LOCATION note for each variable from a chain CHANGED_VARIABLES and delete this chain. WHERE specifies whether the notes shall be emitted before of after instruction INSN.
References hash_table< Descriptor, Allocator >::create(), create_alloc_pool(), cselib_get_next_uid(), dropped_values, and loc_exp_dep_pool.
|
static |
Emit notes before INSN for differences between dataflow sets OLD_SET and NEW_SET.
int emit_notes_for_differences_1 | ( | ) |
Add variable *SLOT to the chain CHANGED_VARIABLES if it differs from the same variable in hash table DATA or is not there at all.
Variable has disappeared.
Propagate the auxiliary data to (ultimately) changed_variables.
Continue traversing the hash table.
Update cur_loc and one-part auxiliary data, before new_var goes through variable_was_changed.
Continue traversing the hash table.
int emit_notes_for_differences_2 | ( | ) |
Add variable *SLOT to the chain CHANGED_VARIABLES if it is not in hash table DATA.
Continue traversing the hash table.
References arg_pointer_rtx, GET_CODE, INTVAL, plus_constant(), replace_equiv_address_nv(), and XEXP.
|
static |
|
static |
Emit the notes for changes of location parts in the basic block BB.
If expansion is successful, keep it in the list.
Otherwise, if the following item is data_value for it, drop it too too.
Just drop this item.
|
static |
|
static |
Return a location list node whose loc is rtx_equal to LOC, in the location list of a one-part variable or value VAR, or in that of any values recursively mentioned in the location lists. VARS must be in star-canonical form.
Since we're in star-canonical form, we don't need to visit non-canonical nodes: one-part variables and non-canonical values would only point back to the canonical node.
Skip all subsequent VALUEs.
??? Gotta look in cselib_val locations too.
|
static |
Return a node whose loc is a MEM that refers to EXPR in the location list of a one-part variable or value VAR, or in that of any values recursively mentioned in the location lists.
|
static |
SRC is the source of an assignment. Use SET to try to find what was ultimately assigned to SRC. Return that value if known, otherwise return SRC itself.
References bitmap_bit_p, bitmap_clear(), bitmap_clear_bit(), bitmap_set_bit, changed, hash_table< Descriptor, Allocator >::elements(), first, gcc_assert, MAY_HAVE_DEBUG_INSNS, NULL, shared_hash_htab(), hash_table< Descriptor, Allocator >::size(), dataflow_set_def::vars, VTI, and worklist.
Referenced by remove_value_from_changed_variables().
|
static |
Referenced by remove_value_from_changed_variables().
|
inlinestatic |
Find a VALUE corresponding to X.
This is called after uses are set up and before stores are processed by cselib, so it's safe to look up srcs, but not dsts. So we look up expressions that appear in srcs or in dest expressions, but we search the sets array for dests of stores.
Some targets represent memset and memcpy patterns by (set (mem:BLK ...) (reg:[QHSD]I ...)) or (set (mem:BLK ...) (const_int ...)) or (set (mem:BLK ...) (mem:BLK ...)). Don't return anything in that case, otherwise we end up with mode mismatches.
|
inlinestatic |
Look for the index in VAR->var_part corresponding to OFFSET. Return -1 if not found. If INSERTION_POINT is non-NULL, the referenced int will be set to the index that the part has or should have, if it should be inserted.
Find the location part.
References location_chain_def::loc, REG_P, REGNO, rtx_equal_p(), unshare_variable(), and VAR_INIT_STATUS_UNKNOWN.
|
static |
|
static |
Return the canonical address for LOC, that must be a VALUE, using a cached global equivalence or computing it and storing it in the global cache.
Tentative, avoiding infinite recursion.
The table may have moved during recursion, recompute SLOT.
|
static |
Return the canonical address for LOC, that must be a VALUE, using a cached local equivalence or computing it and storing it in the local cache.
Tentative, avoiding infinite recursion.
Recurse to cache local expansion of X, or if we need to search for a VALUE in the expansion.
Look for an improved equivalent expression.
References changed, gcc_assert, location_chain_def::loc, loc_chain_pool, variable_def::n_var_parts, location_chain_def::next, NULL, pool_free(), shared_var_p(), unshare_variable(), VAR_INIT_STATUS_UNKNOWN, VAR_LOC_1PAUX, VAR_LOC_FROM, variable_was_changed(), and vt_canon_true_dep().
|
static |
|
static |
|
static |
Initialize the set (array) SET of attrs to empty lists.
References shared_hash_def::refcount.
|
static |
Insert LOC in *DNODE, if it's not there yet. The list must be in loc_cmp order, and it is maintained as such.
|
static |
Given an INSN, calculate the amount of stack adjustment it contains PRE- and POST-modifying stack pointer.
There may be stack adjustments inside compound insns. Search for them.
Referenced by vt_get_decl_and_offset().
|
static |
Insert in DEST the intersection of the locations present in both S1NODE and S2VAR, directly or indirectly. S1NODE is from a variable in DSM->cur, whereas S2VAR is from DSM->src. dvar is in DSM->dst.
??? gotta look in cselib_val locations too. ??? if the location is equivalent to any location in src, searched recursively add to dst the values needed to represent the equivalence
telling whether locations S is equivalent to another dv's location list:
for each location D in the list
if S and D satisfy rtx_equal_p, then it is present
else if D is a value, recurse without cycles
else if S and D have the same CODE and MODE
for each operand oS and the corresponding oD
if oS and oD are not equivalent, then S an D are not equivalent
else if they are RTX vectors
if any vector oS element is not equivalent to its respective oD, then S and D are not equivalent
References gcc_assert, location_chain_def::loc, variable_def::n_var_parts, location_chain_def::next, and NULL.
Referenced by canonicalize_values_star(), and dataflow_set_union().
Referenced by dv_changed_p().
|
static |
Return -1 if X should be before Y in a location list for a 1-part variable, 1 if Y should be before X, and 0 if they're equivalent and should not appear in the list.
Don't assert the modes are the same, that is true only when not recursing. (subreg:QI (value:SI 1:1) 0) and (subreg:QI (value:DI 2:2) 0) can be compared, even when the modes are different.
Entry value is the least preferable kind of expression. Compare operands below.
Compare the vector length first.
Compare the vectors elements.
These are just backpointers, so they don't matter.
It is believed that rtx's at this level will never contain anything but integers and other rtx's, except for within LABEL_REFs and SYMBOL_REFs.
|
static |
Allocate the one-part auxiliary data structure for VAR, with enough room for COUNT dependencies.
We can be called with COUNT == 0 to allocate the data structure without any dependencies, e.g. for the backlinks only. However, if we are specifying a COUNT, then the dependency list must have been emptied before. It would be possible to adjust pointers or force it empty here, but this is better done at an earlier point in the algorithm, so we instead leave an assertion to catch errors.
If the reallocation moves the onepaux structure, the back-pointer to BACKLINKS in the first list member will still point to its old location. Adjust it.
|
static |
|
static |
Remove all entries from the vector of active dependencies of VAR, removing them from the back-links lists too.
References variable_def::dv, dv_changed_p(), dv_from_rtx(), gcc_checking_assert, NO_LOC_P, set_dv_changed(), and VALUE_RECURSED_INTO.
|
static |
Create active dependencies of VAR on COUNT values starting at VALUE, and corresponding back-links to the entries in VARS. Return true if we found any pending-recursion results.
Set up all dependencies from last_child (as set up at the end of the loop above) to the end.
|
static |
Insert an active dependency from VAR on X to the vector of dependencies, and add the corresponding back-link to X's list of back-links in VARS.
??? Build a vector of variables parallel to EXPANDING, to avoid an additional look up?
No point in adding the same backlink more than once. This may arise if say the same value appears in two complex expressions in the same loc_list, or even more than once in a single expression.
References cselib_expand_value_rtx_cb(), EXPR_DEPTH, FINI_ELCD, INIT_ELCD, MAY_HAVE_DEBUG_INSNS, scratch_regs, and vt_expand_loc_callback().
|
static |
Clear (canonical address) slots that reference X.
|
inlinestatic |
Log to OUT information about micro-operation MOPT involving X in INSN of BB.
References count_use_info::bb, and NULL.
Referenced by vt_add_function_parameter(), and vt_get_decl_and_offset().
rtl_opt_pass* make_pass_variable_tracking | ( | ) |
|
static |
Return TRUE if the value of MEM may vary across a call.
|
static |
Return true if I is the negated value of a power of two.
Referenced by var_reg_decl_set(), and var_regno_delete().
|
static |
Return the next insn after INSN that is not a NOTE_INSN_VAR_LOCATION.
|
static |
Helper function for MO_VAL_LOC handling. Return non-zero if any rtxes not suitable for CONST use not replaced by VALUEs are discovered.
|
static |
If VAL (a value or debug_expr) has backlinks to variables actively dependent on it in HTAB or in CHANGED_VARIABLES, mark them as changed, adding to CHANGED_VALUES_STACK any dependencies that may have dependencies of their own to notify.
Deactivate and remove the backlink, as it was “used up”. It makes no sense to attempt to notify the same entity again: either it will be recomputed and re-register an active dependency, or it will still have the changed mark.
|
static |
Notify the back-links of IVAR that are pending recursion that we have found a non-NIL value for it, so they are cleared for another attempt to compute a current location.
If we have already resolved it, leave it alone.
Check that VALUE_RECURSED_INTO, true from the test above, implies NO_LOC_P.
We won't notify variables that are being expanded, because their dependency list is cleared before recursing.
|
inlinestatic |
Return the variable pool to be used for a dv of type ONEPART.
Referenced by canonicalize_values_star(), and vt_find_locations().
Referenced by canonicalize_values_star().
|
static |
Return true if one-part variables VAR1 and VAR2 are different. They must be in canonical order.
|
static |
Compute call_arguments.
Can't do anything for these, if the original type mode isn't known or can't be converted.
For non-integer stack argument see also if they weren't initialized by integers.
Try harder, when passing address of a constant pool integer it can be easily read back.
Add debug arguments.
Reverse call_arguments chain.
Don't record anything.
Referenced by record_entry_value().
|
static |
Ensure VAL is preserved and remember it in a vector for vt_emit_notes.
References GET_CODE, micro_operation_def::loc, MO_SET, NULL, SET, SET_DEST, SET_SRC, micro_operation_def::type, micro_operation_def::u, and var_lowpart().
|
static |
Take out of changed_variables any entries that don't refer to use variables. Back-propagate change notifications from values and debug_exprs to their active dependencies in HTAB or in CHANGED_VARIABLES.
Move values from changed_variables to changed_values_stack.
Back-propagate change notifications in values while popping them from the stack.
This condition will hold when visiting each of the entries originally in changed_variables. We can't remove them earlier because this could drop the backlinks before we got a chance to use them.
|
static |
Record the value for the ENTRY_VALUE of RTL as a global equivalence of VAL.
References CALL_P, cselib_process_insn(), dump_cselib_table(), dump_file, dump_flags, prepare_call_arguments(), and print_rtl_single().
|
staticread |
Recover the one-part aux from dropped_values.
Referenced by vt_find_locations().
|
static |
Remove any redundant values in the location list of VAR, which must be unshared and 1-part.
Remove duplicate value node.
|
static |
Remove from changed_variables the entry whose DV corresponds to value or debug_expr VAL.
References find_src_set_src(), find_src_status(), GET_CODE, NULL, REG_P, SET, SET_DEST, SET_SRC, VAL_EXPR_IS_COPIED, and VAR_INIT_STATUS_INITIALIZED.
|
static |
Replace all registers and addresses in an expression with VALUE expressions that map back to them, unless the expression is a register. If no mapping is or can be performed, returns NULL.
|
static |
While expanding variables, we may encounter recursion cycles because of mutual (possibly indirect) dependencies between two particular variables (or values), say A and B. If we're trying to expand A when we get to B, which in turn attempts to expand A, if we can't find any other expansion for B, we'll add B to this pending-recursion stack, and tentatively return NULL for its location. This tentative value will be used for any other occurrences of B, unless A gets some other location, in which case it will notify B that it is worth another try at computing a location for it, and it will use the location computed for A then. At the end of the expansion, the tentative NULL locations become final for all members of PENDING that didn't get a notification. This function performs this finalization of NULL locations.
|
static |
Attempt to reverse the EXPR operation in the debug info and record it in the cselib table. Say for reg1 = reg2 + 6 even when reg2 is no longer live we can express its value as VAL - 6.
Use canonical V to avoid creating multiple redundant expressions for different VALUES equivalent to V.
Adding a reverse op isn't useful if V already has an always valid location. Ignore ENTRY_VALUE, while it is always constant, we should prefer non-ENTRY_VALUE locations whenever possible.
Avoid creating too large locs lists.
Ensure ret isn't VALUE itself (which can happen e.g. for (plus (reg1) (reg2)) when reg2 is known to be 0), as that breaks a lot of routines during var-tracking.
References aggregate_value_p(), build_pointer_type(), CALL_INSN_FUNCTION_USAGE, get_call_rtx_from(), GET_CODE, GET_MODE, INTEGRAL_TYPE_P, list_length(), MEM_EXPR, MEM_P, NULL, NULL_RTX, NULL_TREE, REG_P, SYMBOL_REF_DECL, targetm, TREE_CHAIN, TREE_CODE, TREE_OPERAND, TREE_TYPE, TREE_VALUE, TYPE_ARG_TYPES, TYPE_MODE, void_list_node, and XEXP.
|
static |
Return true if *X is a DEBUG_EXPR. Usable as an argument to for_each_rtx to tell whether there are any DEBUG_EXPRs within RTX.
|
static |
|
static |
Determine whether a given LOC refers to the same variable part as EXPR+OFFSET.
References cselib_preserve_value(), and cselib_val_struct::val_rtx.
|
static |
Referenced by loc_exp_dep_clear(), and vt_find_locations().
|
inlinestatic |
Record (if NEWV) that DV needs to have its cur_loc recomputed. For user DECLs, this means they're in changed_variables. Values and debug exprs may be left with this flag set if no user variable requires them to be evaluated.
Fall through...
References gcc_assert, GET_CODE, GET_MODE, MEM_P, REG_P, REGNO, and RTX_CODE.
|
static |
Create new variable information.
LOC is in the beginning of the chain so we have nothing to do.
We have to make a copy of a shared variable.
We have not found the location part, new one will be created.
We have to make a copy of the shared variable.
We track only variables whose size is <= MAX_VAR_PARTS bytes thus there are at most MAX_VAR_PARTS different offsets.
We have to move the elements of array starting at index inspos to the next position.
Delete the location from the list.
Save these values, to assign to the new node, before deleting this one.
Add the location to the beginning.
If no location was emitted do so.
Referenced by canonicalize_values_star(), and variable_was_changed().
|
static |
Set the part of variable's location in the dataflow set SET. The variable part is specified by variable's declaration in DV and offset OFFSET and the part's location by LOC. IOPT should be NO_INSERT if the variable is known to be in SET already and the variable hash table must not be resized, and INSERT otherwise.
Referenced by canonicalize_values_star(), dataflow_set_equiv_regs(), and val_bind().
|
inlinestatic |
Increment reference counter on VARS and return it.
|
static |
Decrement reference counter and destroy hash table if not shared anymore.
|
inlinestatic |
References dv_from_decl(), HOST_WIDE_INT, REG_EXPR, REG_OFFSET, and var_reg_decl_set().
|
inlinestatic |
Return variable for DV or NULL if not already present in the hash table.
Referenced by canonicalize_values_star().
|
inlinestatic |
Referenced by variable_was_changed().
|
inlinestatic |
Return slot for DV, if it is already present in the hash table. If it is not present, insert it only VARS is not shared, otherwise return NULL.
References DECL_HAS_DEBUG_EXPR_P, and TREE_CODE.
|
inlinestatic |
Referenced by canonicalize_values_star(), variable_was_changed(), and vt_find_locations().
|
inlinestatic |
Return slot for DV only if it is already present in the hash table.
Referenced by canonicalize_values_star().
|
inlinestatic |
References variable_def::dv, dv_htab_hash(), hash_table< Descriptor, Allocator >::find_slot_with_hash(), and variable_def::refcount.
Referenced by canonicalize_values_star(), variable_was_changed(), and vt_find_locations().
|
inlinestatic |
Unshare *PVARS if shared and return slot for DV. If INS is INSERT, insert it if not already present.
Referenced by canonicalize_values_star().
|
inlinestatic |
Return the hash table for VARS.
Referenced by attrs_list_member(), attrs_list_union(), find_src_set_src(), and vt_find_locations().
|
inlinestatic |
Shared hashtable support. Return true if VARS is shared.
Referenced by attrs_list_member(), canonicalize_values_star(), and vt_find_locations().
|
static |
Copy variables into a new hash table.
Referenced by attrs_list_member().
|
inlinestatic |
Return true if VAR is shared, or maybe because VARS is shared.
Don't count an entry in the changed_variables table as a duplicate.
References emit_notes, gcc_checking_assert, NULL, and VAR_LOC_1PAUX.
Referenced by dump_dataflow_sets(), and get_addr_from_local_cache().
|
static |
Local function prototypes.
Given a SET, calculate the amount of stack adjustment it contains PRE- and POST-modifying stack pointer. This function is similar to stack_adjust_offset.
(set (reg sp) (plus (reg sp) (const_int)))
(set (mem (pre_dec (reg sp))) (foo))
We handle only adjustments by constant amount.
Referenced by variable_part_different_p().
|
static |
Shall EXPR be tracked?
If EXPR is not a parameter or a variable do not track it.
It also must have a name...
... and a RTL assigned to it.
If this expression is really a debug alias of some other declaration, we don't need to track this expression if the ultimate declaration is ignored.
Do not track EXPR if REALDECL it should be ignored for debugging purposes.
Do not track global variables until we are able to emit correct location list for them.
When the EXPR is a DECL for alias of some variable (see example) the TREE_STATIC flag is not used. Disable tracking all DECLs whose DECL_RTL contains SYMBOL_REF. Example: extern char **_dl_argv_internal __attribute__ ((alias ("_dl_argv"))); char **_dl_argv;
If RTX is a memory it should not be very large (because it would be an array or struct).
Do not track structures and arrays.
|
static |
LOC is a REG or MEM that we would like to track if possible. If EXPR is null, we don't know what expression LOC refers to, otherwise it refers to EXPR + OFFSET. STORE_REG_P is true if LOC is an lvalue register.
Return true if EXPR is nonnull and if LOC, or some lowpart of it, is something we can track. When returning true, store the mode of the lowpart we can track in *MODE_OUT (if nonnull) and its offset from EXPR in *OFFSET_OUT (if nonnull).
If REG was a paradoxical subreg, its REG_ATTRS will describe the whole subreg, but only the old inner part is really relevant.
If LOC is a paradoxical lowpart of EXPR, refer to EXPR itself. Do the same if we are storing to a register and EXPR occupies the whole of register LOC; in that case, the whole of EXPR is being changed. We exclude complex modes from the second case because the real and imaginary parts are represented as separate pseudo registers, even if the whole complex value fits into one hard register.
|
static |
Return a copy of a variable VAR and insert it to dataflow set SET.
One-part auxiliary data is only used while emitting notes, so propagate it to the new variable in the active dataflow set. If we're not emitting notes, this will be a no-op.
References location_chain_def::init.
Referenced by dump_dataflow_sets(), find_variable_location_part(), and get_addr_from_local_cache().
|
inlinestatic |
Return true if LOC should not be expanded for location expressions, or used in them.
References dump_file, dump_flags, dv_from_value(), gcc_checking_assert, INSN_UID, print_inline_rtx(), TDF_DETAILS, and val_reset().
|
inlinestatic |
Return the combined depth, when one sub-expression evaluated to BEST_DEPTH and the previous known depth was SAVED_DEPTH.
If we didn't find anything, stick with what we had.
If we found hadn't found anything, use the depth of the current expression. Do NOT add one extra level, we want to compute the maximum depth among sub-expressions. We'll increment it later, if appropriate.
Combine the entryval count so that regardless of which one we return, the entryval count is accurate.
|
static |
Transform X into narrower mode MODE from wider mode WMODE.
|
static |
Helper for adjust_mems. Return 1 if *loc is unsuitable for transformation of wider mode arithmetics to narrower mode, -1 if it is suitable and subexpressions shouldn't be traversed and 0 if it is suitable and subexpressions should be traversed. Called through for_each_rtx.
Referenced by vt_stack_adjustments().
|
static |
Determine what kind of micro operation to choose for a USE. Return MO_CLOBBER if no micro operation is to be generated.
??? flag_float_store and volatile mems are never given values, but we could in theory use them for locations.
Multi-part variables shouldn't refer to one-part variable names such as VALUEs (never happens) or DEBUG_EXPRs (only happens in the presence of debug insns).
|
inlinestatic |
Bind VAL to LOC in SET. If MODIFIED, detach LOC from any values bound to it.
If this MEM is a global constant, we don't need it in the dynamic tables. ??? We should test this before emitting the micro-op in the first place.
Other kinds of equivalences are necessarily static, at least so long as we do not perform substitutions while merging expressions.
References attrs_def::dv, dv_as_value(), dv_from_value(), dv_is_value_p(), GET_MODE, attrs_def::next, NULL, NULL_RTX, attrs_def::offset, REGNO, set_variable_part(), and VAR_INIT_STATUS_INITIALIZED.
|
static |
Reset this node, detaching all its equivalences. Return the slot in the variable hash table that holds dv, if there is one.
Relationships in the global cache don't change, so reset the local cache entry only.
If the value resolved back to itself, odds are that other values may have cached it too. These entries now refer to the old X, so detach them too. Entries that used the old X but resolved to something else remain ok as long as that something else isn't also reset.
Redirect the equivalence link to the new canonical value, or simply remove it if it would point at itself.
Keep the remaining values connected, accummulating links in the canonical value.
We remove this last, to make sure that the canonical value is not removed to the point of requiring reinsertion.
Referenced by unsuitable_loc().
|
static |
Find the values in a given location and map the val to another value, if it is unique, or add the location as one holding the value.
Map incoming equivalences. ??? Wouldn't it be nice if we just started sharing the location lists? Maybe a circular list ending at the value itself or some such.
If we didn't find any equivalence, we need to remember that this value is held in the named register. ??? Attempt to find and merge equivalent MEMs or other expressions too.
|
static |
Bind a value to a location it was just stored in. If MODIFIED holds, assume the location was modified, detaching it from any values bound to it.
|
inlinestatic |
Map a decl to its main debug decl.
|
static |
Return the MODE lowpart of LOC, or null if LOC is not something we want to track. When returning nonnull, make sure that the attributes on the returned value are updated.
Referenced by preserve_value().
|
static |
Set the location of DV, OFFSET as the MEM LOC.
References dv_as_value(), local_get_addr_cache, and pointer_map_contains().
Referenced by drop_overlapping_mem_locs().
|
static |
|
static |
Delete the location part LOC from dataflow set SET. If CLOBBER is true, also delete any other live copies of the same variable part. Adjust the address first if it is stack pointer based.
|
static |
Delete and set the location part of variable MEM_EXPR (LOC) in dataflow set SET to LOC. If MODIFY is true, any other live copies of the same variable part are also deleted from the dataflow set, otherwise the variable part is assumed to be copied from another location holding the same part. Adjust the address first if it is stack pointer based.
|
static |
Set the location part of variable MEM_EXPR (LOC) in dataflow set SET to LOC. Adjust the address first if it is stack pointer based.
|
static |
Set the register LOC to contain DV, OFFSET.
References GET_CODE, INTVAL, negative_power_of_two_p(), and XEXP.
Referenced by shared_hash_find().
|
static |
|
static |
Delete the association of register LOC in dataflow set SET with any variables that aren't onepart. If CLOBBER is true, also delete any other live copies of the same variable part, and delete the association with onepart dvs too.
|
static |
Delete current content of register LOC in dataflow set SET and set the register to contain REG_EXPR (LOC), REG_OFFSET (LOC). If MODIFY is true, any other live copies of the same variable part are also deleted from the dataflow set, otherwise the variable part is assumed to be copied from another location holding the same part.
|
static |
Set the register to contain REG_EXPR (LOC), REG_OFFSET (LOC).
References gcc_checking_assert, and GET_CODE.
|
static |
|
static |
Delete content of register with number REGNO in dataflow set SET.
References GET_CODE, INTVAL, negative_power_of_two_p(), vt_canonicalize_addr(), and XEXP.
int var_track_values_to_stack | ( | variable_def ** | slot, |
vec< rtx, va_heap > * | changed_values_stack | ||
) |
While traversing changed_variables, push onto DATA (a stack of RTX values) entries that aren't user variables.
|
static |
Return true if variables VAR1 and VAR2 are different.
One-part values have locations in a canonical order.
|
inlinestatic |
Return the variable for DV in dropped_values, inserting one if requested with INSERT.
|
static |
Referenced by vt_find_locations().
|
static |
Free the element of VARIABLE_HTAB (its type is struct variable_def).
These may be reused across functions, so reset e.g. NO_LOC_P.
References shared_hash_def::refcount.
|
static |
Combine variable or value in *S1SLOT (in DSM->cur) with the corresponding entry in DSM->src. Multi-part variables are combined with variable_union, whereas onepart dvs are combined with intersection.
If the incoming onepart variable has an empty location list, then the intersection will be just as empty. For other variables, it's always union.
If this value became canonical for another value that had this register, we want to leave it alone.
Since nextp points into the removed node, we can't use it. The pointer to the next node moved to nodep. However, if the variable we're walking is unshared during our walk, we'll keep walking the location list of the previously-shared variable, in which case the node won't have been removed, and we'll want to skip it. That's why we test *nodep here.
Canonicalization puts registers first, so we don't have to walk it all.
Mark all referenced nodes for canonicalization, and make sure we have mutual equivalence links.
If we have one value and anything else, we're going to canonicalize this, so make sure all values have an entry in the table and are marked for canonicalization.
If this was marked during register canonicalization, we know we have to canonicalize values.
|
static |
Copy s2slot (in DSM->src) to DSM->dst if the variable is a multi-part variable. Unions of multi-part variables and intersections of one-part ones will be handled in variable_merge_over_cur().
|
static |
|
static |
References GET_MODE, GET_MODE_SIZE, HARD_REGISTER_NUM_P, NULL, ORIGINAL_REGNO, PSEUDO_REGNO_MODE, REG_P, and track_expr_p().
int variable_post_merge_new_vals | ( | ) |
Create values for incoming expressions associated with one-part variables that don't have value numbers for them.
Create a unique value to hold this register, that ought to be found and reused in subsequent rounds.
Remove attribute referring to the decl, which now uses the value for the register, already existing or to be added when we bring perm in.
int variable_post_merge_perm_vals | ( | ) |
Reset values in the permanent set that are not associated with the chosen expression.
Although variable_post_merge_new_vals may have made decls non-star-canonical, values that pre-existed in canonical form remain canonical, and newly-created values reference a single REG, so they are canonical as well. Since VAR has the location list for a VALUE, using find_loc_in_1pdv for it is fine, since VALUEs don't map back to DECLs.
If there is a value associated with this register already, create an equivalence.
References NULL, VAR_LOC_1PAUX, and VAR_LOC_FROM.
unsigned int variable_tracking_main | ( | void | ) |
|
inlinestatic |
The entry point to variable tracking pass.
This is later restored by our caller.
|
static |
Compute union of location parts of variable *SLOT and the same variable from hash table DATA. Compute "sorted" union of the location chains for common offsets, i.e. the locations of a variable part are sorted by a priority where the priority is the sum of the positions in the 2 chains (if a location is only in one list the position in the second list is defined to be larger than the length of the chains). When we are updating the location parts the newest location is in the beginning of the chain, so when we do the described "sorted" union we keep the newest locations in the beginning.
Continue traversing the hash table.
We can combine one-part variables very efficiently, because their entries are in canonical order. Count the number of location parts, result is K.
We track only variables whose size is <= MAX_VAR_PARTS bytes thus there are at most MAX_VAR_PARTS different offsets.
Compute the "sorted" union of the chains, i.e. the locations which are in both chains go first, they are sorted by the sum of positions in the chains.
If DST is shared compare the location chains. If they are different we will modify the chain in DST with high probability so make a copy of DST.
The most common case, much simpler, no qsort is needed.
Copy the location from SRC.
Fill in the locations from DST.
Pos plus value larger than a sum of 2 valid positions.
Fill in the locations from SRC.
Find location from NODE.
Copy the location from SRC.
Special case still very common case. For dst_l == 2 all entries dst_l ... n-1 are sorted, with for i >= dst_l vui[i].pos == i + src_l + dst_l.
Order should be 1, 0, 2...
Order should be 0, 2, 1, 3...
Order should be 0, 1, 2...
Reconnect the nodes in sorted order.
Copy the chain from SRC.
Continue traversing the hash table.
References variable_union_info::pos.
Referenced by canonicalize_values_star().
|
static |
|
static |
Compare function for qsort, order the structures by POS element.
|
static |
Referenced by get_addr_from_local_cache().
|
static |
Add variable VAR to the hash table of changed variables and if it has no locations delete it from SET's hash table.
Remember this decl or VALUE has been added to changed_variables.
Restore the auxiliary info from an empty variable previously created for changed_variables, so it is not lost.
References set_slot_part(), shared_hash_find_slot(), shared_hash_find_slot_noinsert(), and shared_hash_find_slot_unshare().
|
static |
|
static |
Copy all variables from hash table SRC to hash table DST.
|
static |
Insert function parameter PARM in IN and OUT sets of ENTRY_BLOCK.
If there is a DRAP register or a pseudo in internal_arg_pointer, rewrite the incoming location of parameters passed on the stack into MEMs based on the argument pointer, so that incoming doesn't depend on a pseudo.
This means argument is passed by invisible reference.
If that DECL_RTL wasn't a pseudo that got spilled to memory, bail out. Otherwise, the spill slot sharing code will force the memory to reference spill_slot_decl (%sfp), so we don't match above. That's ok, the pseudo must have referenced the entire parameter, so just reset OFFSET.
We can't deal with these right now, because this kind of variable is single-part. ??? We could handle parallels that describe multiple locations for the same single value, but ATM we don't.
??? We shouldn't ever hit this, but it may happen because arguments passed by invisible reference aren't dealt with above: incoming-rtl will have Pmode rather than the expected mode for the type.
??? Float-typed values in memory are not handled by cselib.
References micro_operation_def::adjust, dump_file, dump_flags, micro_operation_def::insn, log_op_type(), MO_ADJUST, PATTERN, micro_operation_def::type, micro_operation_def::u, and VTI.
|
static |
Insert function parameters to IN and OUT sets of ENTRY_BLOCK.
|
inlinestatic |
Return true iff there's a true dependence between MLOC and LOC. MADDR must be a canonicalized version of MLOC's address.
References GET_CODE.
Referenced by get_addr_from_local_cache().
|
static |
Referenced by var_regno_delete().
|
static |
Canonicalize LOC using equivalences from SET in addition to those in the cselib static table. It expects a VALUE-based expression, and it will only substitute VALUEs with other VALUEs or function-global equivalences, so that, if two addresses have base VALUEs that are locally or globally related in ways that memrefs_conflict_p cares about, they will both canonicalize to expressions that have the same base VALUE.
The use of VALUEs as canonical base addresses enables the canonical RTXs to remain unchanged globally, if they resolve to a constant, or throughout a basic block otherwise, so that they can be cached and the cache needs not be invalidated when REGs, MEMs or such change.
Alignment operations can't normally be combined, so just canonicalize the base and we're done. We'll normally have only one stack alignment anyway.
Consolidate plus_constants.
Add OFST back in.
Don't build new RTL if we can help it.
|
static |
Run a fast, BB-local only version of var tracking, to take care of information that we don't do global analysis on, such that not all information is lost. If SKIPPED holds, we're skipping the global pass entirely, so we should try to use information it would have handled as well..
??? Just skip it all for now.
|
static |
Emit notes for the whole function.
Free memory occupied by the out hash tables, as they aren't used anymore.
Enable emitting notes by functions (mainly by set_variable_part and delete_variable_part).
Emit the notes for changes of variable locations between two subsequent basic blocks.
Emit the notes for the changes in the basic block itself.
Free memory occupied by the in hash table, we won't need it again.
|
static |
Expand the one-part VARiable to a location, using the equivalences in VARS, updating their CUR_LOCs in the process.
References NULL, and VAR_LOC_1PAUX.
|
static |
Expand VALUEs and DEBUG_EXPRs in LOC to a location, using the equivalences in VARS, updating their CUR_LOCs in the process.
References gcc_checking_assert, NULL, and VAR_LOC_1PAUX.
Callback for cselib_expand_value, that looks for expressions holding the value in the var-tracking hash tables. Return X for standard processing, anything else is to be used as-is.
Invalid SUBREGs are ok in debug info. ??? We could try alternate expansions for the VALUE as well.
Check that VALUE_RECURSED_INTO implies NO_LOC_P. This is tentative, but it makes some tests simpler.
Referenced by loc_exp_insert_dep().
|
inlinestatic |
Expand VAR to a location RTX, updating its cur_loc. Use REGS and DATA for cselib expand callback. If PENDRECP is given, indicate in it whether any sub-expression couldn't be fully evaluated because it is pending recursion resolution.
Clear all backlinks pointing at this, so that we're not notified while we're active.
Attempt to expand each available location in turn.
Set it up in case we leave the loop.
We found entries with ENTRY_VALUEs and skipped them. Since we could not find any expansions without ENTRY_VALUEs, but we found at least one with them, go back and get an entry with the minimum number ENTRY_VALUE count that we found. We could avoid looping, but since each sub-loc is already resolved, the re-expansion should be trivial. ??? Should we record all attempted locs as dependencies, so that we retry the expansion should any of them change, in the hope it can give us a new entry without an ENTRY_VALUE?
Register all encountered dependencies as active.
Record where the expansion came from.
Indicate whether any of the dependencies are pending recursion resolution.
|
static |
Free the data structures needed for variable tracking.
|
static |
Find the locations of variables in the whole function.
Compute reverse completion order of depth first search of the CFG so that the data-flow runs faster.
Calculate the IN set as the intersection of predecessor OUT sets.
Calculate the IN set as union of predecessor OUT sets.
Send E->DEST to next round.
Add E->DEST to current round.
References changed_variables, hash_table< Descriptor, Allocator >::clear_slot(), dropped_values, variable_def::dv, dv_htab_hash(), emit_notes, hash_table< Descriptor, Allocator >::find_slot_with_hash(), gcc_assert, gcc_checking_assert, variable_def::n_var_parts, NULL, ONEPART_DEXPR, onepart_pool(), ONEPART_VALUE, pool_alloc(), recover_dropped_1paux(), variable_def::refcount, set_dv_changed(), shared_hash_find_slot_noinsert(), shared_hash_find_slot_unshare(), shared_hash_htab(), shared_hash_shared(), VAR_LOC_1PAUX, and variable_htab_free().
|
static |
Strip constant offsets and alignments off of LOC. Return the base expression.
Referenced by clobber_overlapping_mems().
|
static |
|
static |
If there is a declaration and offset associated with register/memory RTL assign declaration to *DECLP and offset to *OFFSETP, and return true.
References micro_operation_def::adjust, adjust_insn(), BB_END, BB_HEAD, cselib_hook_called, dump_file, dump_flags, frame_pointer_needed, micro_operation_def::insn, INSN_P, insn_stack_adjust_offset_pre_post(), log_op_type(), MAY_HAVE_DEBUG_INSNS, MO_ADJUST, NEXT_INSN, PATTERN, micro_operation_def::type, micro_operation_def::u, and VTI.
|
static |
Initialize cfa_base_rtx, create a preserved VALUE for it and ensure it isn't flushed during cselib_reset_table. Can be called only if frame_pointer_rtx resp. arg_pointer_rtx has been eliminated.
Tell alias analysis that cfa_base_rtx should share find_base_term value with stack pointer or hard frame pointer.
|
static |
Allocate and initialize the data structures for variable tracking and parse the RTL to get the micro operations.
Init the IN and OUT sets.
In order to factor out the adjustments made to the stack pointer or to the hard frame pointer and thus be able to use DW_OP_fbreg operations instead of individual location lists, we're going to rewrite MEMs based on them into MEMs based on the CFA by de-eliminating stack_pointer_rtx or hard_frame_pointer_rtx to the virtual CFA pointer frame_pointer_rtx resp. arg_pointer_rtx. We can do this either when there is no frame pointer in the function and stack adjustments are consistent for all basic blocks or when there is a frame pointer and no stack realignment. But we first have to check that frame_pointer_rtx resp. arg_pointer_rtx has been eliminated.
If the stack is realigned and a DRAP register is used, we're going to rewrite MEMs based on it representing incoming locations of parameters passed on the stack into MEMs based on the argument pointer. Although we aren't going to rewrite other MEMs, we still need to initialize the virtual CFA pointer in order to ensure that the argument pointer will be seen as a constant throughout the function. ??? This doesn't work if FRAME_POINTER_CFA_OFFSET is defined.
Add the micro-operations to the vector.
Disassociate sp from fp now.
|
static |
Compute stack adjustments for all blocks by traversing DFS tree. Return true when the adjustments on all incoming edges are consistent. Heavily borrowed from pre_and_rev_post_order_compute.
Initialize entry block.
Allocate stack for back-tracking up CFG.
Push the first edge on to the stack.
Look at the edge on the top of the stack.
Check if the edge destination has been visited yet.
Since the DEST node has been visited for the first time, check its successors.
Check whether the adjustments on the edges are the same.
Go to the next edge.
Return to previous level if there are no more edges.
References CONSTANT_P, cselib_lookup(), for_each_rtx(), GET_CODE, GET_MODE, subreg_lowpart_offset(), SUBREG_REG, use_narrower_mode_test(), validate_subreg(), and XEXP.
|
static |
Alloc pool for struct attrs_def.
Referenced by dv_from_value(), and dv_onepart_p().
|
static |
Arguments to the call.
|
static |
|
static |
arg_pointer_rtx resp. frame_pointer_rtx if stack_pointer_rtx or hard_frame_pointer_rtx is being mapped to it and offset for it.
|
static |
Changed variables, notes will be emitted for them.
Referenced by vt_find_locations().
char check_value_val[(int) VALUE==(int) IDENTIFIER_NODE?1:-1] |
Variable tracking routines for the GNU compiler. Copyright (C) 2002-2013 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 file contains the variable tracking pass. It computes where variables are located (which registers or where in memory) at each position in instruction stream and emits notes describing the locations. Debug information (DWARF2 location lists) is finally generated from these notes. With this debug information, it is possible to show variables even when debugging optimized code.
How does the variable tracking pass work?
First, it scans RTL code for uses, stores and clobbers (register/memory references in instructions), for call insns and for stack adjustments separately for each basic block and saves them to an array of micro operations. The micro operations of one instruction are ordered so that pre-modifying stack adjustment < use < use with no var < call insn < < clobber < set < post-modifying stack adjustment
Then, a forward dataflow analysis is performed to find out how locations of variables change through code and to propagate the variable locations along control flow graph. The IN set for basic block BB is computed as a union of OUT sets of BB's predecessors, the OUT set for BB is copied from the IN set for BB and is changed according to micro operations in BB.
The IN and OUT sets for basic blocks consist of a current stack adjustment (used for adjusting offset of variables addressed using stack pointer), the table of structures describing the locations of parts of a variable and for each physical register a linked list for each physical register. The linked list is a list of variable parts stored in the register, i.e. it is a list of triplets (reg, decl, offset) where decl is REG_EXPR (reg) and offset is REG_OFFSET (reg). The linked list is used for effective deleting appropriate variable parts when we set or clobber the register.
There may be more than one variable part in a register. The linked lists should be pretty short so it is a good data structure here. For example in the following code, register allocator may assign same register to variables A and B, and both of them are stored in the same register in CODE:
if (cond) set A; else set B; CODE; if (cond) use A; else use B;
Finally, the NOTE_INSN_VAR_LOCATION notes describing the variable locations are emitted to appropriate positions in RTL code. Each such a note describes the location of one variable at the point in instruction stream where the note is. There is no need to emit a note for each variable before each instruction, we only emit these notes where the location of variable changes (this means that we also emit notes for changes between the OUT set of the previous block and the IN set of the current block).
The notes consist of two parts:
|
static |
Variable used to tell whether cselib_process_insn called our hook.
Referenced by vt_get_decl_and_offset().
|
static |
This is not reset after each function. It gives each NOTE_INSN_DELETED_DEBUG_LABEL in the entire compilation a unique label number.
|
static |
Values whose dynamic location lists have gone empty, but whose cselib location lists are still usable. Use this to hold the current location, the backlinks, etc, during emit_notes.
Referenced by emit_notes_for_changes(), and vt_find_locations().
|
static |
Referenced by canonicalize_values_star().
|
static |
Shall notes be emitted?
Referenced by shared_var_p(), and vt_find_locations().
|
static |
Empty shared hashtable.
|
static |
This caches canonicalized addresses for VALUEs, computed using information in the global cselib table.
|
static |
Adjustment for hard_frame_pointer_rtx to cfa base reg, or -1 if the replacement shouldn't be done.
|
static |
Alloc pool for struct location_chain_def.
Referenced by get_addr_from_local_cache().
|
static |
Alloc pool for struct loc_exp_dep_s for NOT_ONEPART variables.
Referenced by emit_notes_for_changes().
|
static |
This caches canonicalized addresses for VALUEs, computed using information from the global cache and information pertaining to a basic block being analyzed.
Referenced by var_mem_decl_set().
|
static |
Scratch register bitmap used by cselib_expand_value_rtx.
Referenced by loc_exp_insert_dep().
|
static |
Alloc pool for struct shared_hash_def.
Referenced by attrs_list_clear().
|
static |
Alloc pool for struct variable_def with a single var_part entry.
|
static |
Alloc pool for struct variable_def with MAX_VAR_PARTS entries.
|
static |
|
static |
Buffer for location list sorting and its allocated size.