tree-ssa-structalias: Put constraint building into its own file

This patch cuts out points-to constraint building from
tree-ssa-structalias.cc and places it into a new file
gimple-ssa-pta-constraints.cc.

The diff of tree-ssa-structalias.cc ended up being messy, so here is a
summary of changes I made that may not be apparent at first glance.
I didn't do any functional changes.  Everything is just shifting
functions and declarations around and giving external linkage to some
things.

- These functions now have external linkage and got shifted to the
  beginning of the file:
determine_global_memory_access
fndecl_maybe_in_other_partition
new_var_info
- The using namespace pointer_analysis directive got shifted to the
  beginning of the file
- Declarations of these global variables got shifted to the beginning of
  the file:
variable_info_pool
final_solutions
final_solutions_obstack
- These global variables got external linkage:
use_field_sensitive
in_ipa_mode

gcc/ChangeLog:

	* Makefile.in: Add gimple-ssa-pta-constraints.cc.
	* tree-ssa-structalias.cc (determine_global_memory_access):
	External linkage, move to namespace pointer_analysis.
	(fndecl_maybe_in_other_partition): External linkage, move to
	namespace pointer_analysis.
	(new_var_info): External linkage, move to namespace
	pointer_analysis.
	(create_variable_info_for): Move to
	gimple-ssa-pta-constraints.cc.
	(lookup_vi_for_tree): External linkage, move to namespace
	pointer_analysis, move to gimple-ssa-pta-constraints.cc.
	(type_can_have_subvars): Move to gimple-ssa-pta-constraints.cc.
	(make_param_constraints): Move to gimple-ssa-pta-constraints.cc.
	(get_call_vi): Move to gimple-ssa-pta-constraints.cc.
	(lookup_call_use_vi): External linkage, move to namespace
	pointer_analysis, move to gimple-ssa-pta-constraints.cc.
	(lookup_call_clobber_vi): External linkage, move to namespace
	pointer_analysis, move to gimple-ssa-pta-constraints.cc.
	(get_call_use_vi): Move to gimple-ssa-pta-constraints.cc.
	(get_call_clobber_vi): Move to gimple-ssa-pta-constraints.cc.
	(get_constraint_for_1): Move to gimple-ssa-pta-constraints.cc.
	(get_constraint_for): Move to gimple-ssa-pta-constraints.cc.
	(get_constraint_for_rhs): Move to gimple-ssa-pta-constraints.cc.
	(do_deref): Move to gimple-ssa-pta-constraints.cc.
	(constraint_pool): Move to gimple-ssa-pta-constraints.cc.
	(new_constraint): Move to gimple-ssa-pta-constraints.cc.
	(insert_vi_for_tree): Move to gimple-ssa-pta-constraints.cc.
	(alias_get_name): Move to gimple-ssa-pta-constraints.cc.
	(get_vi_for_tree): Move to gimple-ssa-pta-constraints.cc.
	(new_scalar_tmp_constraint_exp): Move to
	gimple-ssa-pta-constraints.cc.
	(get_constraint_for_ssa_var): Move to
	gimple-ssa-pta-constraints.cc.
	(process_constraint): Move to gimple-ssa-pta-constraints.cc.
	(bitpos_of_field): Move to gimple-ssa-pta-constraints.cc.
	(get_constraint_for_ptr_offset): Move to
	gimple-ssa-pta-constraints.cc.
	(get_constraint_for_component_ref): Move to
	gimple-ssa-pta-constraints.cc.
	(get_constraint_for_address_of): Move to
	gimple-ssa-pta-constraints.cc.
	(process_all_all_constraints): Move to
	gimple-ssa-pta-constraints.cc.
	(do_structure_copy): Move to gimple-ssa-pta-constraints.cc.
	(make_constraints_to): Move to gimple-ssa-pta-constraints.cc.
	(make_constraint_to): Move to gimple-ssa-pta-constraints.cc.
	(make_constraint_from): Move to gimple-ssa-pta-constraints.cc.
	(make_copy_constraint): Move to gimple-ssa-pta-constraints.cc.
	(make_escape_constraint): Move to gimple-ssa-pta-constraints.cc.
	(make_indirect_escape_constraint): Move to
	gimple-ssa-pta-constraints.cc.
	(make_transitive_closure_constraints): Move to
	gimple-ssa-pta-constraints.cc.
	(make_any_offset_constraints): Move to
	gimple-ssa-pta-constraints.cc.
	(struct obstack fake_var_decl_obstack): Move to
	gimple-ssa-pta-constraints.cc.
	(build_fake_var_decl): Move to gimple-ssa-pta-constraints.cc.
	(make_heapvar): Move to gimple-ssa-pta-constraints.cc.
	(make_constraint_from_restrict): Move to
	gimple-ssa-pta-constraints.cc.
	(make_constraint_from_global_restrict): Move to
	gimple-ssa-pta-constraints.cc.
	(get_function_part_constraint): Move to
	gimple-ssa-pta-constraints.cc.
	(handle_call_arg): Move to gimple-ssa-pta-constraints.cc.
	(handle_rhs_call): Move to gimple-ssa-pta-constraints.cc.
	(handle_lhs_call): Move to gimple-ssa-pta-constraints.cc.
	(get_fi_for_callee): Move to gimple-ssa-pta-constraints.cc.
	(find_func_aliases_for_call_arg): Move to
	gimple-ssa-pta-constraints.cc.
	(find_func_aliases_for_builtin_call): Move to
	gimple-ssa-pta-constraints.cc.
	(find_func_aliases_for_call): Move to
	gimple-ssa-pta-constraints.cc.
	(find_func_aliases): Move to gimple-ssa-pta-constraints.cc.
	(process_ipa_clobber): Move to gimple-ssa-pta-constraints.cc.
	(find_func_clobbers): Move to gimple-ssa-pta-constraints.cc.
	(struct fieldoff): Move to gimple-ssa-pta-constraints.cc.
	(fieldoff_compare): Move to gimple-ssa-pta-constraints.cc.
	(sort_fieldstack): Move to gimple-ssa-pta-constraints.cc.
	(var_can_have_subvars): Move to gimple-ssa-pta-constraints.cc.
	(type_must_have_pointers): Move to
	gimple-ssa-pta-constraints.cc.
	(field_must_have_pointers): Move to
	gimple-ssa-pta-constraints.cc.
	(push_fields_onto_fieldstack): Move to
	gimple-ssa-pta-constraints.cc.
	(count_num_arguments): Move to gimple-ssa-pta-constraints.cc.
	(create_function_info_for): Move to
	gimple-ssa-pta-constraints.cc.
	(check_for_overlaps): Move to gimple-ssa-pta-constraints.cc.
	(create_variable_info_for_1): Move to
	gimple-ssa-pta-constraints.cc.
	(intra_create_variable_infos): Move to
	gimple-ssa-pta-constraints.cc.
	(init_base_vars): Move to gimple-ssa-pta-constraints.cc.
	(init_constraint_builder): Move to
	gimple-ssa-pta-constraints.cc.
	(delete_constraint_builder): Move to
	gimple-ssa-pta-constraints.cc.
	(intra_build_constraints): Move to
	gimple-ssa-pta-constraints.cc.
	(delete_points_to_sets): Move to gimple-ssa-pta-constraints.cc.
	(associate_varinfo_to_alias): Move to
	gimple-ssa-pta-constraints.cc
	(refered_from_nonlocal_fn): Move to
	gimple-ssa-pta-constraints.cc
	(refered_from_nonlocal_var): Move to
	gimple-ssa-pta-constraints.cc
	(ipa_create_function_infos): Move to
	gimple-ssa-pta-constraints.cc
	(ipa_create_global_variable_infos): Move to
	gimple-ssa-pta-constraints.cc
	(ipa_build_constraints): Move to gimple-ssa-pta-constraints.cc
	* tree-ssa-structalias.h (struct constraint_stats):
	(determine_global_memory_access): External linkage, move to
	namespace pointer_analysis.
	(fndecl_maybe_in_other_partition): External linkage, move to
	namespace pointer_analysis.
	(new_var_info): External linkage, move to namespace
	pointer_analysis.
	* gimple-ssa-pta-constraints.cc: New file.
	* gimple-ssa-pta-constraints.h: New file.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
This commit is contained in:
Filip Kastl 2025-10-09 13:45:17 +02:00
parent 8581d66ec6
commit 0738f0ae35
5 changed files with 4369 additions and 4266 deletions

View File

@ -1804,6 +1804,7 @@ OBJS = \
tree-ssa-strlen.o \
tree-ssa-structalias.o \
pta-andersen.o \
gimple-ssa-pta-constraints.o \
tree-ssa-tail-merge.o \
tree-ssa-ter.o \
tree-ssa-threadbackward.o \

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
/* Constraint builder for tree based points-to analysis
Copyright (C) 2005-2025 Free Software Foundation, Inc.
Contributed by Daniel Berlin <dberlin@dberlin.org>
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 GIMPLE_SSA_PTA_CONSTRAINTS_H
#define GIMPLE_SSA_PTA_CONSTRAINTS_H
namespace pointer_analysis {
varinfo_t lookup_vi_for_tree (tree);
varinfo_t lookup_call_use_vi (gcall *);
varinfo_t lookup_call_clobber_vi (gcall *);
varinfo_t get_fi_for_callee (gcall *);
void init_constraint_builder (void);
void delete_constraint_builder (void);
void intra_build_constraints (void);
void ipa_build_constraints (void);
} // namespace pointer_analysis
#endif /* GIMPLE_SSA_PTA_CONSTRAINTS_H */

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,15 @@ enum { nothing_id = 1, anything_id = 2, string_id = 3,
escaped_id = 4, nonlocal_id = 5, escaped_return_id = 6,
storedanything_id = 7, integer_id = 8 };
/* In IPA mode there are varinfos for different aspects of reach
function designator. One for the points-to set of the return
value, one for the variables that are clobbered by the function,
one for its uses and one for each parameter (including a single
glob for remaining variadic arguments). */
enum { fi_clobbers = 1, fi_uses = 2,
fi_static_chain = 3, fi_result = 4, fi_parm_base = 5 };
/* Use 0x8000... as special unknown offset. */
#define UNKNOWN_OFFSET HOST_WIDE_INT_MIN
@ -167,6 +176,9 @@ struct constraint_stats
unsigned int points_to_sets_created;
};
extern bool use_field_sensitive;
extern int in_ipa_mode;
extern struct constraint_stats stats;
extern bitmap_obstack pta_obstack;
@ -198,6 +210,9 @@ varinfo_t first_vi_for_offset (varinfo_t start,
unsigned HOST_WIDE_INT offset);
varinfo_t first_or_preceding_vi_for_offset (varinfo_t start,
unsigned HOST_WIDE_INT offset);
void determine_global_memory_access (gcall *, bool *, bool *, bool *);
bool fndecl_maybe_in_other_partition (tree);
varinfo_t new_var_info (tree t, const char *name, bool add_id);
void dump_constraint (FILE *file, constraint_t c);
void dump_constraints (FILE *file, int from);
void dump_solution_for_var (FILE *file, unsigned int var);