tree-ssa-alias.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* Tree based alias analysis and alias oracle.
  2. Copyright (C) 2008-2015 Free Software Foundation, Inc.
  3. Contributed by Richard Guenther <rguenther@suse.de>
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify
  6. under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. GCC is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GCC; see the file COPYING3. If not see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef TREE_SSA_ALIAS_H
  17. #define TREE_SSA_ALIAS_H
  18. /* The points-to solution.
  19. The points-to solution is a union of pt_vars and the abstract
  20. sets specified by the flags. */
  21. struct GTY(()) pt_solution
  22. {
  23. /* Nonzero if points-to analysis couldn't determine where this pointer
  24. is pointing to. */
  25. unsigned int anything : 1;
  26. /* Nonzero if the points-to set includes any global memory. Note that
  27. even if this is zero pt_vars can still include global variables. */
  28. unsigned int nonlocal : 1;
  29. /* Nonzero if the points-to set includes the local escaped solution by
  30. reference. */
  31. unsigned int escaped : 1;
  32. /* Nonzero if the points-to set includes the IPA escaped solution by
  33. reference. */
  34. unsigned int ipa_escaped : 1;
  35. /* Nonzero if the points-to set includes 'nothing', the points-to set
  36. includes memory at address NULL. */
  37. unsigned int null : 1;
  38. /* Nonzero if the vars bitmap includes a variable included in 'nonlocal'. */
  39. unsigned int vars_contains_nonlocal : 1;
  40. /* Nonzero if the vars bitmap includes a variable included in 'escaped'. */
  41. unsigned int vars_contains_escaped : 1;
  42. /* Nonzero if the vars bitmap includes a anonymous heap variable that
  43. escaped the function and thus became global. */
  44. unsigned int vars_contains_escaped_heap : 1;
  45. /* Set of variables that this pointer may point to. */
  46. bitmap vars;
  47. };
  48. /* Simplified and cached information about a memory reference tree.
  49. Used by the alias-oracle internally and externally in alternate
  50. interfaces. */
  51. struct ao_ref
  52. {
  53. /* The original full memory reference tree or NULL_TREE if that is
  54. not available. */
  55. tree ref;
  56. /* The following fields are the decomposed reference as returned
  57. by get_ref_base_and_extent. */
  58. /* The base object of the memory reference or NULL_TREE if all of
  59. the following fields are not yet computed. */
  60. tree base;
  61. /* The offset relative to the base. */
  62. HOST_WIDE_INT offset;
  63. /* The size of the access. */
  64. HOST_WIDE_INT size;
  65. /* The maximum possible extent of the access or -1 if unconstrained. */
  66. HOST_WIDE_INT max_size;
  67. /* The alias set of the access or -1 if not yet computed. */
  68. alias_set_type ref_alias_set;
  69. /* The alias set of the base object or -1 if not yet computed. */
  70. alias_set_type base_alias_set;
  71. /* Whether the memory is considered a volatile access. */
  72. bool volatile_p;
  73. };
  74. /* In tree-ssa-alias.c */
  75. extern void ao_ref_init (ao_ref *, tree);
  76. extern void ao_ref_init_from_ptr_and_size (ao_ref *, tree, tree);
  77. extern tree ao_ref_base (ao_ref *);
  78. extern alias_set_type ao_ref_alias_set (ao_ref *);
  79. extern alias_set_type ao_ref_base_alias_set (ao_ref *);
  80. extern bool ptr_deref_may_alias_global_p (tree);
  81. extern bool ptr_derefs_may_alias_p (tree, tree);
  82. extern bool ref_may_alias_global_p (tree);
  83. extern bool ref_may_alias_global_p (ao_ref *);
  84. extern bool refs_may_alias_p (tree, tree);
  85. extern bool refs_may_alias_p_1 (ao_ref *, ao_ref *, bool);
  86. extern bool refs_anti_dependent_p (tree, tree);
  87. extern bool refs_output_dependent_p (tree, tree);
  88. extern bool ref_maybe_used_by_stmt_p (gimple, tree);
  89. extern bool ref_maybe_used_by_stmt_p (gimple, ao_ref *);
  90. extern bool stmt_may_clobber_global_p (gimple);
  91. extern bool stmt_may_clobber_ref_p (gimple, tree);
  92. extern bool stmt_may_clobber_ref_p_1 (gimple, ao_ref *);
  93. extern bool call_may_clobber_ref_p (gcall *, tree);
  94. extern bool call_may_clobber_ref_p_1 (gcall *, ao_ref *);
  95. extern bool stmt_kills_ref_p (gimple, tree);
  96. extern bool stmt_kills_ref_p (gimple, ao_ref *);
  97. extern tree get_continuation_for_phi (gimple, ao_ref *,
  98. unsigned int *, bitmap *, bool,
  99. void *(*)(ao_ref *, tree, void *, bool),
  100. void *);
  101. extern void *walk_non_aliased_vuses (ao_ref *, tree,
  102. void *(*)(ao_ref *, tree,
  103. unsigned int, void *),
  104. void *(*)(ao_ref *, tree, void *, bool),
  105. tree (*)(tree),
  106. void *);
  107. extern unsigned int walk_aliased_vdefs (ao_ref *, tree,
  108. bool (*)(ao_ref *, tree, void *),
  109. void *, bitmap *,
  110. bool *function_entry_reached = NULL);
  111. extern void dump_alias_info (FILE *);
  112. extern void debug_alias_info (void);
  113. extern void dump_points_to_solution (FILE *, struct pt_solution *);
  114. extern void debug (pt_solution &ref);
  115. extern void debug (pt_solution *ptr);
  116. extern void dump_points_to_info_for (FILE *, tree);
  117. extern void debug_points_to_info_for (tree);
  118. extern void dump_alias_stats (FILE *);
  119. /* In tree-ssa-structalias.c */
  120. extern unsigned int compute_may_aliases (void);
  121. extern bool pt_solution_empty_p (struct pt_solution *);
  122. extern bool pt_solution_singleton_p (struct pt_solution *, unsigned *);
  123. extern bool pt_solution_includes_global (struct pt_solution *);
  124. extern bool pt_solution_includes (struct pt_solution *, const_tree);
  125. extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *);
  126. extern void pt_solution_reset (struct pt_solution *);
  127. extern void pt_solution_set (struct pt_solution *, bitmap, bool);
  128. extern void pt_solution_set_var (struct pt_solution *, tree);
  129. extern void dump_pta_stats (FILE *);
  130. extern GTY(()) struct pt_solution ipa_escaped_pt;
  131. /* Return true, if the two ranges [POS1, SIZE1] and [POS2, SIZE2]
  132. overlap. SIZE1 and/or SIZE2 can be (unsigned)-1 in which case the
  133. range is open-ended. Otherwise return false. */
  134. static inline bool
  135. ranges_overlap_p (HOST_WIDE_INT pos1,
  136. unsigned HOST_WIDE_INT size1,
  137. HOST_WIDE_INT pos2,
  138. unsigned HOST_WIDE_INT size2)
  139. {
  140. if (pos1 >= pos2
  141. && (size2 == (unsigned HOST_WIDE_INT)-1
  142. || pos1 < (pos2 + (HOST_WIDE_INT) size2)))
  143. return true;
  144. if (pos2 >= pos1
  145. && (size1 == (unsigned HOST_WIDE_INT)-1
  146. || pos2 < (pos1 + (HOST_WIDE_INT) size1)))
  147. return true;
  148. return false;
  149. }
  150. #endif /* TREE_SSA_ALIAS_H */