GCC Middle and Back End API Reference

Data Structures  
struct  prop_value_d 
Typedefs  
typedef struct prop_value_d  prop_value_t 
Functions  
static bool  stmt_may_generate_copy () 
static prop_value_t *  get_copy_of_val () 
static tree  valueize_val () 
static bool  set_copy_of_val () 
static void  dump_copy_of () 
static enum ssa_prop_result  copy_prop_visit_assignment () 
static enum ssa_prop_result  copy_prop_visit_cond_stmt () 
static enum ssa_prop_result  copy_prop_visit_stmt () 
static enum ssa_prop_result  copy_prop_visit_phi_node () 
static void  init_copy_prop () 
static tree  get_value () 
static void  fini_copy_prop () 
static unsigned int  execute_copy_prop () 
static bool  gate_copy_prop () 
gimple_opt_pass *  make_pass_copy_prop () 
Variables  
static prop_value_t *  copy_of 
static unsigned  n_copy_of 
typedef struct prop_value_d prop_value_t 

static 
Evaluate the RHS of STMT. If it produces a valid copy, set the LHS value and store the LHS into *RESULT_P.
Straight copy between two SSA names. First, make sure that we can propagate the RHS into uses of LHS.

static 
Visit the GIMPLE_COND STMT. Return SSA_PROP_INTERESTING if it can determine which edge will be taken. Otherwise, return SSA_PROP_VARYING.
The only conditionals that we may be able to compute statically are predicates involving two SSA_NAMEs.
See if we can determine the predicate's value.
We can fold COND and get a useful result only when we have the same SSA_NAME on both sides of a comparison operator.
References dump_file, and print_gimple_stmt().
Referenced by copy_prop_visit_stmt().

static 
Visit PHI node PHI. If all the arguments produce the same value, set it to be the value of the LHS of PHI.
We don't care about values flowing through nonexecutable edges.
Names that flow through abnormal edges cannot be used to derive copies.
If we didn't visit the definition of arg yet treat it as UNDEFINED. This also handles PHI arguments that are the same as lhs. We'll come here again.
Avoid copy propagation from an inner into an outer loop. Otherwise, this may move loop variant variables outside of their loops and prevent coalescing opportunities. If the value was loop invariant, it will be hoisted by LICM and exposed for copy propagation. ??? The value will be always loop invariant. In loopclosed SSA form do not copypropagate through PHI nodes in blocks with a loop exit edge predecessor.
If the LHS didn't have a value yet, make it a copy of the first argument we find.
If PHI_VAL and ARG don't have a common copyof chain, then this PHI node cannot be a copy operation.
References prop_value_d::value.

static 
Evaluate statement STMT. If the statement produces a new output value, return SSA_PROP_INTERESTING and store the SSA_NAME holding the new value in *RESULT_P. If STMT is a conditional branch and we can determine its truth value, set *TAKEN_EDGE_P accordingly. If the new value produced by STMT is varying, return SSA_PROP_VARYING.
If the statement is a copy assignment, evaluate its RHS to see if the lattice value of its output has changed.
See if we can determine which edge goes out of a conditional jump.
Any other kind of statement is not interesting for constant propagation and, therefore, not worth simulating.
The assignment is not a copy operation. Don't visit this statement again and mark all the definitions in the statement to be copies of nothing.
References copy_prop_visit_cond_stmt().

static 
Dump the copyof value for variable VAR to FILE.

static 
Main entry point to the copy propagator. PHIS_ONLY is true if we should only consider PHI nodes as generating copy propagation opportunities. The algorithm propagates the value COPYOF using ssa_propagate. For every variable X_i, COPYOF(X_i) indicates which variable is X_i created from. The following example shows how the algorithm proceeds at a high level: 1 a_24 = x_1 2 a_2 = PHI <a_24, x_1> 3 a_5 = PHI <a_2> 4 x_1 = PHI <x_298, a_5, a_2> The end result should be that a_2, a_5, a_24 and x_1 are a copy of x_298. Propagation proceeds as follows. Visit #1: a_24 is copyof x_1. Value changed. Visit #2: a_2 is copyof x_1. Value changed. Visit #3: a_5 is copyof x_1. Value changed. Visit #4: x_1 is copyof x_298. Value changed. Visit #1: a_24 is copyof x_298. Value changed. Visit #2: a_2 is copyof x_298. Value changed. Visit #3: a_5 is copyof x_298. Value changed. Visit #4: x_1 is copyof x_298. Stable state reached. When visiting PHI nodes, we only consider arguments that flow through edges marked executable by the propagation engine. So, when visiting statement #2 for the first time, we will only look at the first argument (a_24) and optimistically assume that its value is the copy of a_24 (x_1).

static 
Deallocate memory used in copy propagation and do final substitution.
Set the final copyof value for each variable by traversing the copyof chains.
In theory the pointsto solution of all members of the copy chain is their intersection. For now we do not bother to compute this but only make sure we do not lose pointsto information completely by setting the pointsto solution of the representative to the first solution we find if it doesn't have one already.
Don't do DCE if SCEV is initialized. It would destroy the scev cache.

static 

inlinestatic 
Return the copyof value for VAR.
If the variable will never generate a useful copy relation, make it its own copy.

static 
Callback for substitute_and_fold to get at the final copyof values.
References copy_of, duplicate_ssa_name_ptr_info(), and duplicate_ssa_name_range_info().

static 
Initialize structures used for copy propagation.
The only statements that we care about are those that may generate useful copies. We also need to mark conditional jumps so that their outgoing edges are added to the work lists of the propagator. Avoid copy propagation from an inner into an outer loop. Otherwise, this may move loop variant variables outside of their loops and prevent coalescing opportunities. If the value was loop invariant, it will be hoisted by LICM and exposed for copy propagation. ??? This doesn't make sense.
Since we are iterating over the statements in BB, not the phi nodes, STMT will always be an assignment.
Mark all the outputs of this statement as not being the copy of anything.
gimple_opt_pass* make_pass_copy_prop  (  ) 

inlinestatic 
Set VAL to be the copy of VAR. If that changed return true.
Set FIRST to be the first link in COPY_OF[DEST]. If that changed, return true.

static 
Return true if this statement may generate a useful copy.
If the statement has volatile operands, it won't generate a useful copy.
Statements with loads and/or stores will never generate a useful copy.
Otherwise, the only statements that generate useful copies are assignments whose RHS is just an SSA name that doesn't flow through abnormal edges.

inlinestatic 
Return the variable VAR is a copy of or VAR if VAR isn't the result of a copy.
References copy_of, operand_equal_p(), and prop_value_d::value.

static 
Referenced by get_value(), and valueize_val().

static 