tree-ssa-alias.h 6.21 KB
Newer Older
1
/* Tree based alias analysis and alias oracle.
2
   Copyright (C) 2008-2014 Free Software Foundation, Inc.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
   Contributed by Richard Guenther  <rguenther@suse.de>

   This file is part of GCC.

   GCC is free software; you can redistribute it and/or modify
   under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   GCC is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GCC; see the file COPYING3.  If not see
   <http://www.gnu.org/licenses/>.  */

#ifndef TREE_SSA_ALIAS_H
#define TREE_SSA_ALIAS_H

/* The points-to solution.

   The points-to solution is a union of pt_vars and the abstract
   sets specified by the flags.  */
28
struct GTY(()) pt_solution
29 30 31 32 33 34 35 36 37
{
  /* Nonzero if points-to analysis couldn't determine where this pointer
     is pointing to.  */
  unsigned int anything : 1;

  /* Nonzero if the points-to set includes any global memory.  Note that
     even if this is zero pt_vars can still include global variables.  */
  unsigned int nonlocal : 1;

38 39
  /* Nonzero if the points-to set includes the local escaped solution by
     reference.  */
40 41
  unsigned int escaped : 1;

42 43 44 45
  /* Nonzero if the points-to set includes the IPA escaped solution by
     reference.  */
  unsigned int ipa_escaped : 1;

46 47 48 49 50
  /* Nonzero if the points-to set includes 'nothing', the points-to set
     includes memory at address NULL.  */
  unsigned int null : 1;


51 52 53 54 55 56 57
  /* Nonzero if the vars bitmap includes a variable included in 'nonlocal'.  */
  unsigned int vars_contains_nonlocal : 1;
  /* Nonzero if the vars bitmap includes a variable included in 'escaped'.  */
  unsigned int vars_contains_escaped : 1;
  /* Nonzero if the vars bitmap includes a anonymous heap variable that
     escaped the function and thus became global.  */
  unsigned int vars_contains_escaped_heap : 1;
58

59 60 61 62 63
  /* Set of variables that this pointer may point to.  */
  bitmap vars;
};


64 65 66
/* Simplified and cached information about a memory reference tree.
   Used by the alias-oracle internally and externally in alternate
   interfaces.  */
67
struct ao_ref
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
{
  /* The original full memory reference tree or NULL_TREE if that is
     not available.  */
  tree ref;

  /* The following fields are the decomposed reference as returned
     by get_ref_base_and_extent.  */
  /* The base object of the memory reference or NULL_TREE if all of
     the following fields are not yet computed.  */
  tree base;
  /* The offset relative to the base.  */
  HOST_WIDE_INT offset;
  /* The size of the access.  */
  HOST_WIDE_INT size;
  /* The maximum possible extent of the access or -1 if unconstrained.  */
  HOST_WIDE_INT max_size;

  /* The alias set of the access or -1 if not yet computed.  */
  alias_set_type ref_alias_set;

  /* The alias set of the base object or -1 if not yet computed.  */
  alias_set_type base_alias_set;
90 91 92

  /* Whether the memory is considered a volatile access.  */
  bool volatile_p;
93
};
94 95


96
/* In tree-ssa-alias.c  */
97
extern void ao_ref_init (ao_ref *, tree);
98
extern void ao_ref_init_from_ptr_and_size (ao_ref *, tree, tree);
99 100
extern tree ao_ref_base (ao_ref *);
extern alias_set_type ao_ref_alias_set (ao_ref *);
101
extern bool ptr_deref_may_alias_global_p (tree);
102
extern bool ptr_derefs_may_alias_p (tree, tree);
103
extern bool ref_may_alias_global_p (tree);
104
extern bool refs_may_alias_p (tree, tree);
105
extern bool refs_may_alias_p_1 (ao_ref *, ao_ref *, bool);
106 107
extern bool refs_anti_dependent_p (tree, tree);
extern bool refs_output_dependent_p (tree, tree);
108
extern bool ref_maybe_used_by_stmt_p (gimple, tree);
109
extern bool stmt_may_clobber_global_p (gimple);
110
extern bool stmt_may_clobber_ref_p (gimple, tree);
111
extern bool stmt_may_clobber_ref_p_1 (gimple, ao_ref *);
112
extern bool call_may_clobber_ref_p (gimple, tree);
113
extern bool call_may_clobber_ref_p_1 (gimple, ao_ref *);
114
extern bool stmt_kills_ref_p (gimple, tree);
115
extern tree get_continuation_for_phi (gimple, ao_ref *,
116 117 118
				      unsigned int *, bitmap *, bool,
				      void *(*)(ao_ref *, tree, void *, bool),
				      void *);
119
extern void *walk_non_aliased_vuses (ao_ref *, tree,
120 121
				     void *(*)(ao_ref *, tree,
					       unsigned int, void *),
122 123
				     void *(*)(ao_ref *, tree, void *, bool),
				     void *);
124 125 126
extern unsigned int walk_aliased_vdefs (ao_ref *, tree,
					bool (*)(ao_ref *, tree, void *),
					void *, bitmap *);
127 128
extern void dump_alias_info (FILE *);
extern void debug_alias_info (void);
129
extern void dump_points_to_solution (FILE *, struct pt_solution *);
130 131
extern void debug (pt_solution &ref);
extern void debug (pt_solution *ptr);
132 133 134 135 136 137 138
extern void dump_points_to_info_for (FILE *, tree);
extern void debug_points_to_info_for (tree);
extern void dump_alias_stats (FILE *);


/* In tree-ssa-structalias.c  */
extern unsigned int compute_may_aliases (void);
139
extern bool pt_solution_empty_p (struct pt_solution *);
140
extern bool pt_solution_singleton_p (struct pt_solution *, unsigned *);
141 142 143 144
extern bool pt_solution_includes_global (struct pt_solution *);
extern bool pt_solution_includes (struct pt_solution *, const_tree);
extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *);
extern void pt_solution_reset (struct pt_solution *);
145
extern void pt_solution_set (struct pt_solution *, bitmap, bool);
146 147
extern void pt_solution_set_var (struct pt_solution *, tree);

148 149
extern void dump_pta_stats (FILE *);

150 151
extern GTY(()) struct pt_solution ipa_escaped_pt;

152 153 154 155 156
/* Return true, if the two ranges [POS1, SIZE1] and [POS2, SIZE2]
   overlap.  SIZE1 and/or SIZE2 can be (unsigned)-1 in which case the
   range is open-ended.  Otherwise return false.  */

static inline bool
157
ranges_overlap_p (HOST_WIDE_INT pos1,
158
		  unsigned HOST_WIDE_INT size1,
159
		  HOST_WIDE_INT pos2,
160 161 162 163
		  unsigned HOST_WIDE_INT size2)
{
  if (pos1 >= pos2
      && (size2 == (unsigned HOST_WIDE_INT)-1
164
	  || pos1 < (pos2 + (HOST_WIDE_INT) size2)))
165 166 167
    return true;
  if (pos2 >= pos1
      && (size1 == (unsigned HOST_WIDE_INT)-1
168
	  || pos2 < (pos1 + (HOST_WIDE_INT) size1)))
169 170 171 172 173 174
    return true;

  return false;
}


175 176

#endif /* TREE_SSA_ALIAS_H  */