Home | History | Annotate | Line # | Download | only in gcc
      1   1.1  mrg /* Interprocedural analyses.
      2  1.12  mrg    Copyright (C) 2005-2022 Free Software Foundation, Inc.
      3   1.1  mrg 
      4   1.1  mrg This file is part of GCC.
      5   1.1  mrg 
      6   1.1  mrg GCC is free software; you can redistribute it and/or modify it under
      7   1.1  mrg the terms of the GNU General Public License as published by the Free
      8   1.1  mrg Software Foundation; either version 3, or (at your option) any later
      9   1.1  mrg version.
     10   1.1  mrg 
     11   1.1  mrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
     12   1.1  mrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
     13   1.1  mrg FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     14   1.1  mrg for more details.
     15   1.1  mrg 
     16   1.1  mrg You should have received a copy of the GNU General Public License
     17   1.1  mrg along with GCC; see the file COPYING3.  If not see
     18   1.1  mrg <http://www.gnu.org/licenses/>.  */
     19   1.1  mrg 
     20   1.1  mrg #ifndef IPA_PROP_H
     21   1.1  mrg #define IPA_PROP_H
     22   1.1  mrg 
     23   1.1  mrg /* The following definitions and interfaces are used by
     24   1.1  mrg    interprocedural analyses or parameters.  */
     25   1.1  mrg 
     26   1.5  mrg #define IPA_UNDESCRIBED_USE -1
     27   1.5  mrg 
     28  1.12  mrg /* ipa-prop.cc stuff (ipa-cp, indirect inlining):  */
     29   1.1  mrg 
     30   1.1  mrg /* A jump function for a callsite represents the values passed as actual
     31   1.3  mrg    arguments of the callsite.  They were originally proposed in a paper called
     32   1.3  mrg    "Interprocedural Constant Propagation", by David Callahan, Keith D Cooper,
     33   1.3  mrg    Ken Kennedy, Linda Torczon in Comp86, pg 152-161.  There are three main
     34   1.3  mrg    types of values :
     35   1.1  mrg 
     36   1.1  mrg    Pass-through - the caller's formal parameter is passed as an actual
     37   1.1  mrg                   argument, possibly one simple operation performed on it.
     38   1.1  mrg    Constant     - a constant (is_gimple_ip_invariant)is passed as an actual
     39   1.1  mrg                   argument.
     40   1.1  mrg    Unknown      - neither of the above.
     41   1.1  mrg 
     42  1.11  mrg    IPA_JF_LOAD_AGG is a compound pass-through jump function, in which primary
     43  1.11  mrg    operation on formal parameter is memory dereference that loads a value from
     44  1.11  mrg    a part of an aggregate, which is represented or pointed to by the formal
     45  1.11  mrg    parameter.  Moreover, an additional unary/binary operation can be applied on
     46  1.11  mrg    the loaded value, and final result is passed as actual argument of callee
     47  1.11  mrg    (e.g. *(param_1(D) + 4) op 24 ).  It is meant to describe usage of aggregate
     48  1.11  mrg    parameter or by-reference parameter referenced in argument passing, commonly
     49  1.11  mrg    found in C++ and Fortran.
     50  1.11  mrg 
     51   1.3  mrg    IPA_JF_ANCESTOR is a special pass-through jump function, which means that
     52   1.3  mrg    the result is an address of a part of the object pointed to by the formal
     53   1.3  mrg    parameter to which the function refers.  It is mainly intended to represent
     54   1.6  mrg    getting addresses of ancestor fields in C++
     55   1.3  mrg    (e.g. &this_1(D)->D.1766.D.1756).  Note that if the original pointer is
     56   1.3  mrg    NULL, ancestor jump function must behave like a simple pass-through.
     57   1.3  mrg 
     58   1.3  mrg    Other pass-through functions can either simply pass on an unchanged formal
     59   1.3  mrg    parameter or can apply one simple binary operation to it (such jump
     60   1.3  mrg    functions are called polynomial).
     61   1.3  mrg 
     62  1.12  mrg    Jump functions are computed in ipa-prop.cc by function
     63   1.3  mrg    update_call_notes_after_inlining.  Some information can be lost and jump
     64   1.3  mrg    functions degraded accordingly when inlining, see
     65   1.3  mrg    update_call_notes_after_inlining in the same file.  */
     66   1.1  mrg 
     67   1.1  mrg enum jump_func_type
     68   1.1  mrg {
     69   1.1  mrg   IPA_JF_UNKNOWN = 0,  /* newly allocated and zeroed jump functions default */
     70   1.3  mrg   IPA_JF_CONST,             /* represented by field costant */
     71   1.3  mrg   IPA_JF_PASS_THROUGH,	    /* represented by field pass_through */
     72  1.11  mrg   IPA_JF_LOAD_AGG,	    /* represented by field load_agg */
     73   1.3  mrg   IPA_JF_ANCESTOR	    /* represented by field ancestor */
     74   1.1  mrg };
     75   1.1  mrg 
     76   1.5  mrg struct ipa_cst_ref_desc;
     77   1.5  mrg 
     78   1.5  mrg /* Structure holding data required to describe a constant jump function.  */
     79   1.5  mrg struct GTY(()) ipa_constant_data
     80   1.3  mrg {
     81   1.5  mrg   /* THe value of the constant.  */
     82   1.5  mrg   tree value;
     83   1.5  mrg   /* Pointer to the structure that describes the reference.  */
     84   1.5  mrg   struct ipa_cst_ref_desc GTY((skip)) *rdesc;
     85   1.1  mrg };
     86   1.1  mrg 
     87   1.1  mrg /* Structure holding data required to describe a pass-through jump function.  */
     88   1.1  mrg 
     89   1.1  mrg struct GTY(()) ipa_pass_through_data
     90   1.1  mrg {
     91   1.1  mrg   /* If an operation is to be performed on the original parameter, this is the
     92   1.1  mrg      second (constant) operand.  */
     93   1.1  mrg   tree operand;
     94   1.1  mrg   /* Number of the caller's formal parameter being passed.  */
     95   1.1  mrg   int formal_id;
     96   1.1  mrg   /* Operation that is performed on the argument before it is passed on.
     97  1.12  mrg      Special values which have other meaning than in normal contexts:
     98  1.12  mrg        - NOP_EXPR means no operation, not even type conversion.
     99  1.12  mrg        - ASSERT_EXPR means that only the value in operand is allowed to pass
    100  1.12  mrg          through (without any change), for all other values the result is
    101  1.12  mrg          unknown.
    102  1.12  mrg      Otherwise operation must be a simple binary or unary arithmetic operation
    103  1.12  mrg      where the caller's parameter is the first operand and (for binary
    104  1.12  mrg      operations) the operand field from this structure is the second one.  */
    105   1.1  mrg   enum tree_code operation;
    106   1.3  mrg   /* When the passed value is a pointer, it is set to true only when we are
    107   1.3  mrg      certain that no write to the object it points to has occurred since the
    108   1.3  mrg      caller functions started execution, except for changes noted in the
    109   1.3  mrg      aggregate part of the jump function (see description of
    110   1.3  mrg      ipa_agg_jump_function).  The flag is used only when the operation is
    111   1.3  mrg      NOP_EXPR.  */
    112   1.5  mrg   unsigned agg_preserved : 1;
    113  1.12  mrg   /* Set when the edge has already been used to decrement an appropriate
    114  1.12  mrg      reference description counter and should not be decremented again.  */
    115  1.12  mrg   unsigned refdesc_decremented : 1;
    116   1.1  mrg };
    117   1.1  mrg 
    118  1.11  mrg /* Structure holding data required to describe a load-value-from-aggregate
    119  1.11  mrg    jump function.  */
    120  1.11  mrg 
    121  1.11  mrg struct GTY(()) ipa_load_agg_data
    122  1.11  mrg {
    123  1.11  mrg   /* Inherit from pass through jump function, describing unary/binary
    124  1.11  mrg      operation on the value loaded from aggregate that is represented or
    125  1.11  mrg      pointed to by the formal parameter, specified by formal_id in this
    126  1.11  mrg      pass_through jump function data structure.  */
    127  1.11  mrg   struct ipa_pass_through_data pass_through;
    128  1.11  mrg   /* Type of the value loaded from the aggregate.  */
    129  1.11  mrg   tree type;
    130  1.11  mrg   /* Offset at which the value is located within the aggregate.  */
    131  1.11  mrg   HOST_WIDE_INT offset;
    132  1.11  mrg   /* True if loaded by reference (the aggregate is pointed to by the formal
    133  1.11  mrg      parameter) or false if loaded by value (the aggregate is represented
    134  1.11  mrg      by the formal parameter).  */
    135  1.11  mrg   bool by_ref;
    136  1.11  mrg };
    137  1.11  mrg 
    138   1.3  mrg /* Structure holding data required to describe an ancestor pass-through
    139   1.3  mrg    jump function.  */
    140   1.1  mrg 
    141   1.1  mrg struct GTY(()) ipa_ancestor_jf_data
    142   1.1  mrg {
    143   1.1  mrg   /* Offset of the field representing the ancestor.  */
    144   1.1  mrg   HOST_WIDE_INT offset;
    145   1.1  mrg   /* Number of the caller's formal parameter being passed.  */
    146   1.1  mrg   int formal_id;
    147   1.3  mrg   /* Flag with the same meaning like agg_preserve in ipa_pass_through_data.  */
    148   1.5  mrg   unsigned agg_preserved : 1;
    149  1.11  mrg   /* When set, the operation should not have any effect on NULL pointers.  */
    150  1.11  mrg   unsigned keep_null : 1;
    151  1.11  mrg };
    152  1.11  mrg 
    153  1.11  mrg /* A jump function for an aggregate part at a given offset, which describes how
    154  1.11  mrg    it content value is generated.  All unlisted positions are assumed to have a
    155  1.11  mrg    value defined in an unknown way.  */
    156  1.11  mrg 
    157  1.11  mrg struct GTY(()) ipa_agg_jf_item
    158  1.11  mrg {
    159  1.11  mrg   /* The offset for the aggregate part.  */
    160  1.11  mrg   HOST_WIDE_INT offset;
    161  1.11  mrg 
    162  1.11  mrg   /* Data type of the aggregate part.  */
    163  1.11  mrg   tree type;
    164  1.11  mrg 
    165  1.11  mrg   /* Jump function type.  */
    166  1.11  mrg   enum jump_func_type jftype;
    167  1.11  mrg 
    168  1.11  mrg   /* Represents a value of jump function. constant represents the actual constant
    169  1.11  mrg      in constant jump function content.  pass_through is used only in simple pass
    170  1.11  mrg      through jump function context.  load_agg is for load-value-from-aggregate
    171  1.11  mrg      jump function context.  */
    172  1.11  mrg   union jump_func_agg_value
    173  1.11  mrg   {
    174  1.11  mrg     tree GTY ((tag ("IPA_JF_CONST"))) constant;
    175  1.11  mrg     struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
    176  1.11  mrg     struct ipa_load_agg_data GTY ((tag ("IPA_JF_LOAD_AGG"))) load_agg;
    177  1.11  mrg   } GTY ((desc ("%1.jftype"))) value;
    178   1.1  mrg };
    179   1.1  mrg 
    180  1.11  mrg /* Jump functions describing a set of aggregate contents.  */
    181  1.11  mrg 
    182  1.11  mrg struct GTY(()) ipa_agg_jump_function
    183  1.11  mrg {
    184  1.11  mrg   /* Description of the individual jump function item.  */
    185  1.11  mrg   vec<ipa_agg_jf_item, va_gc> *items;
    186  1.11  mrg   /* True if the data was passed by reference (as opposed to by value).  */
    187  1.11  mrg   bool by_ref;
    188  1.11  mrg };
    189  1.11  mrg 
    190  1.11  mrg /* An element in an aggregate part describing a known value at a given offset.
    191  1.11  mrg    All unlisted positions are assumed to be unknown and all listed values must
    192   1.5  mrg    fulfill is_gimple_ip_invariant.  */
    193   1.3  mrg 
    194  1.11  mrg struct ipa_agg_value
    195   1.3  mrg {
    196   1.3  mrg   /* The offset at which the known value is located within the aggregate.  */
    197   1.3  mrg   HOST_WIDE_INT offset;
    198   1.3  mrg 
    199  1.11  mrg   /* The known constant.  */
    200   1.3  mrg   tree value;
    201  1.11  mrg 
    202  1.11  mrg   /* Return true if OTHER describes same agg value.  */
    203  1.11  mrg   bool equal_to (const ipa_agg_value &other);
    204   1.5  mrg };
    205   1.3  mrg 
    206  1.11  mrg /* Structure describing a set of known offset/value for aggregate.  */
    207   1.3  mrg 
    208  1.11  mrg struct ipa_agg_value_set
    209   1.1  mrg {
    210  1.11  mrg   /* Description of the individual item.  */
    211  1.11  mrg   vec<ipa_agg_value> items;
    212  1.11  mrg   /* True if the data was passed by reference (as opposed to by value).  */
    213   1.3  mrg   bool by_ref;
    214  1.11  mrg 
    215  1.11  mrg   /* Return true if OTHER describes same agg values.  */
    216  1.11  mrg   bool equal_to (const ipa_agg_value_set &other)
    217  1.11  mrg   {
    218  1.11  mrg     if (by_ref != other.by_ref)
    219  1.11  mrg       return false;
    220  1.11  mrg     if (items.length () != other.items.length ())
    221  1.11  mrg       return false;
    222  1.11  mrg     for (unsigned int i = 0; i < items.length (); i++)
    223  1.11  mrg       if (!items[i].equal_to (other.items[i]))
    224  1.11  mrg 	return false;
    225  1.11  mrg     return true;
    226  1.11  mrg   }
    227  1.11  mrg 
    228  1.11  mrg   /* Return true if there is any value for aggregate.  */
    229  1.11  mrg   bool is_empty () const
    230  1.11  mrg   {
    231  1.11  mrg     return items.is_empty ();
    232  1.11  mrg   }
    233  1.11  mrg 
    234  1.11  mrg   ipa_agg_value_set copy () const
    235  1.11  mrg   {
    236  1.11  mrg     ipa_agg_value_set new_copy;
    237  1.11  mrg 
    238  1.11  mrg     new_copy.items = items.copy ();
    239  1.11  mrg     new_copy.by_ref = by_ref;
    240  1.11  mrg 
    241  1.11  mrg     return new_copy;
    242  1.11  mrg   }
    243  1.11  mrg 
    244  1.11  mrg   void release ()
    245  1.11  mrg   {
    246  1.11  mrg     items.release ();
    247  1.11  mrg   }
    248   1.1  mrg };
    249   1.1  mrg 
    250  1.11  mrg /* Return copy of a vec<ipa_agg_value_set>.  */
    251  1.11  mrg 
    252  1.11  mrg static inline vec<ipa_agg_value_set>
    253  1.11  mrg ipa_copy_agg_values (const vec<ipa_agg_value_set> &aggs)
    254  1.11  mrg {
    255  1.11  mrg   vec<ipa_agg_value_set> aggs_copy = vNULL;
    256  1.11  mrg 
    257  1.11  mrg   if (!aggs.is_empty ())
    258  1.11  mrg     {
    259  1.11  mrg       ipa_agg_value_set *agg;
    260  1.11  mrg       int i;
    261  1.11  mrg 
    262  1.11  mrg       aggs_copy.reserve_exact (aggs.length ());
    263  1.11  mrg 
    264  1.11  mrg       FOR_EACH_VEC_ELT (aggs, i, agg)
    265  1.11  mrg 	aggs_copy.quick_push (agg->copy ());
    266  1.11  mrg     }
    267  1.11  mrg 
    268  1.11  mrg   return aggs_copy;
    269  1.11  mrg }
    270  1.11  mrg 
    271  1.11  mrg /* For vec<ipa_agg_value_set>, DO NOT call release(), use below function
    272  1.11  mrg    instead.  Because ipa_agg_value_set contains a field of vector type, we
    273  1.11  mrg    should release this child vector in each element before reclaiming the
    274  1.11  mrg    whole vector.  */
    275  1.11  mrg 
    276  1.11  mrg static inline void
    277  1.11  mrg ipa_release_agg_values (vec<ipa_agg_value_set> &aggs,
    278  1.11  mrg 			bool release_vector = true)
    279  1.11  mrg {
    280  1.11  mrg   ipa_agg_value_set *agg;
    281  1.11  mrg   int i;
    282  1.11  mrg 
    283  1.11  mrg   FOR_EACH_VEC_ELT (aggs, i, agg)
    284  1.11  mrg     agg->release ();
    285  1.11  mrg   if (release_vector)
    286  1.11  mrg     aggs.release ();
    287  1.11  mrg }
    288   1.5  mrg 
    289   1.8  mrg /* Information about zero/non-zero bits.  */
    290  1.11  mrg class GTY(()) ipa_bits
    291   1.8  mrg {
    292  1.11  mrg public:
    293   1.8  mrg   /* The propagated value.  */
    294   1.8  mrg   widest_int value;
    295   1.8  mrg   /* Mask corresponding to the value.
    296   1.8  mrg      Similar to ccp_lattice_t, if xth bit of mask is 0,
    297   1.8  mrg      implies xth bit of value is constant.  */
    298   1.8  mrg   widest_int mask;
    299   1.8  mrg };
    300   1.8  mrg 
    301   1.8  mrg /* Info about value ranges.  */
    302   1.8  mrg 
    303  1.11  mrg class GTY(()) ipa_vr
    304   1.5  mrg {
    305  1.11  mrg public:
    306   1.5  mrg   /* The data fields below are valid only if known is true.  */
    307   1.5  mrg   bool known;
    308  1.10  mrg   enum value_range_kind type;
    309   1.8  mrg   wide_int min;
    310   1.8  mrg   wide_int max;
    311  1.11  mrg   bool nonzero_p (tree) const;
    312   1.5  mrg };
    313   1.3  mrg 
    314   1.1  mrg /* A jump function for a callsite represents the values passed as actual
    315   1.1  mrg    arguments of the callsite. See enum jump_func_type for the various
    316   1.1  mrg    types of jump functions supported.  */
    317   1.5  mrg struct GTY (()) ipa_jump_func
    318   1.1  mrg {
    319  1.11  mrg   /* Aggregate jump function description.  See struct ipa_agg_jump_function
    320  1.11  mrg      and its description.  */
    321   1.3  mrg   struct ipa_agg_jump_function agg;
    322   1.3  mrg 
    323   1.8  mrg   /* Information about zero/non-zero bits.  The pointed to structure is shared
    324   1.8  mrg      betweed different jump functions.  Use ipa_set_jfunc_bits to set this
    325   1.8  mrg      field.  */
    326  1.11  mrg   class ipa_bits *bits;
    327   1.8  mrg 
    328   1.8  mrg   /* Information about value range, containing valid data only when vr_known is
    329   1.8  mrg      true.  The pointed to structure is shared betweed different jump
    330   1.8  mrg      functions.  Use ipa_set_jfunc_vr to set this field.  */
    331  1.12  mrg   value_range *m_vr;
    332   1.5  mrg 
    333   1.1  mrg   enum jump_func_type type;
    334   1.1  mrg   /* Represents a value of a jump function.  pass_through is used only in jump
    335   1.1  mrg      function context.  constant represents the actual constant in constant jump
    336   1.1  mrg      functions and member_cst holds constant c++ member functions.  */
    337   1.1  mrg   union jump_func_value
    338   1.1  mrg   {
    339   1.5  mrg     struct ipa_constant_data GTY ((tag ("IPA_JF_CONST"))) constant;
    340   1.1  mrg     struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
    341   1.1  mrg     struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
    342   1.1  mrg   } GTY ((desc ("%1.type"))) value;
    343   1.5  mrg };
    344   1.3  mrg 
    345   1.3  mrg 
    346   1.5  mrg /* Return the constant stored in a constant jump functin JFUNC.  */
    347   1.3  mrg 
    348   1.3  mrg static inline tree
    349   1.5  mrg ipa_get_jf_constant (struct ipa_jump_func *jfunc)
    350   1.3  mrg {
    351   1.5  mrg   gcc_checking_assert (jfunc->type == IPA_JF_CONST);
    352   1.5  mrg   return jfunc->value.constant.value;
    353   1.3  mrg }
    354   1.3  mrg 
    355   1.5  mrg static inline struct ipa_cst_ref_desc *
    356   1.5  mrg ipa_get_jf_constant_rdesc (struct ipa_jump_func *jfunc)
    357   1.3  mrg {
    358   1.3  mrg   gcc_checking_assert (jfunc->type == IPA_JF_CONST);
    359   1.5  mrg   return jfunc->value.constant.rdesc;
    360   1.3  mrg }
    361   1.3  mrg 
    362  1.12  mrg /* Make JFUNC not participate in any further reference counting.  */
    363  1.12  mrg 
    364  1.12  mrg inline void
    365  1.12  mrg ipa_zap_jf_refdesc (ipa_jump_func *jfunc)
    366  1.12  mrg {
    367  1.12  mrg   gcc_checking_assert (jfunc->type == IPA_JF_CONST);
    368  1.12  mrg   jfunc->value.constant.rdesc = NULL;
    369  1.12  mrg }
    370  1.12  mrg 
    371   1.3  mrg /* Return the operand of a pass through jmp function JFUNC.  */
    372   1.3  mrg 
    373   1.3  mrg static inline tree
    374   1.3  mrg ipa_get_jf_pass_through_operand (struct ipa_jump_func *jfunc)
    375   1.3  mrg {
    376   1.3  mrg   gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
    377   1.3  mrg   return jfunc->value.pass_through.operand;
    378   1.3  mrg }
    379   1.3  mrg 
    380   1.3  mrg /* Return the number of the caller's formal parameter that a pass through jump
    381   1.3  mrg    function JFUNC refers to.  */
    382   1.3  mrg 
    383   1.3  mrg static inline int
    384   1.3  mrg ipa_get_jf_pass_through_formal_id (struct ipa_jump_func *jfunc)
    385   1.3  mrg {
    386   1.3  mrg   gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
    387   1.3  mrg   return jfunc->value.pass_through.formal_id;
    388   1.3  mrg }
    389   1.3  mrg 
    390   1.3  mrg /* Return operation of a pass through jump function JFUNC.  */
    391   1.3  mrg 
    392   1.3  mrg static inline enum tree_code
    393   1.3  mrg ipa_get_jf_pass_through_operation (struct ipa_jump_func *jfunc)
    394   1.3  mrg {
    395   1.3  mrg   gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
    396   1.3  mrg   return jfunc->value.pass_through.operation;
    397   1.3  mrg }
    398   1.3  mrg 
    399   1.5  mrg /* Return the agg_preserved flag of a pass through jump function JFUNC.  */
    400   1.3  mrg 
    401   1.3  mrg static inline bool
    402   1.3  mrg ipa_get_jf_pass_through_agg_preserved (struct ipa_jump_func *jfunc)
    403   1.3  mrg {
    404   1.3  mrg   gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
    405   1.3  mrg   return jfunc->value.pass_through.agg_preserved;
    406   1.3  mrg }
    407   1.3  mrg 
    408  1.12  mrg /* Return the refdesc_decremented flag of a pass through jump function
    409  1.12  mrg    JFUNC.  */
    410  1.12  mrg 
    411  1.12  mrg inline bool
    412  1.12  mrg ipa_get_jf_pass_through_refdesc_decremented (struct ipa_jump_func *jfunc)
    413  1.12  mrg {
    414  1.12  mrg   gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
    415  1.12  mrg   return jfunc->value.pass_through.refdesc_decremented;
    416  1.12  mrg }
    417  1.12  mrg 
    418  1.12  mrg /* Set the refdesc_decremented flag of a pass through jump function JFUNC to
    419  1.12  mrg    VALUE.  */
    420  1.12  mrg 
    421  1.12  mrg inline void
    422  1.12  mrg ipa_set_jf_pass_through_refdesc_decremented (ipa_jump_func *jfunc, bool value)
    423  1.12  mrg {
    424  1.12  mrg   gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
    425  1.12  mrg   jfunc->value.pass_through.refdesc_decremented = value;
    426  1.12  mrg }
    427  1.12  mrg 
    428   1.5  mrg /* Return true if pass through jump function JFUNC preserves type
    429   1.5  mrg    information.  */
    430   1.5  mrg 
    431   1.5  mrg static inline bool
    432   1.5  mrg ipa_get_jf_pass_through_type_preserved (struct ipa_jump_func *jfunc)
    433   1.5  mrg {
    434   1.5  mrg   gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
    435   1.5  mrg   return jfunc->value.pass_through.agg_preserved;
    436   1.5  mrg }
    437   1.5  mrg 
    438   1.3  mrg /* Return the offset of an ancestor jump function JFUNC.  */
    439   1.3  mrg 
    440   1.3  mrg static inline HOST_WIDE_INT
    441   1.3  mrg ipa_get_jf_ancestor_offset (struct ipa_jump_func *jfunc)
    442   1.3  mrg {
    443   1.3  mrg   gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
    444   1.3  mrg   return jfunc->value.ancestor.offset;
    445   1.3  mrg }
    446   1.3  mrg 
    447   1.3  mrg /* Return the number of the caller's formal parameter that an ancestor jump
    448   1.3  mrg    function JFUNC refers to.  */
    449   1.3  mrg 
    450   1.3  mrg static inline int
    451   1.3  mrg ipa_get_jf_ancestor_formal_id (struct ipa_jump_func *jfunc)
    452   1.3  mrg {
    453   1.3  mrg   gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
    454   1.3  mrg   return jfunc->value.ancestor.formal_id;
    455   1.3  mrg }
    456   1.3  mrg 
    457   1.5  mrg /* Return the agg_preserved flag of an ancestor jump function JFUNC.  */
    458   1.1  mrg 
    459   1.3  mrg static inline bool
    460   1.3  mrg ipa_get_jf_ancestor_agg_preserved (struct ipa_jump_func *jfunc)
    461   1.1  mrg {
    462   1.3  mrg   gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
    463   1.3  mrg   return jfunc->value.ancestor.agg_preserved;
    464   1.3  mrg }
    465   1.1  mrg 
    466   1.5  mrg /* Return true if ancestor jump function JFUNC presrves type information.  */
    467   1.5  mrg 
    468   1.5  mrg static inline bool
    469   1.5  mrg ipa_get_jf_ancestor_type_preserved (struct ipa_jump_func *jfunc)
    470   1.5  mrg {
    471   1.5  mrg   gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
    472   1.5  mrg   return jfunc->value.ancestor.agg_preserved;
    473   1.5  mrg }
    474   1.5  mrg 
    475  1.11  mrg /* Return if jfunc represents an operation whether we first check the formal
    476  1.11  mrg    parameter for non-NULLness unless it does not matter because the offset is
    477  1.11  mrg    zero anyway.  */
    478  1.11  mrg 
    479  1.11  mrg static inline bool
    480  1.11  mrg ipa_get_jf_ancestor_keep_null (struct ipa_jump_func *jfunc)
    481  1.11  mrg {
    482  1.11  mrg   gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
    483  1.11  mrg   return jfunc->value.ancestor.keep_null;
    484  1.11  mrg }
    485  1.11  mrg 
    486  1.12  mrg /* Class for allocating a bundle of various potentially known properties about
    487  1.12  mrg    actual arguments of a particular call on stack for the usual case and on
    488  1.12  mrg    heap only if there are unusually many arguments.  The data is deallocated
    489  1.12  mrg    when the instance of this class goes out of scope or is otherwise
    490  1.12  mrg    destructed.  */
    491  1.12  mrg 
    492  1.12  mrg class ipa_auto_call_arg_values
    493  1.12  mrg {
    494  1.12  mrg public:
    495  1.12  mrg   ~ipa_auto_call_arg_values ();
    496  1.12  mrg 
    497  1.12  mrg   /* If m_known_vals (vector of known "scalar" values) is sufficiantly long,
    498  1.12  mrg      return its element at INDEX, otherwise return NULL.  */
    499  1.12  mrg   tree safe_sval_at (int index)
    500  1.12  mrg   {
    501  1.12  mrg     /* TODO: Assert non-negative index here and test.  */
    502  1.12  mrg     if ((unsigned) index < m_known_vals.length ())
    503  1.12  mrg       return m_known_vals[index];
    504  1.12  mrg     return NULL;
    505  1.12  mrg   }
    506  1.12  mrg 
    507  1.12  mrg   /* If m_known_aggs is sufficiantly long, return the pointer rto its element
    508  1.12  mrg      at INDEX, otherwise return NULL.  */
    509  1.12  mrg   ipa_agg_value_set *safe_aggval_at (int index)
    510  1.12  mrg   {
    511  1.12  mrg     /* TODO: Assert non-negative index here and test.  */
    512  1.12  mrg     if ((unsigned) index < m_known_aggs.length ())
    513  1.12  mrg       return &m_known_aggs[index];
    514  1.12  mrg     return NULL;
    515  1.12  mrg   }
    516  1.12  mrg 
    517  1.12  mrg   /* Vector describing known values of parameters.  */
    518  1.12  mrg   auto_vec<tree, 32> m_known_vals;
    519  1.12  mrg 
    520  1.12  mrg   /* Vector describing known polymorphic call contexts.  */
    521  1.12  mrg   auto_vec<ipa_polymorphic_call_context, 32> m_known_contexts;
    522  1.12  mrg 
    523  1.12  mrg   /* Vector describing known aggregate values.  */
    524  1.12  mrg   auto_vec<ipa_agg_value_set, 32> m_known_aggs;
    525  1.12  mrg 
    526  1.12  mrg   /* Vector describing known value ranges of arguments.  */
    527  1.12  mrg   auto_vec<value_range, 32> m_known_value_ranges;
    528  1.12  mrg };
    529  1.12  mrg 
    530  1.12  mrg /* Class bundling the various potentially known properties about actual
    531  1.12  mrg    arguments of a particular call.  This variant does not deallocate the
    532  1.12  mrg    bundled data in any way.  */
    533  1.12  mrg 
    534  1.12  mrg class ipa_call_arg_values
    535  1.12  mrg {
    536  1.12  mrg public:
    537  1.12  mrg   /* Default constructor, setting the vectors to empty ones.  */
    538  1.12  mrg   ipa_call_arg_values ()
    539  1.12  mrg   {}
    540  1.12  mrg 
    541  1.12  mrg   /* Construct this general variant of the bundle from the variant which uses
    542  1.12  mrg      auto_vecs to hold the vectors.  This means that vectors of objects
    543  1.12  mrg      constructed with this constructor should not be changed because if they
    544  1.12  mrg      get reallocated, the member vectors and the underlying auto_vecs would get
    545  1.12  mrg      out of sync.  */
    546  1.12  mrg   ipa_call_arg_values (ipa_auto_call_arg_values *aavals)
    547  1.12  mrg     : m_known_vals (aavals->m_known_vals.to_vec_legacy ()),
    548  1.12  mrg       m_known_contexts (aavals->m_known_contexts.to_vec_legacy ()),
    549  1.12  mrg       m_known_aggs (aavals->m_known_aggs.to_vec_legacy ()),
    550  1.12  mrg       m_known_value_ranges (aavals->m_known_value_ranges.to_vec_legacy ())
    551  1.12  mrg   {}
    552  1.12  mrg 
    553  1.12  mrg   /* If m_known_vals (vector of known "scalar" values) is sufficiantly long,
    554  1.12  mrg      return its element at INDEX, otherwise return NULL.  */
    555  1.12  mrg   tree safe_sval_at (int index)
    556  1.12  mrg   {
    557  1.12  mrg     /* TODO: Assert non-negative index here and test.  */
    558  1.12  mrg     if ((unsigned) index < m_known_vals.length ())
    559  1.12  mrg       return m_known_vals[index];
    560  1.12  mrg     return NULL;
    561  1.12  mrg   }
    562  1.12  mrg 
    563  1.12  mrg   /* If m_known_aggs is sufficiantly long, return the pointer rto its element
    564  1.12  mrg      at INDEX, otherwise return NULL.  */
    565  1.12  mrg   ipa_agg_value_set *safe_aggval_at (int index)
    566  1.12  mrg   {
    567  1.12  mrg     /* TODO: Assert non-negative index here and test.  */
    568  1.12  mrg     if ((unsigned) index < m_known_aggs.length ())
    569  1.12  mrg       return &m_known_aggs[index];
    570  1.12  mrg     return NULL;
    571  1.12  mrg   }
    572  1.12  mrg 
    573  1.12  mrg   /* Vector describing known values of parameters.  */
    574  1.12  mrg   vec<tree> m_known_vals = vNULL;
    575  1.12  mrg 
    576  1.12  mrg   /* Vector describing known polymorphic call contexts.  */
    577  1.12  mrg   vec<ipa_polymorphic_call_context> m_known_contexts = vNULL;
    578  1.12  mrg 
    579  1.12  mrg   /* Vector describing known aggregate values.  */
    580  1.12  mrg   vec<ipa_agg_value_set> m_known_aggs = vNULL;
    581  1.12  mrg 
    582  1.12  mrg   /* Vector describing known value ranges of arguments.  */
    583  1.12  mrg   vec<value_range> m_known_value_ranges = vNULL;
    584  1.12  mrg };
    585  1.12  mrg 
    586  1.12  mrg 
    587   1.3  mrg /* Summary describing a single formal parameter.  */
    588   1.1  mrg 
    589   1.8  mrg struct GTY(()) ipa_param_descriptor
    590   1.1  mrg {
    591   1.8  mrg   /* In analysis and modification phase, this is the PARAM_DECL of this
    592  1.11  mrg      parameter, in IPA LTO phase, this is the type of the described
    593   1.8  mrg      parameter or NULL if not known.  Do not read this field directly but
    594   1.8  mrg      through ipa_get_param and ipa_get_type as appropriate.  */
    595   1.8  mrg   tree decl_or_type;
    596   1.5  mrg   /* If all uses of the parameter are described by ipa-prop structures, this
    597   1.5  mrg      says how many there are.  If any use could not be described by means of
    598  1.12  mrg      ipa-prop structures (which include flag dereferenced below), this is
    599  1.12  mrg      IPA_UNDESCRIBED_USE.  */
    600   1.5  mrg   int controlled_uses;
    601  1.12  mrg   unsigned int move_cost : 27;
    602   1.3  mrg   /* The parameter is used.  */
    603   1.3  mrg   unsigned used : 1;
    604  1.11  mrg   unsigned used_by_ipa_predicates : 1;
    605  1.11  mrg   unsigned used_by_indirect_call : 1;
    606  1.11  mrg   unsigned used_by_polymorphic_call : 1;
    607  1.12  mrg   /* Set to true when in addition to being used in call statements, the
    608  1.12  mrg      parameter has also been used for loads (but not for writes, does not
    609  1.12  mrg      escape, etc.).  This allows us to identify parameters p which are only
    610  1.12  mrg      used as *p, and so when we propagate a constant to them, we can generate a
    611  1.12  mrg      LOAD and not ADDR reference to them.  */
    612  1.12  mrg   unsigned load_dereferenced : 1;
    613   1.1  mrg };
    614   1.1  mrg 
    615   1.1  mrg /* ipa_node_params stores information related to formal parameters of functions
    616   1.1  mrg    and some other information for interprocedural passes that operate on
    617   1.1  mrg    parameters (such as ipa-cp).  */
    618   1.3  mrg 
    619  1.11  mrg class GTY((for_user)) ipa_node_params
    620   1.1  mrg {
    621  1.11  mrg public:
    622   1.8  mrg   /* Default constructor.  */
    623   1.8  mrg   ipa_node_params ();
    624   1.8  mrg 
    625   1.8  mrg   /* Default destructor.  */
    626   1.5  mrg   ~ipa_node_params ();
    627   1.5  mrg 
    628   1.3  mrg   /* Information about individual formal parameters that are gathered when
    629   1.3  mrg      summaries are generated. */
    630   1.8  mrg   vec<ipa_param_descriptor, va_gc> *descriptors;
    631   1.1  mrg   /* Pointer to an array of structures describing individual formal
    632   1.1  mrg      parameters.  */
    633  1.11  mrg   class ipcp_param_lattices * GTY((skip)) lattices;
    634   1.1  mrg   /* Only for versioned nodes this field would not be NULL,
    635   1.1  mrg      it points to the node that IPA cp cloned from.  */
    636   1.8  mrg   struct cgraph_node * GTY((skip)) ipcp_orig_node;
    637   1.5  mrg   /* If this node is an ipa-cp clone, these are the known constants that
    638   1.5  mrg      describe what it has been specialized for.  */
    639   1.8  mrg   vec<tree> GTY((skip)) known_csts;
    640   1.5  mrg   /* If this node is an ipa-cp clone, these are the known polymorphic contexts
    641   1.5  mrg      that describe what it has been specialized for.  */
    642   1.8  mrg   vec<ipa_polymorphic_call_context> GTY((skip)) known_contexts;
    643   1.5  mrg   /* Whether the param uses analysis and jump function computation has already
    644   1.5  mrg      been performed.  */
    645   1.5  mrg   unsigned analysis_done : 1;
    646   1.3  mrg   /* Whether the function is enqueued in ipa-cp propagation stack.  */
    647   1.1  mrg   unsigned node_enqueued : 1;
    648   1.3  mrg   /* Whether we should create a specialized version based on values that are
    649   1.3  mrg      known to be constant in all contexts.  */
    650   1.3  mrg   unsigned do_clone_for_all_contexts : 1;
    651   1.3  mrg   /* Set if this is an IPA-CP clone for all contexts.  */
    652   1.3  mrg   unsigned is_all_contexts_clone : 1;
    653   1.3  mrg   /* Node has been completely replaced by clones and will be removed after
    654   1.3  mrg      ipa-cp is finished.  */
    655   1.3  mrg   unsigned node_dead : 1;
    656   1.5  mrg   /* Node is involved in a recursion, potentionally indirect.  */
    657   1.5  mrg   unsigned node_within_scc : 1;
    658  1.11  mrg   /* Node contains only direct recursion.  */
    659  1.11  mrg   unsigned node_is_self_scc : 1;
    660   1.5  mrg   /* Node is calling a private function called only once.  */
    661   1.5  mrg   unsigned node_calling_single_call : 1;
    662   1.6  mrg   /* False when there is something makes versioning impossible.  */
    663   1.6  mrg   unsigned versionable : 1;
    664   1.5  mrg };
    665   1.5  mrg 
    666   1.8  mrg inline
    667   1.8  mrg ipa_node_params::ipa_node_params ()
    668   1.8  mrg : descriptors (NULL), lattices (NULL), ipcp_orig_node (NULL),
    669   1.8  mrg   known_csts (vNULL), known_contexts (vNULL), analysis_done (0),
    670   1.8  mrg   node_enqueued (0), do_clone_for_all_contexts (0), is_all_contexts_clone (0),
    671  1.12  mrg   node_dead (0), node_within_scc (0), node_is_self_scc (0),
    672  1.12  mrg   node_calling_single_call (0), versionable (0)
    673   1.8  mrg {
    674   1.8  mrg }
    675   1.8  mrg 
    676   1.8  mrg inline
    677   1.8  mrg ipa_node_params::~ipa_node_params ()
    678   1.8  mrg {
    679   1.8  mrg   free (lattices);
    680  1.12  mrg   vec_free (descriptors);
    681   1.8  mrg   known_csts.release ();
    682   1.8  mrg   known_contexts.release ();
    683   1.8  mrg }
    684   1.8  mrg 
    685   1.5  mrg /* Intermediate information that we get from alias analysis about a particular
    686   1.5  mrg    parameter in a particular basic_block.  When a parameter or the memory it
    687   1.5  mrg    references is marked modified, we use that information in all dominated
    688   1.5  mrg    blocks without consulting alias analysis oracle.  */
    689   1.5  mrg 
    690   1.5  mrg struct ipa_param_aa_status
    691   1.5  mrg {
    692   1.5  mrg   /* Set when this structure contains meaningful information.  If not, the
    693   1.5  mrg      structure describing a dominating BB should be used instead.  */
    694   1.5  mrg   bool valid;
    695   1.5  mrg 
    696   1.5  mrg   /* Whether we have seen something which might have modified the data in
    697   1.5  mrg      question.  PARM is for the parameter itself, REF is for data it points to
    698   1.5  mrg      but using the alias type of individual accesses and PT is the same thing
    699   1.5  mrg      but for computing aggregate pass-through functions using a very inclusive
    700   1.5  mrg      ao_ref.  */
    701   1.5  mrg   bool parm_modified, ref_modified, pt_modified;
    702   1.5  mrg };
    703   1.5  mrg 
    704   1.5  mrg /* Information related to a given BB that used only when looking at function
    705   1.5  mrg    body.  */
    706   1.5  mrg 
    707   1.5  mrg struct ipa_bb_info
    708   1.5  mrg {
    709   1.5  mrg   /* Call graph edges going out of this BB.  */
    710   1.5  mrg   vec<cgraph_edge *> cg_edges;
    711   1.5  mrg   /* Alias analysis statuses of each formal parameter at this bb.  */
    712   1.5  mrg   vec<ipa_param_aa_status> param_aa_statuses;
    713   1.5  mrg };
    714   1.5  mrg 
    715   1.5  mrg /* Structure with global information that is only used when looking at function
    716   1.5  mrg    body. */
    717   1.5  mrg 
    718   1.5  mrg struct ipa_func_body_info
    719   1.5  mrg {
    720   1.5  mrg   /* The node that is being analyzed.  */
    721   1.5  mrg   cgraph_node *node;
    722   1.5  mrg 
    723   1.5  mrg   /* Its info.  */
    724  1.11  mrg   class ipa_node_params *info;
    725   1.5  mrg 
    726   1.5  mrg   /* Information about individual BBs. */
    727   1.5  mrg   vec<ipa_bb_info> bb_infos;
    728   1.5  mrg 
    729   1.5  mrg   /* Number of parameters.  */
    730   1.5  mrg   int param_count;
    731   1.5  mrg 
    732  1.10  mrg   /* Number of statements we are still allowed to walked by when analyzing this
    733  1.10  mrg      function.  */
    734  1.10  mrg   unsigned int aa_walk_budget;
    735   1.1  mrg };
    736   1.1  mrg 
    737   1.1  mrg /* ipa_node_params access functions.  Please use these to access fields that
    738   1.1  mrg    are or will be shared among various passes.  */
    739   1.1  mrg 
    740   1.1  mrg /* Return the number of formal parameters. */
    741   1.1  mrg 
    742   1.1  mrg static inline int
    743  1.11  mrg ipa_get_param_count (class ipa_node_params *info)
    744   1.1  mrg {
    745   1.8  mrg   return vec_safe_length (info->descriptors);
    746   1.1  mrg }
    747   1.1  mrg 
    748  1.12  mrg /* Return the parameter declaration in DESCRIPTORS at index I and assert it is
    749  1.12  mrg    indeed a PARM_DECL.  */
    750  1.12  mrg 
    751  1.12  mrg static inline tree
    752  1.12  mrg ipa_get_param (const vec<ipa_param_descriptor, va_gc> &descriptors, int i)
    753  1.12  mrg {
    754  1.12  mrg   tree t = descriptors[i].decl_or_type;
    755  1.12  mrg   gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
    756  1.12  mrg   return t;
    757  1.12  mrg }
    758  1.12  mrg 
    759   1.1  mrg /* Return the declaration of Ith formal parameter of the function corresponding
    760   1.1  mrg    to INFO.  Note there is no setter function as this array is built just once
    761   1.8  mrg    using ipa_initialize_node_params.  This function should not be called in
    762   1.8  mrg    WPA.  */
    763   1.1  mrg 
    764   1.1  mrg static inline tree
    765  1.11  mrg ipa_get_param (class ipa_node_params *info, int i)
    766   1.1  mrg {
    767   1.8  mrg   gcc_checking_assert (info->descriptors);
    768  1.12  mrg   return ipa_get_param (*info->descriptors, i);
    769   1.8  mrg }
    770   1.8  mrg 
    771   1.8  mrg /* Return the type of Ith formal parameter of the function corresponding
    772   1.8  mrg    to INFO if it is known or NULL if not.  */
    773   1.8  mrg 
    774   1.8  mrg static inline tree
    775  1.11  mrg ipa_get_type (class ipa_node_params *info, int i)
    776   1.8  mrg {
    777   1.9  mrg   if (vec_safe_length (info->descriptors) <= (unsigned) i)
    778   1.9  mrg     return NULL;
    779   1.8  mrg   tree t = (*info->descriptors)[i].decl_or_type;
    780   1.8  mrg   if (!t)
    781   1.8  mrg     return NULL;
    782   1.8  mrg   if (TYPE_P (t))
    783   1.8  mrg     return t;
    784   1.8  mrg   gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
    785   1.8  mrg   return TREE_TYPE (t);
    786   1.1  mrg }
    787   1.1  mrg 
    788   1.5  mrg /* Return the move cost of Ith formal parameter of the function corresponding
    789   1.5  mrg    to INFO.  */
    790   1.5  mrg 
    791   1.5  mrg static inline int
    792  1.11  mrg ipa_get_param_move_cost (class ipa_node_params *info, int i)
    793   1.5  mrg {
    794   1.8  mrg   gcc_checking_assert (info->descriptors);
    795   1.8  mrg   return (*info->descriptors)[i].move_cost;
    796   1.5  mrg }
    797   1.5  mrg 
    798   1.3  mrg /* Set the used flag corresponding to the Ith formal parameter of the function
    799   1.3  mrg    associated with INFO to VAL.  */
    800   1.1  mrg 
    801   1.3  mrg static inline void
    802  1.11  mrg ipa_set_param_used (class ipa_node_params *info, int i, bool val)
    803   1.1  mrg {
    804   1.8  mrg   gcc_checking_assert (info->descriptors);
    805   1.8  mrg   (*info->descriptors)[i].used = val;
    806   1.1  mrg }
    807   1.1  mrg 
    808  1.11  mrg /* Set the used_by_ipa_predicates flag corresponding to the Ith formal
    809  1.11  mrg    parameter of the function associated with INFO to VAL.  */
    810  1.11  mrg 
    811  1.11  mrg static inline void
    812  1.11  mrg ipa_set_param_used_by_ipa_predicates (class ipa_node_params *info, int i, bool val)
    813  1.11  mrg {
    814  1.11  mrg   gcc_checking_assert (info->descriptors);
    815  1.11  mrg   (*info->descriptors)[i].used_by_ipa_predicates = val;
    816  1.11  mrg }
    817  1.11  mrg 
    818  1.11  mrg /* Set the used_by_indirect_call flag corresponding to the Ith formal
    819  1.11  mrg    parameter of the function associated with INFO to VAL.  */
    820  1.11  mrg 
    821  1.11  mrg static inline void
    822  1.11  mrg ipa_set_param_used_by_indirect_call (class ipa_node_params *info, int i, bool val)
    823  1.11  mrg {
    824  1.11  mrg   gcc_checking_assert (info->descriptors);
    825  1.11  mrg   (*info->descriptors)[i].used_by_indirect_call = val;
    826  1.11  mrg }
    827  1.11  mrg 
    828  1.11  mrg /* Set the .used_by_polymorphic_call flag corresponding to the Ith formal
    829  1.11  mrg    parameter of the function associated with INFO to VAL.  */
    830  1.11  mrg 
    831  1.11  mrg static inline void
    832  1.11  mrg ipa_set_param_used_by_polymorphic_call (class ipa_node_params *info, int i, bool val)
    833  1.11  mrg {
    834  1.11  mrg   gcc_checking_assert (info->descriptors);
    835  1.11  mrg   (*info->descriptors)[i].used_by_polymorphic_call = val;
    836  1.11  mrg }
    837  1.11  mrg 
    838   1.5  mrg /* Return how many uses described by ipa-prop a parameter has or
    839   1.5  mrg    IPA_UNDESCRIBED_USE if there is a use that is not described by these
    840   1.5  mrg    structures.  */
    841   1.5  mrg static inline int
    842  1.11  mrg ipa_get_controlled_uses (class ipa_node_params *info, int i)
    843   1.5  mrg {
    844   1.8  mrg   /* FIXME: introducing speculation causes out of bounds access here.  */
    845   1.8  mrg   if (vec_safe_length (info->descriptors) > (unsigned)i)
    846   1.8  mrg     return (*info->descriptors)[i].controlled_uses;
    847   1.5  mrg   return IPA_UNDESCRIBED_USE;
    848   1.5  mrg }
    849   1.5  mrg 
    850   1.5  mrg /* Set the controlled counter of a given parameter.  */
    851   1.5  mrg 
    852   1.5  mrg static inline void
    853  1.11  mrg ipa_set_controlled_uses (class ipa_node_params *info, int i, int val)
    854   1.5  mrg {
    855   1.8  mrg   gcc_checking_assert (info->descriptors);
    856   1.8  mrg   (*info->descriptors)[i].controlled_uses = val;
    857   1.5  mrg }
    858   1.5  mrg 
    859  1.12  mrg /* Assuming a parameter does not have IPA_UNDESCRIBED_USE controlled uses,
    860  1.12  mrg    return flag which indicates it has been dereferenced but only in a load.  */
    861  1.12  mrg static inline int
    862  1.12  mrg ipa_get_param_load_dereferenced (class ipa_node_params *info, int i)
    863  1.12  mrg {
    864  1.12  mrg   gcc_assert (ipa_get_controlled_uses (info, i) != IPA_UNDESCRIBED_USE);
    865  1.12  mrg   return (*info->descriptors)[i].load_dereferenced;
    866  1.12  mrg }
    867  1.12  mrg 
    868  1.12  mrg /* Set the load_dereferenced flag of a given parameter.  */
    869  1.12  mrg 
    870  1.12  mrg static inline void
    871  1.12  mrg ipa_set_param_load_dereferenced (class ipa_node_params *info, int i, bool val)
    872  1.12  mrg {
    873  1.12  mrg   gcc_checking_assert (info->descriptors);
    874  1.12  mrg   (*info->descriptors)[i].load_dereferenced = val;
    875  1.12  mrg }
    876  1.12  mrg 
    877   1.3  mrg /* Return the used flag corresponding to the Ith formal parameter of the
    878   1.3  mrg    function associated with INFO.  */
    879   1.1  mrg 
    880   1.3  mrg static inline bool
    881  1.11  mrg ipa_is_param_used (class ipa_node_params *info, int i)
    882   1.1  mrg {
    883   1.8  mrg   gcc_checking_assert (info->descriptors);
    884   1.8  mrg   return (*info->descriptors)[i].used;
    885   1.1  mrg }
    886   1.1  mrg 
    887  1.11  mrg /* Return the used_by_ipa_predicates flag corresponding to the Ith formal
    888  1.11  mrg    parameter of the function associated with INFO.  */
    889  1.11  mrg 
    890  1.11  mrg static inline bool
    891  1.11  mrg ipa_is_param_used_by_ipa_predicates (class ipa_node_params *info, int i)
    892  1.11  mrg {
    893  1.11  mrg   gcc_checking_assert (info->descriptors);
    894  1.11  mrg   return (*info->descriptors)[i].used_by_ipa_predicates;
    895  1.11  mrg }
    896  1.11  mrg 
    897  1.11  mrg /* Return the used_by_indirect_call flag corresponding to the Ith formal
    898  1.11  mrg    parameter of the function associated with INFO.  */
    899  1.11  mrg 
    900  1.11  mrg static inline bool
    901  1.11  mrg ipa_is_param_used_by_indirect_call (class ipa_node_params *info, int i)
    902  1.11  mrg {
    903  1.11  mrg   gcc_checking_assert (info->descriptors);
    904  1.11  mrg   return (*info->descriptors)[i].used_by_indirect_call;
    905  1.11  mrg }
    906  1.11  mrg 
    907  1.11  mrg /* Return the used_by_polymorphic_call flag corresponding to the Ith formal
    908  1.11  mrg    parameter of the function associated with INFO.  */
    909  1.11  mrg 
    910  1.11  mrg static inline bool
    911  1.11  mrg ipa_is_param_used_by_polymorphic_call (class ipa_node_params *info, int i)
    912  1.11  mrg {
    913  1.11  mrg   gcc_checking_assert (info->descriptors);
    914  1.11  mrg   return (*info->descriptors)[i].used_by_polymorphic_call;
    915  1.11  mrg }
    916  1.11  mrg 
    917   1.3  mrg /* Information about replacements done in aggregates for a given node (each
    918   1.3  mrg    node has its linked list).  */
    919   1.3  mrg struct GTY(()) ipa_agg_replacement_value
    920   1.1  mrg {
    921   1.3  mrg   /* Next item in the linked list.  */
    922   1.3  mrg   struct ipa_agg_replacement_value *next;
    923   1.3  mrg   /* Offset within the aggregate.  */
    924   1.3  mrg   HOST_WIDE_INT offset;
    925   1.3  mrg   /* The constant value.  */
    926   1.3  mrg   tree value;
    927  1.11  mrg   /* The parameter index.  */
    928   1.3  mrg   int index;
    929   1.3  mrg   /* Whether the value was passed by reference.  */
    930   1.3  mrg   bool by_ref;
    931   1.3  mrg };
    932   1.1  mrg 
    933   1.5  mrg /* Structure holding information for the transformation phase of IPA-CP.  */
    934   1.5  mrg 
    935  1.10  mrg struct GTY(()) ipcp_transformation
    936   1.5  mrg {
    937   1.5  mrg   /* Linked list of known aggregate values.  */
    938   1.5  mrg   ipa_agg_replacement_value *agg_values;
    939   1.8  mrg   /* Known bits information.  */
    940   1.8  mrg   vec<ipa_bits *, va_gc> *bits;
    941   1.8  mrg   /* Value range information.  */
    942   1.8  mrg   vec<ipa_vr, va_gc> *m_vr;
    943  1.11  mrg 
    944  1.11  mrg   /* Default constructor.  */
    945  1.11  mrg   ipcp_transformation ()
    946  1.11  mrg   : agg_values (NULL), bits (NULL), m_vr (NULL)
    947  1.11  mrg   { }
    948  1.11  mrg 
    949  1.11  mrg   /* Default destructor.  */
    950  1.11  mrg   ~ipcp_transformation ()
    951  1.11  mrg   {
    952  1.11  mrg     ipa_agg_replacement_value *agg = agg_values;
    953  1.11  mrg     while (agg)
    954  1.11  mrg       {
    955  1.11  mrg 	ipa_agg_replacement_value *next = agg->next;
    956  1.11  mrg 	ggc_free (agg);
    957  1.11  mrg 	agg = next;
    958  1.11  mrg       }
    959  1.11  mrg     vec_free (bits);
    960  1.11  mrg     vec_free (m_vr);
    961  1.11  mrg   }
    962   1.5  mrg };
    963   1.1  mrg 
    964   1.3  mrg void ipa_set_node_agg_value_chain (struct cgraph_node *node,
    965   1.3  mrg 				   struct ipa_agg_replacement_value *aggvals);
    966  1.10  mrg void ipcp_transformation_initialize (void);
    967  1.10  mrg void ipcp_free_transformation_sum (void);
    968   1.1  mrg 
    969   1.3  mrg /* ipa_edge_args stores information related to a callsite and particularly its
    970   1.3  mrg    arguments.  It can be accessed by the IPA_EDGE_REF macro.  */
    971   1.9  mrg 
    972   1.9  mrg class GTY((for_user)) ipa_edge_args
    973   1.1  mrg {
    974   1.9  mrg  public:
    975   1.9  mrg 
    976   1.9  mrg   /* Default constructor.  */
    977   1.9  mrg   ipa_edge_args () : jump_functions (NULL), polymorphic_call_contexts (NULL)
    978   1.9  mrg     {}
    979   1.9  mrg 
    980   1.9  mrg   /* Destructor.  */
    981   1.9  mrg   ~ipa_edge_args ()
    982   1.9  mrg     {
    983  1.12  mrg       unsigned int i;
    984  1.12  mrg       ipa_jump_func *jf;
    985  1.12  mrg       FOR_EACH_VEC_SAFE_ELT (jump_functions, i, jf)
    986  1.12  mrg 	vec_free (jf->agg.items);
    987   1.9  mrg       vec_free (jump_functions);
    988   1.9  mrg       vec_free (polymorphic_call_contexts);
    989   1.9  mrg     }
    990   1.9  mrg 
    991   1.9  mrg   /* Vectors of the callsite's jump function and polymorphic context
    992   1.9  mrg      information of each parameter.  */
    993   1.5  mrg   vec<ipa_jump_func, va_gc> *jump_functions;
    994   1.5  mrg   vec<ipa_polymorphic_call_context, va_gc> *polymorphic_call_contexts;
    995   1.5  mrg };
    996   1.1  mrg 
    997   1.1  mrg /* ipa_edge_args access functions.  Please use these to access fields that
    998   1.1  mrg    are or will be shared among various passes.  */
    999   1.1  mrg 
   1000   1.1  mrg /* Return the number of actual arguments. */
   1001   1.1  mrg 
   1002   1.1  mrg static inline int
   1003  1.11  mrg ipa_get_cs_argument_count (class ipa_edge_args *args)
   1004   1.1  mrg {
   1005   1.3  mrg   return vec_safe_length (args->jump_functions);
   1006   1.1  mrg }
   1007   1.1  mrg 
   1008   1.1  mrg /* Returns a pointer to the jump function for the ith argument.  Please note
   1009   1.1  mrg    there is no setter function as jump functions are all set up in
   1010   1.1  mrg    ipa_compute_jump_functions. */
   1011   1.1  mrg 
   1012   1.1  mrg static inline struct ipa_jump_func *
   1013  1.11  mrg ipa_get_ith_jump_func (class ipa_edge_args *args, int i)
   1014   1.1  mrg {
   1015   1.3  mrg   return &(*args->jump_functions)[i];
   1016   1.1  mrg }
   1017   1.1  mrg 
   1018   1.5  mrg /* Returns a pointer to the polymorphic call context for the ith argument.
   1019   1.5  mrg    NULL if contexts are not computed.  */
   1020  1.11  mrg static inline class ipa_polymorphic_call_context *
   1021  1.11  mrg ipa_get_ith_polymorhic_call_context (class ipa_edge_args *args, int i)
   1022   1.5  mrg {
   1023   1.5  mrg   if (!args->polymorphic_call_contexts)
   1024   1.5  mrg     return NULL;
   1025   1.5  mrg   return &(*args->polymorphic_call_contexts)[i];
   1026   1.5  mrg }
   1027   1.1  mrg 
   1028   1.5  mrg /* Function summary for ipa_node_params.  */
   1029   1.8  mrg class GTY((user)) ipa_node_params_t: public function_summary <ipa_node_params *>
   1030   1.5  mrg {
   1031   1.5  mrg public:
   1032   1.8  mrg   ipa_node_params_t (symbol_table *table, bool ggc):
   1033  1.12  mrg     function_summary<ipa_node_params *> (table, ggc)
   1034  1.12  mrg   {
   1035  1.12  mrg     disable_insertion_hook ();
   1036  1.12  mrg   }
   1037   1.5  mrg 
   1038   1.5  mrg   /* Hook that is called by summary when a node is duplicated.  */
   1039   1.5  mrg   virtual void duplicate (cgraph_node *node,
   1040   1.5  mrg 			  cgraph_node *node2,
   1041   1.5  mrg 			  ipa_node_params *data,
   1042   1.5  mrg 			  ipa_node_params *data2);
   1043   1.5  mrg };
   1044   1.1  mrg 
   1045   1.9  mrg /* Summary to manange ipa_edge_args structures.  */
   1046   1.9  mrg 
   1047   1.9  mrg class GTY((user)) ipa_edge_args_sum_t : public call_summary <ipa_edge_args *>
   1048   1.9  mrg {
   1049   1.9  mrg  public:
   1050   1.9  mrg   ipa_edge_args_sum_t (symbol_table *table, bool ggc)
   1051   1.9  mrg     : call_summary<ipa_edge_args *> (table, ggc) { }
   1052   1.9  mrg 
   1053  1.11  mrg   void remove (cgraph_edge *edge)
   1054  1.11  mrg   {
   1055  1.11  mrg     call_summary <ipa_edge_args *>::remove (edge);
   1056  1.11  mrg   }
   1057  1.11  mrg 
   1058  1.11  mrg   /* Hook that is called by summary when an edge is removed.  */
   1059   1.9  mrg   virtual void remove (cgraph_edge *cs, ipa_edge_args *args);
   1060   1.9  mrg   /* Hook that is called by summary when an edge is duplicated.  */
   1061   1.9  mrg   virtual void duplicate (cgraph_edge *src,
   1062   1.9  mrg 			  cgraph_edge *dst,
   1063   1.9  mrg 			  ipa_edge_args *old_args,
   1064   1.9  mrg 			  ipa_edge_args *new_args);
   1065   1.9  mrg };
   1066   1.9  mrg 
   1067   1.5  mrg /* Function summary where the parameter infos are actually stored. */
   1068   1.8  mrg extern GTY(()) ipa_node_params_t * ipa_node_params_sum;
   1069   1.9  mrg /* Call summary to store information about edges such as jump functions.  */
   1070   1.9  mrg extern GTY(()) ipa_edge_args_sum_t *ipa_edge_args_sum;
   1071   1.8  mrg 
   1072  1.10  mrg /* Function summary for IPA-CP transformation.  */
   1073  1.10  mrg class ipcp_transformation_t
   1074  1.10  mrg : public function_summary<ipcp_transformation *>
   1075  1.10  mrg {
   1076  1.10  mrg public:
   1077  1.10  mrg   ipcp_transformation_t (symbol_table *table, bool ggc):
   1078  1.10  mrg     function_summary<ipcp_transformation *> (table, ggc) {}
   1079  1.10  mrg 
   1080  1.10  mrg   ~ipcp_transformation_t () {}
   1081  1.10  mrg 
   1082  1.10  mrg   static ipcp_transformation_t *create_ggc (symbol_table *symtab)
   1083  1.10  mrg   {
   1084  1.10  mrg     ipcp_transformation_t *summary
   1085  1.11  mrg       = new (ggc_alloc_no_dtor <ipcp_transformation_t> ())
   1086  1.10  mrg       ipcp_transformation_t (symtab, true);
   1087  1.10  mrg     return summary;
   1088  1.10  mrg   }
   1089  1.11  mrg   /* Hook that is called by summary when a node is duplicated.  */
   1090  1.11  mrg   virtual void duplicate (cgraph_node *node,
   1091  1.11  mrg 			  cgraph_node *node2,
   1092  1.11  mrg 			  ipcp_transformation *data,
   1093  1.11  mrg 			  ipcp_transformation *data2);
   1094  1.10  mrg };
   1095  1.10  mrg 
   1096  1.10  mrg /* Function summary where the IPA CP transformations are actually stored.  */
   1097  1.10  mrg extern GTY(()) function_summary <ipcp_transformation *> *ipcp_transformation_sum;
   1098   1.8  mrg 
   1099   1.1  mrg /* Creating and freeing ipa_node_params and ipa_edge_args.  */
   1100   1.1  mrg void ipa_create_all_node_params (void);
   1101   1.1  mrg void ipa_create_all_edge_args (void);
   1102   1.8  mrg void ipa_check_create_edge_args (void);
   1103   1.1  mrg void ipa_free_all_node_params (void);
   1104   1.1  mrg void ipa_free_all_edge_args (void);
   1105   1.3  mrg void ipa_free_all_structures_after_ipa_cp (void);
   1106   1.3  mrg void ipa_free_all_structures_after_iinln (void);
   1107   1.5  mrg 
   1108   1.1  mrg void ipa_register_cgraph_hooks (void);
   1109   1.5  mrg int count_formal_params (tree fndecl);
   1110   1.1  mrg 
   1111   1.1  mrg /* This function ensures the array of node param infos is big enough to
   1112   1.1  mrg    accommodate a structure for all nodes and reallocates it if not.  */
   1113   1.1  mrg 
   1114   1.1  mrg static inline void
   1115   1.1  mrg ipa_check_create_node_params (void)
   1116   1.1  mrg {
   1117   1.5  mrg   if (!ipa_node_params_sum)
   1118   1.8  mrg     ipa_node_params_sum
   1119  1.11  mrg       = (new (ggc_alloc_no_dtor <ipa_node_params_t> ())
   1120   1.8  mrg 	 ipa_node_params_t (symtab, true));
   1121   1.1  mrg }
   1122   1.1  mrg 
   1123   1.9  mrg /* Returns true if edge summary contains a record for EDGE.  The main purpose
   1124   1.9  mrg    of this function is that debug dumping function can check info availability
   1125   1.9  mrg    without causing allocations.  */
   1126   1.1  mrg 
   1127   1.1  mrg static inline bool
   1128   1.1  mrg ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge)
   1129   1.1  mrg {
   1130   1.9  mrg   return ipa_edge_args_sum->exists (edge);
   1131   1.1  mrg }
   1132   1.1  mrg 
   1133  1.10  mrg static inline ipcp_transformation *
   1134   1.5  mrg ipcp_get_transformation_summary (cgraph_node *node)
   1135   1.5  mrg {
   1136  1.10  mrg   if (ipcp_transformation_sum == NULL)
   1137   1.5  mrg     return NULL;
   1138  1.10  mrg 
   1139  1.10  mrg   return ipcp_transformation_sum->get (node);
   1140   1.5  mrg }
   1141   1.5  mrg 
   1142   1.3  mrg /* Return the aggregate replacements for NODE, if there are any.  */
   1143   1.1  mrg 
   1144   1.3  mrg static inline struct ipa_agg_replacement_value *
   1145   1.5  mrg ipa_get_agg_replacements_for_node (cgraph_node *node)
   1146   1.1  mrg {
   1147  1.10  mrg   ipcp_transformation *ts = ipcp_get_transformation_summary (node);
   1148   1.5  mrg   return ts ? ts->agg_values : NULL;
   1149   1.1  mrg }
   1150   1.1  mrg 
   1151   1.1  mrg /* Function formal parameters related computations.  */
   1152   1.1  mrg void ipa_initialize_node_params (struct cgraph_node *node);
   1153   1.1  mrg bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
   1154   1.5  mrg 					vec<cgraph_edge *> *new_edges);
   1155   1.3  mrg 
   1156  1.12  mrg /* Indirect edge processing and target discovery.  */
   1157   1.3  mrg tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
   1158  1.12  mrg 				   ipa_call_arg_values *avals,
   1159  1.12  mrg 				   bool *speculative);
   1160  1.12  mrg tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
   1161  1.12  mrg 				   ipa_auto_call_arg_values *avals,
   1162  1.12  mrg 				   bool *speculative);
   1163   1.5  mrg struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree,
   1164   1.5  mrg 						    bool speculative = false);
   1165   1.5  mrg tree ipa_impossible_devirt_target (struct cgraph_edge *, tree);
   1166   1.8  mrg ipa_bits *ipa_get_ipa_bits_for_value (const widest_int &value,
   1167   1.8  mrg 				      const widest_int &mask);
   1168   1.8  mrg 
   1169   1.3  mrg 
   1170   1.3  mrg /* Functions related to both.  */
   1171   1.3  mrg void ipa_analyze_node (struct cgraph_node *);
   1172   1.3  mrg 
   1173   1.3  mrg /* Aggregate jump function related functions.  */
   1174  1.12  mrg tree ipa_find_agg_cst_for_param (const ipa_agg_value_set *agg, tree scalar,
   1175   1.8  mrg 				 HOST_WIDE_INT offset, bool by_ref,
   1176   1.8  mrg 				 bool *from_global_constant = NULL);
   1177   1.8  mrg bool ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
   1178   1.8  mrg 			     vec<ipa_param_descriptor, va_gc> *descriptors,
   1179   1.8  mrg 			     gimple *stmt, tree op, int *index_p,
   1180  1.11  mrg 			     HOST_WIDE_INT *offset_p, poly_int64 *size_p,
   1181   1.8  mrg 			     bool *by_ref, bool *guaranteed_unmodified = NULL);
   1182   1.1  mrg 
   1183   1.1  mrg /* Debugging interface.  */
   1184   1.1  mrg void ipa_print_node_params (FILE *, struct cgraph_node *node);
   1185   1.1  mrg void ipa_print_all_params (FILE *);
   1186   1.1  mrg void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
   1187   1.1  mrg void ipa_print_all_jump_functions (FILE * f);
   1188   1.3  mrg void ipcp_verify_propagated_values (void);
   1189   1.3  mrg 
   1190   1.6  mrg template <typename value>
   1191   1.6  mrg class ipcp_value;
   1192   1.6  mrg 
   1193   1.6  mrg extern object_allocator<ipcp_value<tree> > ipcp_cst_values_pool;
   1194   1.6  mrg extern object_allocator<ipcp_value<ipa_polymorphic_call_context> >
   1195   1.6  mrg   ipcp_poly_ctx_values_pool;
   1196   1.6  mrg 
   1197   1.6  mrg template <typename valtype>
   1198  1.11  mrg struct ipcp_value_source;
   1199   1.6  mrg 
   1200   1.6  mrg extern object_allocator<ipcp_value_source<tree> > ipcp_sources_pool;
   1201   1.6  mrg 
   1202  1.11  mrg struct ipcp_agg_lattice;
   1203   1.6  mrg 
   1204   1.6  mrg extern object_allocator<ipcp_agg_lattice> ipcp_agg_lattice_pool;
   1205   1.1  mrg 
   1206   1.3  mrg void ipa_dump_agg_replacement_values (FILE *f,
   1207   1.3  mrg 				      struct ipa_agg_replacement_value *av);
   1208   1.3  mrg void ipa_prop_write_jump_functions (void);
   1209   1.1  mrg void ipa_prop_read_jump_functions (void);
   1210   1.5  mrg void ipcp_write_transformation_summaries (void);
   1211   1.5  mrg void ipcp_read_transformation_summaries (void);
   1212  1.11  mrg int ipa_get_param_decl_index (class ipa_node_params *, tree);
   1213  1.11  mrg tree ipa_value_from_jfunc (class ipa_node_params *info,
   1214   1.9  mrg 			   struct ipa_jump_func *jfunc, tree type);
   1215   1.3  mrg unsigned int ipcp_transform_function (struct cgraph_node *node);
   1216   1.5  mrg ipa_polymorphic_call_context ipa_context_from_jfunc (ipa_node_params *,
   1217   1.5  mrg 						     cgraph_edge *,
   1218   1.5  mrg 						     int,
   1219   1.5  mrg 						     ipa_jump_func *);
   1220  1.11  mrg value_range ipa_value_range_from_jfunc (ipa_node_params *, cgraph_edge *,
   1221  1.11  mrg 					ipa_jump_func *, tree);
   1222  1.11  mrg ipa_agg_value_set ipa_agg_value_set_from_jfunc (ipa_node_params *,
   1223  1.11  mrg 						cgraph_node *,
   1224  1.11  mrg 						ipa_agg_jump_function *);
   1225  1.11  mrg void ipa_dump_param (FILE *, class ipa_node_params *info, int i);
   1226   1.6  mrg void ipa_release_body_info (struct ipa_func_body_info *);
   1227   1.8  mrg tree ipa_get_callee_param_type (struct cgraph_edge *e, int i);
   1228  1.11  mrg bool ipcp_get_parm_bits (tree, tree *, widest_int *);
   1229  1.12  mrg bool unadjusted_ptr_and_unit_offset (tree op, tree *ret,
   1230  1.12  mrg 				     poly_int64 *offset_ret);
   1231  1.12  mrg 
   1232  1.12  mrg bool ipa_jump_functions_equivalent_p (ipa_jump_func *jf1, ipa_jump_func *jf2);
   1233   1.1  mrg 
   1234  1.12  mrg /* From tree-sra.cc:  */
   1235   1.9  mrg tree build_ref_for_offset (location_t, tree, poly_int64, bool, tree,
   1236   1.3  mrg 			   gimple_stmt_iterator *, bool);
   1237   1.1  mrg 
   1238  1.12  mrg /* In ipa-cp.cc  */
   1239  1.12  mrg void ipa_cp_cc_finalize (void);
   1240  1.12  mrg bool values_equal_for_ipcp_p (tree x, tree y);
   1241   1.5  mrg 
   1242   1.1  mrg #endif /* IPA_PROP_H */
   1243