ipa-prop.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. /* Interprocedural analyses.
  2. Copyright (C) 2005-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef IPA_PROP_H
  16. #define IPA_PROP_H
  17. /* The following definitions and interfaces are used by
  18. interprocedural analyses or parameters. */
  19. #define IPA_UNDESCRIBED_USE -1
  20. /* ipa-prop.c stuff (ipa-cp, indirect inlining): */
  21. /* A jump function for a callsite represents the values passed as actual
  22. arguments of the callsite. They were originally proposed in a paper called
  23. "Interprocedural Constant Propagation", by David Callahan, Keith D Cooper,
  24. Ken Kennedy, Linda Torczon in Comp86, pg 152-161. There are three main
  25. types of values :
  26. Pass-through - the caller's formal parameter is passed as an actual
  27. argument, possibly one simple operation performed on it.
  28. Constant - a constant (is_gimple_ip_invariant)is passed as an actual
  29. argument.
  30. Unknown - neither of the above.
  31. IPA_JF_ANCESTOR is a special pass-through jump function, which means that
  32. the result is an address of a part of the object pointed to by the formal
  33. parameter to which the function refers. It is mainly intended to represent
  34. getting addresses of of ancestor fields in C++
  35. (e.g. &this_1(D)->D.1766.D.1756). Note that if the original pointer is
  36. NULL, ancestor jump function must behave like a simple pass-through.
  37. Other pass-through functions can either simply pass on an unchanged formal
  38. parameter or can apply one simple binary operation to it (such jump
  39. functions are called polynomial).
  40. Jump functions are computed in ipa-prop.c by function
  41. update_call_notes_after_inlining. Some information can be lost and jump
  42. functions degraded accordingly when inlining, see
  43. update_call_notes_after_inlining in the same file. */
  44. enum jump_func_type
  45. {
  46. IPA_JF_UNKNOWN = 0, /* newly allocated and zeroed jump functions default */
  47. IPA_JF_CONST, /* represented by field costant */
  48. IPA_JF_PASS_THROUGH, /* represented by field pass_through */
  49. IPA_JF_ANCESTOR /* represented by field ancestor */
  50. };
  51. struct ipa_cst_ref_desc;
  52. /* Structure holding data required to describe a constant jump function. */
  53. struct GTY(()) ipa_constant_data
  54. {
  55. /* THe value of the constant. */
  56. tree value;
  57. /* Pointer to the structure that describes the reference. */
  58. struct ipa_cst_ref_desc GTY((skip)) *rdesc;
  59. };
  60. /* Structure holding data required to describe a pass-through jump function. */
  61. struct GTY(()) ipa_pass_through_data
  62. {
  63. /* If an operation is to be performed on the original parameter, this is the
  64. second (constant) operand. */
  65. tree operand;
  66. /* Number of the caller's formal parameter being passed. */
  67. int formal_id;
  68. /* Operation that is performed on the argument before it is passed on.
  69. NOP_EXPR means no operation. Otherwise oper must be a simple binary
  70. arithmetic operation where the caller's parameter is the first operand and
  71. operand field from this structure is the second one. */
  72. enum tree_code operation;
  73. /* When the passed value is a pointer, it is set to true only when we are
  74. certain that no write to the object it points to has occurred since the
  75. caller functions started execution, except for changes noted in the
  76. aggregate part of the jump function (see description of
  77. ipa_agg_jump_function). The flag is used only when the operation is
  78. NOP_EXPR. */
  79. unsigned agg_preserved : 1;
  80. };
  81. /* Structure holding data required to describe an ancestor pass-through
  82. jump function. */
  83. struct GTY(()) ipa_ancestor_jf_data
  84. {
  85. /* Offset of the field representing the ancestor. */
  86. HOST_WIDE_INT offset;
  87. /* Number of the caller's formal parameter being passed. */
  88. int formal_id;
  89. /* Flag with the same meaning like agg_preserve in ipa_pass_through_data. */
  90. unsigned agg_preserved : 1;
  91. };
  92. /* An element in an aggegate part of a jump function describing a known value
  93. at a given offset. When it is part of a pass-through jump function with
  94. agg_preserved set or an ancestor jump function with agg_preserved set, all
  95. unlisted positions are assumed to be preserved but the value can be a type
  96. node, which means that the particular piece (starting at offset and having
  97. the size of the type) is clobbered with an unknown value. When
  98. agg_preserved is false or the type of the containing jump function is
  99. different, all unlisted parts are assumed to be unknown and all values must
  100. fulfill is_gimple_ip_invariant. */
  101. struct GTY(()) ipa_agg_jf_item
  102. {
  103. /* The offset at which the known value is located within the aggregate. */
  104. HOST_WIDE_INT offset;
  105. /* The known constant or type if this is a clobber. */
  106. tree value;
  107. };
  108. /* Aggregate jump function - i.e. description of contents of aggregates passed
  109. either by reference or value. */
  110. struct GTY(()) ipa_agg_jump_function
  111. {
  112. /* Description of the individual items. */
  113. vec<ipa_agg_jf_item, va_gc> *items;
  114. /* True if the data was passed by reference (as opposed to by value). */
  115. bool by_ref;
  116. };
  117. typedef struct ipa_agg_jump_function *ipa_agg_jump_function_p;
  118. /* Info about pointer alignments. */
  119. struct GTY(()) ipa_alignment
  120. {
  121. /* The data fields below are valid only if known is true. */
  122. bool known;
  123. /* See ptr_info_def and get_pointer_alignment_1 for description of these
  124. two. */
  125. unsigned align;
  126. unsigned misalign;
  127. };
  128. /* A jump function for a callsite represents the values passed as actual
  129. arguments of the callsite. See enum jump_func_type for the various
  130. types of jump functions supported. */
  131. struct GTY (()) ipa_jump_func
  132. {
  133. /* Aggregate contants description. See struct ipa_agg_jump_function and its
  134. description. */
  135. struct ipa_agg_jump_function agg;
  136. /* Information about alignment of pointers. */
  137. struct ipa_alignment alignment;
  138. enum jump_func_type type;
  139. /* Represents a value of a jump function. pass_through is used only in jump
  140. function context. constant represents the actual constant in constant jump
  141. functions and member_cst holds constant c++ member functions. */
  142. union jump_func_value
  143. {
  144. struct ipa_constant_data GTY ((tag ("IPA_JF_CONST"))) constant;
  145. struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
  146. struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
  147. } GTY ((desc ("%1.type"))) value;
  148. };
  149. /* Return the constant stored in a constant jump functin JFUNC. */
  150. static inline tree
  151. ipa_get_jf_constant (struct ipa_jump_func *jfunc)
  152. {
  153. gcc_checking_assert (jfunc->type == IPA_JF_CONST);
  154. return jfunc->value.constant.value;
  155. }
  156. static inline struct ipa_cst_ref_desc *
  157. ipa_get_jf_constant_rdesc (struct ipa_jump_func *jfunc)
  158. {
  159. gcc_checking_assert (jfunc->type == IPA_JF_CONST);
  160. return jfunc->value.constant.rdesc;
  161. }
  162. /* Return the operand of a pass through jmp function JFUNC. */
  163. static inline tree
  164. ipa_get_jf_pass_through_operand (struct ipa_jump_func *jfunc)
  165. {
  166. gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
  167. return jfunc->value.pass_through.operand;
  168. }
  169. /* Return the number of the caller's formal parameter that a pass through jump
  170. function JFUNC refers to. */
  171. static inline int
  172. ipa_get_jf_pass_through_formal_id (struct ipa_jump_func *jfunc)
  173. {
  174. gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
  175. return jfunc->value.pass_through.formal_id;
  176. }
  177. /* Return operation of a pass through jump function JFUNC. */
  178. static inline enum tree_code
  179. ipa_get_jf_pass_through_operation (struct ipa_jump_func *jfunc)
  180. {
  181. gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
  182. return jfunc->value.pass_through.operation;
  183. }
  184. /* Return the agg_preserved flag of a pass through jump function JFUNC. */
  185. static inline bool
  186. ipa_get_jf_pass_through_agg_preserved (struct ipa_jump_func *jfunc)
  187. {
  188. gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
  189. return jfunc->value.pass_through.agg_preserved;
  190. }
  191. /* Return true if pass through jump function JFUNC preserves type
  192. information. */
  193. static inline bool
  194. ipa_get_jf_pass_through_type_preserved (struct ipa_jump_func *jfunc)
  195. {
  196. gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
  197. return jfunc->value.pass_through.agg_preserved;
  198. }
  199. /* Return the offset of an ancestor jump function JFUNC. */
  200. static inline HOST_WIDE_INT
  201. ipa_get_jf_ancestor_offset (struct ipa_jump_func *jfunc)
  202. {
  203. gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
  204. return jfunc->value.ancestor.offset;
  205. }
  206. /* Return the number of the caller's formal parameter that an ancestor jump
  207. function JFUNC refers to. */
  208. static inline int
  209. ipa_get_jf_ancestor_formal_id (struct ipa_jump_func *jfunc)
  210. {
  211. gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
  212. return jfunc->value.ancestor.formal_id;
  213. }
  214. /* Return the agg_preserved flag of an ancestor jump function JFUNC. */
  215. static inline bool
  216. ipa_get_jf_ancestor_agg_preserved (struct ipa_jump_func *jfunc)
  217. {
  218. gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
  219. return jfunc->value.ancestor.agg_preserved;
  220. }
  221. /* Return true if ancestor jump function JFUNC presrves type information. */
  222. static inline bool
  223. ipa_get_jf_ancestor_type_preserved (struct ipa_jump_func *jfunc)
  224. {
  225. gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
  226. return jfunc->value.ancestor.agg_preserved;
  227. }
  228. /* Summary describing a single formal parameter. */
  229. struct ipa_param_descriptor
  230. {
  231. /* PARAM_DECL of this parameter. */
  232. tree decl;
  233. /* If all uses of the parameter are described by ipa-prop structures, this
  234. says how many there are. If any use could not be described by means of
  235. ipa-prop structures, this is IPA_UNDESCRIBED_USE. */
  236. int controlled_uses;
  237. unsigned int move_cost : 31;
  238. /* The parameter is used. */
  239. unsigned used : 1;
  240. };
  241. /* ipa_node_params stores information related to formal parameters of functions
  242. and some other information for interprocedural passes that operate on
  243. parameters (such as ipa-cp). */
  244. struct ipa_node_params
  245. {
  246. ~ipa_node_params ();
  247. /* Information about individual formal parameters that are gathered when
  248. summaries are generated. */
  249. vec<ipa_param_descriptor> descriptors;
  250. /* Pointer to an array of structures describing individual formal
  251. parameters. */
  252. struct ipcp_param_lattices *lattices;
  253. /* Only for versioned nodes this field would not be NULL,
  254. it points to the node that IPA cp cloned from. */
  255. struct cgraph_node *ipcp_orig_node;
  256. /* If this node is an ipa-cp clone, these are the known constants that
  257. describe what it has been specialized for. */
  258. vec<tree> known_csts;
  259. /* If this node is an ipa-cp clone, these are the known polymorphic contexts
  260. that describe what it has been specialized for. */
  261. vec<ipa_polymorphic_call_context> known_contexts;
  262. /* Whether the param uses analysis and jump function computation has already
  263. been performed. */
  264. unsigned analysis_done : 1;
  265. /* Whether the function is enqueued in ipa-cp propagation stack. */
  266. unsigned node_enqueued : 1;
  267. /* Whether we should create a specialized version based on values that are
  268. known to be constant in all contexts. */
  269. unsigned do_clone_for_all_contexts : 1;
  270. /* Set if this is an IPA-CP clone for all contexts. */
  271. unsigned is_all_contexts_clone : 1;
  272. /* Node has been completely replaced by clones and will be removed after
  273. ipa-cp is finished. */
  274. unsigned node_dead : 1;
  275. /* Node is involved in a recursion, potentionally indirect. */
  276. unsigned node_within_scc : 1;
  277. /* Node is calling a private function called only once. */
  278. unsigned node_calling_single_call : 1;
  279. };
  280. /* Intermediate information that we get from alias analysis about a particular
  281. parameter in a particular basic_block. When a parameter or the memory it
  282. references is marked modified, we use that information in all dominated
  283. blocks without consulting alias analysis oracle. */
  284. struct ipa_param_aa_status
  285. {
  286. /* Set when this structure contains meaningful information. If not, the
  287. structure describing a dominating BB should be used instead. */
  288. bool valid;
  289. /* Whether we have seen something which might have modified the data in
  290. question. PARM is for the parameter itself, REF is for data it points to
  291. but using the alias type of individual accesses and PT is the same thing
  292. but for computing aggregate pass-through functions using a very inclusive
  293. ao_ref. */
  294. bool parm_modified, ref_modified, pt_modified;
  295. };
  296. /* Information related to a given BB that used only when looking at function
  297. body. */
  298. struct ipa_bb_info
  299. {
  300. /* Call graph edges going out of this BB. */
  301. vec<cgraph_edge *> cg_edges;
  302. /* Alias analysis statuses of each formal parameter at this bb. */
  303. vec<ipa_param_aa_status> param_aa_statuses;
  304. };
  305. /* Structure with global information that is only used when looking at function
  306. body. */
  307. struct ipa_func_body_info
  308. {
  309. /* The node that is being analyzed. */
  310. cgraph_node *node;
  311. /* Its info. */
  312. struct ipa_node_params *info;
  313. /* Information about individual BBs. */
  314. vec<ipa_bb_info> bb_infos;
  315. /* Number of parameters. */
  316. int param_count;
  317. /* Number of statements already walked by when analyzing this function. */
  318. unsigned int aa_walked;
  319. };
  320. /* ipa_node_params access functions. Please use these to access fields that
  321. are or will be shared among various passes. */
  322. /* Return the number of formal parameters. */
  323. static inline int
  324. ipa_get_param_count (struct ipa_node_params *info)
  325. {
  326. return info->descriptors.length ();
  327. }
  328. /* Return the declaration of Ith formal parameter of the function corresponding
  329. to INFO. Note there is no setter function as this array is built just once
  330. using ipa_initialize_node_params. */
  331. static inline tree
  332. ipa_get_param (struct ipa_node_params *info, int i)
  333. {
  334. gcc_checking_assert (!flag_wpa);
  335. return info->descriptors[i].decl;
  336. }
  337. /* Return the move cost of Ith formal parameter of the function corresponding
  338. to INFO. */
  339. static inline int
  340. ipa_get_param_move_cost (struct ipa_node_params *info, int i)
  341. {
  342. return info->descriptors[i].move_cost;
  343. }
  344. /* Set the used flag corresponding to the Ith formal parameter of the function
  345. associated with INFO to VAL. */
  346. static inline void
  347. ipa_set_param_used (struct ipa_node_params *info, int i, bool val)
  348. {
  349. info->descriptors[i].used = val;
  350. }
  351. /* Return how many uses described by ipa-prop a parameter has or
  352. IPA_UNDESCRIBED_USE if there is a use that is not described by these
  353. structures. */
  354. static inline int
  355. ipa_get_controlled_uses (struct ipa_node_params *info, int i)
  356. {
  357. /* FIXME: introducing speuclation causes out of bounds access here. */
  358. if (info->descriptors.length () > (unsigned)i)
  359. return info->descriptors[i].controlled_uses;
  360. return IPA_UNDESCRIBED_USE;
  361. }
  362. /* Set the controlled counter of a given parameter. */
  363. static inline void
  364. ipa_set_controlled_uses (struct ipa_node_params *info, int i, int val)
  365. {
  366. info->descriptors[i].controlled_uses = val;
  367. }
  368. /* Return the used flag corresponding to the Ith formal parameter of the
  369. function associated with INFO. */
  370. static inline bool
  371. ipa_is_param_used (struct ipa_node_params *info, int i)
  372. {
  373. return info->descriptors[i].used;
  374. }
  375. /* Information about replacements done in aggregates for a given node (each
  376. node has its linked list). */
  377. struct GTY(()) ipa_agg_replacement_value
  378. {
  379. /* Next item in the linked list. */
  380. struct ipa_agg_replacement_value *next;
  381. /* Offset within the aggregate. */
  382. HOST_WIDE_INT offset;
  383. /* The constant value. */
  384. tree value;
  385. /* The paramter index. */
  386. int index;
  387. /* Whether the value was passed by reference. */
  388. bool by_ref;
  389. };
  390. /* Structure holding information for the transformation phase of IPA-CP. */
  391. struct GTY(()) ipcp_transformation_summary
  392. {
  393. /* Linked list of known aggregate values. */
  394. ipa_agg_replacement_value *agg_values;
  395. /* Alignment information for pointers. */
  396. vec<ipa_alignment, va_gc> *alignments;
  397. };
  398. void ipa_set_node_agg_value_chain (struct cgraph_node *node,
  399. struct ipa_agg_replacement_value *aggvals);
  400. void ipcp_grow_transformations_if_necessary (void);
  401. /* ipa_edge_args stores information related to a callsite and particularly its
  402. arguments. It can be accessed by the IPA_EDGE_REF macro. */
  403. struct GTY(()) ipa_edge_args
  404. {
  405. /* Vector of the callsite's jump function of each parameter. */
  406. vec<ipa_jump_func, va_gc> *jump_functions;
  407. vec<ipa_polymorphic_call_context, va_gc> *polymorphic_call_contexts;
  408. };
  409. /* ipa_edge_args access functions. Please use these to access fields that
  410. are or will be shared among various passes. */
  411. /* Return the number of actual arguments. */
  412. static inline int
  413. ipa_get_cs_argument_count (struct ipa_edge_args *args)
  414. {
  415. return vec_safe_length (args->jump_functions);
  416. }
  417. /* Returns a pointer to the jump function for the ith argument. Please note
  418. there is no setter function as jump functions are all set up in
  419. ipa_compute_jump_functions. */
  420. static inline struct ipa_jump_func *
  421. ipa_get_ith_jump_func (struct ipa_edge_args *args, int i)
  422. {
  423. return &(*args->jump_functions)[i];
  424. }
  425. /* Returns a pointer to the polymorphic call context for the ith argument.
  426. NULL if contexts are not computed. */
  427. static inline struct ipa_polymorphic_call_context *
  428. ipa_get_ith_polymorhic_call_context (struct ipa_edge_args *args, int i)
  429. {
  430. if (!args->polymorphic_call_contexts)
  431. return NULL;
  432. return &(*args->polymorphic_call_contexts)[i];
  433. }
  434. /* Function summary for ipa_node_params. */
  435. class ipa_node_params_t: public function_summary <ipa_node_params *>
  436. {
  437. public:
  438. ipa_node_params_t (symbol_table *table):
  439. function_summary<ipa_node_params *> (table) { }
  440. /* Hook that is called by summary when a node is duplicated. */
  441. virtual void duplicate (cgraph_node *node,
  442. cgraph_node *node2,
  443. ipa_node_params *data,
  444. ipa_node_params *data2);
  445. };
  446. /* Function summary where the parameter infos are actually stored. */
  447. extern ipa_node_params_t *ipa_node_params_sum;
  448. /* Vector of IPA-CP transformation data for each clone. */
  449. extern GTY(()) vec<ipcp_transformation_summary, va_gc> *ipcp_transformations;
  450. /* Vector where the parameter infos are actually stored. */
  451. extern GTY(()) vec<ipa_edge_args, va_gc> *ipa_edge_args_vector;
  452. /* Return the associated parameter/argument info corresponding to the given
  453. node/edge. */
  454. #define IPA_NODE_REF(NODE) (ipa_node_params_sum->get (NODE))
  455. #define IPA_EDGE_REF(EDGE) (&(*ipa_edge_args_vector)[(EDGE)->uid])
  456. /* This macro checks validity of index returned by
  457. ipa_get_param_decl_index function. */
  458. #define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1)
  459. /* Creating and freeing ipa_node_params and ipa_edge_args. */
  460. void ipa_create_all_node_params (void);
  461. void ipa_create_all_edge_args (void);
  462. void ipa_free_edge_args_substructures (struct ipa_edge_args *);
  463. void ipa_free_all_node_params (void);
  464. void ipa_free_all_edge_args (void);
  465. void ipa_free_all_structures_after_ipa_cp (void);
  466. void ipa_free_all_structures_after_iinln (void);
  467. void ipa_register_cgraph_hooks (void);
  468. int count_formal_params (tree fndecl);
  469. /* This function ensures the array of node param infos is big enough to
  470. accommodate a structure for all nodes and reallocates it if not. */
  471. static inline void
  472. ipa_check_create_node_params (void)
  473. {
  474. if (!ipa_node_params_sum)
  475. ipa_node_params_sum = new ipa_node_params_t (symtab);
  476. }
  477. /* This function ensures the array of edge arguments infos is big enough to
  478. accommodate a structure for all edges and reallocates it if not. */
  479. static inline void
  480. ipa_check_create_edge_args (void)
  481. {
  482. if (vec_safe_length (ipa_edge_args_vector)
  483. <= (unsigned) symtab->edges_max_uid)
  484. vec_safe_grow_cleared (ipa_edge_args_vector, symtab->edges_max_uid + 1);
  485. }
  486. /* Returns true if the array of edge infos is large enough to accommodate an
  487. info for EDGE. The main purpose of this function is that debug dumping
  488. function can check info availability without causing reallocations. */
  489. static inline bool
  490. ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge)
  491. {
  492. return ((unsigned) edge->uid < vec_safe_length (ipa_edge_args_vector));
  493. }
  494. static inline ipcp_transformation_summary *
  495. ipcp_get_transformation_summary (cgraph_node *node)
  496. {
  497. if ((unsigned) node->uid >= vec_safe_length (ipcp_transformations))
  498. return NULL;
  499. return &(*ipcp_transformations)[node->uid];
  500. }
  501. /* Return the aggregate replacements for NODE, if there are any. */
  502. static inline struct ipa_agg_replacement_value *
  503. ipa_get_agg_replacements_for_node (cgraph_node *node)
  504. {
  505. ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node);
  506. return ts ? ts->agg_values : NULL;
  507. }
  508. /* Function formal parameters related computations. */
  509. void ipa_initialize_node_params (struct cgraph_node *node);
  510. bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
  511. vec<cgraph_edge *> *new_edges);
  512. /* Indirect edge and binfo processing. */
  513. tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
  514. vec<tree> ,
  515. vec<ipa_polymorphic_call_context>,
  516. vec<ipa_agg_jump_function_p>,
  517. bool *);
  518. struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree,
  519. bool speculative = false);
  520. tree ipa_impossible_devirt_target (struct cgraph_edge *, tree);
  521. /* Functions related to both. */
  522. void ipa_analyze_node (struct cgraph_node *);
  523. /* Aggregate jump function related functions. */
  524. tree ipa_find_agg_cst_for_param (struct ipa_agg_jump_function *, HOST_WIDE_INT,
  525. bool);
  526. bool ipa_load_from_parm_agg (struct ipa_func_body_info *,
  527. vec<ipa_param_descriptor>, gimple, tree, int *,
  528. HOST_WIDE_INT *, HOST_WIDE_INT *, bool *);
  529. /* Debugging interface. */
  530. void ipa_print_node_params (FILE *, struct cgraph_node *node);
  531. void ipa_print_all_params (FILE *);
  532. void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
  533. void ipa_print_all_jump_functions (FILE * f);
  534. void ipcp_verify_propagated_values (void);
  535. extern alloc_pool ipcp_cst_values_pool;
  536. extern alloc_pool ipcp_poly_ctx_values_pool;
  537. extern alloc_pool ipcp_sources_pool;
  538. extern alloc_pool ipcp_agg_lattice_pool;
  539. /* Operation to be performed for the parameter in ipa_parm_adjustment
  540. below. */
  541. enum ipa_parm_op {
  542. IPA_PARM_OP_NONE,
  543. /* This describes a brand new parameter.
  544. The field `type' should be set to the new type, `arg_prefix'
  545. should be set to the string prefix for the new DECL_NAME, and
  546. `new_decl' will ultimately hold the newly created argument. */
  547. IPA_PARM_OP_NEW,
  548. /* This new parameter is an unmodified parameter at index base_index. */
  549. IPA_PARM_OP_COPY,
  550. /* This adjustment describes a parameter that is about to be removed
  551. completely. Most users will probably need to book keep those so that they
  552. don't leave behinfd any non default def ssa names belonging to them. */
  553. IPA_PARM_OP_REMOVE
  554. };
  555. /* Structure to describe transformations of formal parameters and actual
  556. arguments. Each instance describes one new parameter and they are meant to
  557. be stored in a vector. Additionally, most users will probably want to store
  558. adjustments about parameters that are being removed altogether so that SSA
  559. names belonging to them can be replaced by SSA names of an artificial
  560. variable. */
  561. struct ipa_parm_adjustment
  562. {
  563. /* The original PARM_DECL itself, helpful for processing of the body of the
  564. function itself. Intended for traversing function bodies.
  565. ipa_modify_formal_parameters, ipa_modify_call_arguments and
  566. ipa_combine_adjustments ignore this and use base_index.
  567. ipa_modify_formal_parameters actually sets this. */
  568. tree base;
  569. /* Type of the new parameter. However, if by_ref is true, the real type will
  570. be a pointer to this type. */
  571. tree type;
  572. /* Alias refrerence type to be used in MEM_REFs when adjusting caller
  573. arguments. */
  574. tree alias_ptr_type;
  575. /* The new declaration when creating/replacing a parameter. Created
  576. by ipa_modify_formal_parameters, useful for functions modifying
  577. the body accordingly. For brand new arguments, this is the newly
  578. created argument. */
  579. tree new_decl;
  580. /* New declaration of a substitute variable that we may use to replace all
  581. non-default-def ssa names when a parm decl is going away. */
  582. tree new_ssa_base;
  583. /* If non-NULL and the original parameter is to be removed (copy_param below
  584. is NULL), this is going to be its nonlocalized vars value. */
  585. tree nonlocal_value;
  586. /* This holds the prefix to be used for the new DECL_NAME. */
  587. const char *arg_prefix;
  588. /* Offset into the original parameter (for the cases when the new parameter
  589. is a component of an original one). */
  590. HOST_WIDE_INT offset;
  591. /* Zero based index of the original parameter this one is based on. */
  592. int base_index;
  593. /* Whether this parameter is a new parameter, a copy of an old one,
  594. or one about to be removed. */
  595. enum ipa_parm_op op;
  596. /* The parameter is to be passed by reference. */
  597. unsigned by_ref : 1;
  598. };
  599. typedef vec<ipa_parm_adjustment> ipa_parm_adjustment_vec;
  600. vec<tree> ipa_get_vector_of_formal_parms (tree fndecl);
  601. vec<tree> ipa_get_vector_of_formal_parm_types (tree fntype);
  602. void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec);
  603. void ipa_modify_call_arguments (struct cgraph_edge *, gcall *,
  604. ipa_parm_adjustment_vec);
  605. ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
  606. ipa_parm_adjustment_vec);
  607. void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
  608. void ipa_dump_agg_replacement_values (FILE *f,
  609. struct ipa_agg_replacement_value *av);
  610. void ipa_prop_write_jump_functions (void);
  611. void ipa_prop_read_jump_functions (void);
  612. void ipcp_write_transformation_summaries (void);
  613. void ipcp_read_transformation_summaries (void);
  614. void ipa_update_after_lto_read (void);
  615. int ipa_get_param_decl_index (struct ipa_node_params *, tree);
  616. tree ipa_value_from_jfunc (struct ipa_node_params *info,
  617. struct ipa_jump_func *jfunc);
  618. unsigned int ipcp_transform_function (struct cgraph_node *node);
  619. ipa_polymorphic_call_context ipa_context_from_jfunc (ipa_node_params *,
  620. cgraph_edge *,
  621. int,
  622. ipa_jump_func *);
  623. void ipa_dump_param (FILE *, struct ipa_node_params *info, int i);
  624. bool ipa_modify_expr (tree *, bool, ipa_parm_adjustment_vec);
  625. ipa_parm_adjustment *ipa_get_adjustment_candidate (tree **, bool *,
  626. ipa_parm_adjustment_vec,
  627. bool);
  628. /* From tree-sra.c: */
  629. tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, tree,
  630. gimple_stmt_iterator *, bool);
  631. /* In ipa-cp.c */
  632. void ipa_cp_c_finalize (void);
  633. #endif /* IPA_PROP_H */