gccint: Sharing

1 
1 14.21 Structure Sharing Assumptions
1 ===================================
1 
1 The compiler assumes that certain kinds of RTL expressions are unique;
1 there do not exist two distinct objects representing the same value.  In
1 other cases, it makes an opposite assumption: that no RTL expression
1 object of a certain kind appears in more than one place in the
1 containing structure.
1 
1  These assumptions refer to a single function; except for the RTL
1 objects that describe global variables and external functions, and a few
1 standard objects such as small integer constants, no RTL objects are
1 common to two functions.
1 
1    * Each pseudo-register has only a single 'reg' object to represent
1      it, and therefore only a single machine mode.
1 
1    * For any symbolic label, there is only one 'symbol_ref' object
1      referring to it.
1 
1    * All 'const_int' expressions with equal values are shared.
1 
1    * All 'const_poly_int' expressions with equal modes and values are
1      shared.
1 
1    * There is only one 'pc' expression.
1 
1    * There is only one 'cc0' expression.
1 
1    * There is only one 'const_double' expression with value 0 for each
1      floating point mode.  Likewise for values 1 and 2.
1 
1    * There is only one 'const_vector' expression with value 0 for each
1      vector mode, be it an integer or a double constant vector.
1 
1    * No 'label_ref' or 'scratch' appears in more than one place in the
1      RTL structure; in other words, it is safe to do a tree-walk of all
1      the insns in the function and assume that each time a 'label_ref'
1      or 'scratch' is seen it is distinct from all others that are seen.
1 
1    * Only one 'mem' object is normally created for each static variable
1      or stack slot, so these objects are frequently shared in all the
1      places they appear.  However, separate but equal objects for these
1      variables are occasionally made.
1 
1    * When a single 'asm' statement has multiple output operands, a
1      distinct 'asm_operands' expression is made for each output operand.
1      However, these all share the vector which contains the sequence of
1      input operands.  This sharing is used later on to test whether two
1      'asm_operands' expressions come from the same statement, so all
1      optimizations must carefully preserve the sharing if they copy the
1      vector at all.
1 
1    * No RTL object appears in more than one place in the RTL structure
1      except as described above.  Many passes of the compiler rely on
1      this by assuming that they can modify RTL objects in place without
1      unwanted side-effects on other insns.
1 
1    * During initial RTL generation, shared structure is freely
1      introduced.  After all the RTL for a function has been generated,
1      all shared structure is copied by 'unshare_all_rtl' in
1      'emit-rtl.c', after which the above rules are guaranteed to be
1      followed.
1 
1    * During the combiner pass, shared structure within an insn can exist
1      temporarily.  However, the shared structure is copied before the
1      combiner is finished with the insn.  This is done by calling
1      'copy_rtx_if_shared', which is a subroutine of 'unshare_all_rtl'.
1