Commit 0e7b6a51 by David Malcolm Committed by David Malcolm

gimple const-correctness fixes

This patch converts various "gimple *" to "const gimple *" and similar
fixes for gimple subclasses, adding is_a_helper for gimple subclasses
to support the const form of as_a, and adding a few "const" overloads
of accessors.

This is enough to make pp_gimple_stmt_1's stmt const.

gcc/ChangeLog:
	* gimple-predict.h (gimple_predict_predictor): Make "gs" param
	const.
	(gimple_predict_outcome): Likewise.
	* gimple-pretty-print.c (do_niy): Likewise.
	(dump_unary_rhs): Likewise.
	(dump_binary_rhs): Likewise.
	(dump_ternary_rhs): Likewise.
	(dump_gimple_assign): Likewise.
	(dump_gimple_return): Likewise.
	(dump_gimple_call_args): Likewise.
	(pp_points_to_solution): Make "pt" param const.
	(dump_gimple_call): Make "gs" param const.
	(dump_gimple_switch): Likewise.
	(dump_gimple_cond): Likewise.
	(dump_gimple_label): Likewise.
	(dump_gimple_goto): Likewise.
	(dump_gimple_bind): Likewise.
	(dump_gimple_try): Likewise.
	(dump_gimple_catch): Likewise.
	(dump_gimple_eh_filter): Likewise.
	(dump_gimple_eh_must_not_throw): Likewise.
	(dump_gimple_eh_else): Likewise.
	(dump_gimple_resx): Likewise.
	(dump_gimple_eh_dispatch): Likewise.
	(dump_gimple_debug): Likewise.
	(dump_gimple_omp_for): Likewise.
	(dump_gimple_omp_continue): Likewise.
	(dump_gimple_omp_single): Likewise.
	(dump_gimple_omp_taskgroup): Likewise.
	(dump_gimple_omp_target): Likewise.
	(dump_gimple_omp_teams): Likewise.
	(dump_gimple_omp_sections): Likewise.
	(dump_gimple_omp_block): Likewise.
	(dump_gimple_omp_critical): Likewise.
	(dump_gimple_omp_ordered): Likewise.
	(dump_gimple_omp_scan): Likewise.
	(dump_gimple_omp_return): Likewise.
	(dump_gimple_transaction): Likewise.
	(dump_gimple_asm): Likewise.
	(dump_gimple_phi): Make "phi" param const.
	(dump_gimple_omp_parallel): Make "gs" param const.
	(dump_gimple_omp_task): Likewise.
	(dump_gimple_omp_atomic_load): Likewise.
	(dump_gimple_omp_atomic_store): Likewise.
	(dump_gimple_mem_ops): Likewise.
	(pp_gimple_stmt_1): Likewise.  Add "const" to the various as_a <>
	casts throughout.
	* gimple-pretty-print.h (gimple_stmt_1): Make gimple * param const.
	* gimple.h (is_a_helper <const gdebug *>::test): New.
	(is_a_helper <const ggoto *>::test): New.
	(is_a_helper <const glabel *>::test): New.
	(is_a_helper <const geh_else *>::test): New.
	(is_a_helper <const geh_mnt *>::test): New.
	(is_a_helper <const gswitch *>::test): New.
	(is_a_helper <const gtry *>::test): New.
	(is_a_helper <const greturn *>::test): New.
	(gimple_call_tail_p): Make param const.
	(gimple_call_return_slot_opt_p): Likewise.
	(gimple_call_va_arg_pack_p): Likewise.
	(gimple_call_use_set): Add const overload.
	(gimple_call_clobber_set): Likewise.
	(gimple_has_lhs): Make param const.
	(gimple_bind_body): Likewise.
	(gimple_catch_handler): Likewise.
	(gimple_eh_filter_failure): Likewise.
	(gimple_eh_must_not_throw_fndecl): Likewise.
	(gimple_eh_else_n_body): Likewise.
	(gimple_eh_else_e_body): Likewise.
	(gimple_try_eval): Likewise.
	(gimple_try_cleanup): Likewise.
	(gimple_phi_arg): Add const overload.
	(gimple_phi_arg_def): Make param const.
	(gimple_phi_arg_edge): Likewise.
	(gimple_phi_arg_location): Likewise.
	(gimple_phi_arg_has_location): Likewise.
	(gimple_debug_bind_get_var): Likewise.
	(gimple_debug_bind_get_value): Likewise.
	(gimple_debug_source_bind_get_var): Likewise.
	(gimple_debug_source_bind_get_value): Likewise.
	(gimple_omp_body): Likewise.
	(gimple_omp_for_collapse): Likewise.
	(gimple_omp_for_pre_body): Likewise.
	(gimple_transaction_body): Likewise.
	* tree-eh.c (lookup_stmt_eh_lp_fn): Make param "t" const.
	(lookup_stmt_eh_lp): Likewise.
	* tree-eh.h (lookup_stmt_eh_lp_fn): Make param const.
	(lookup_stmt_eh_lp): Likewise.
	* tree-ssa-alias.h (pt_solution_empty_p): Make param const.
	* tree-ssa-structalias.c (pt_solution_empty_p): Likewise.

From-SVN: r279581
parent b23c6a2c
2019-12-19 David Malcolm <dmalcolm@redhat.com>
* gimple-predict.h (gimple_predict_predictor): Make "gs" param
const.
(gimple_predict_outcome): Likewise.
* gimple-pretty-print.c (do_niy): Likewise.
(dump_unary_rhs): Likewise.
(dump_binary_rhs): Likewise.
(dump_ternary_rhs): Likewise.
(dump_gimple_assign): Likewise.
(dump_gimple_return): Likewise.
(dump_gimple_call_args): Likewise.
(pp_points_to_solution): Make "pt" param const.
(dump_gimple_call): Make "gs" param const.
(dump_gimple_switch): Likewise.
(dump_gimple_cond): Likewise.
(dump_gimple_label): Likewise.
(dump_gimple_goto): Likewise.
(dump_gimple_bind): Likewise.
(dump_gimple_try): Likewise.
(dump_gimple_catch): Likewise.
(dump_gimple_eh_filter): Likewise.
(dump_gimple_eh_must_not_throw): Likewise.
(dump_gimple_eh_else): Likewise.
(dump_gimple_resx): Likewise.
(dump_gimple_eh_dispatch): Likewise.
(dump_gimple_debug): Likewise.
(dump_gimple_omp_for): Likewise.
(dump_gimple_omp_continue): Likewise.
(dump_gimple_omp_single): Likewise.
(dump_gimple_omp_taskgroup): Likewise.
(dump_gimple_omp_target): Likewise.
(dump_gimple_omp_teams): Likewise.
(dump_gimple_omp_sections): Likewise.
(dump_gimple_omp_block): Likewise.
(dump_gimple_omp_critical): Likewise.
(dump_gimple_omp_ordered): Likewise.
(dump_gimple_omp_scan): Likewise.
(dump_gimple_omp_return): Likewise.
(dump_gimple_transaction): Likewise.
(dump_gimple_asm): Likewise.
(dump_gimple_phi): Make "phi" param const.
(dump_gimple_omp_parallel): Make "gs" param const.
(dump_gimple_omp_task): Likewise.
(dump_gimple_omp_atomic_load): Likewise.
(dump_gimple_omp_atomic_store): Likewise.
(dump_gimple_mem_ops): Likewise.
(pp_gimple_stmt_1): Likewise. Add "const" to the various as_a <>
casts throughout.
* gimple-pretty-print.h (gimple_stmt_1): Make gimple * param const.
* gimple.h (is_a_helper <const gdebug *>::test): New.
(is_a_helper <const ggoto *>::test): New.
(is_a_helper <const glabel *>::test): New.
(is_a_helper <const geh_else *>::test): New.
(is_a_helper <const geh_mnt *>::test): New.
(is_a_helper <const gswitch *>::test): New.
(is_a_helper <const gtry *>::test): New.
(is_a_helper <const greturn *>::test): New.
(gimple_call_tail_p): Make param const.
(gimple_call_return_slot_opt_p): Likewise.
(gimple_call_va_arg_pack_p): Likewise.
(gimple_call_use_set): Add const overload.
(gimple_call_clobber_set): Likewise.
(gimple_has_lhs): Make param const.
(gimple_bind_body): Likewise.
(gimple_catch_handler): Likewise.
(gimple_eh_filter_failure): Likewise.
(gimple_eh_must_not_throw_fndecl): Likewise.
(gimple_eh_else_n_body): Likewise.
(gimple_eh_else_e_body): Likewise.
(gimple_try_eval): Likewise.
(gimple_try_cleanup): Likewise.
(gimple_phi_arg): Add const overload.
(gimple_phi_arg_def): Make param const.
(gimple_phi_arg_edge): Likewise.
(gimple_phi_arg_location): Likewise.
(gimple_phi_arg_has_location): Likewise.
(gimple_debug_bind_get_var): Likewise.
(gimple_debug_bind_get_value): Likewise.
(gimple_debug_source_bind_get_var): Likewise.
(gimple_debug_source_bind_get_value): Likewise.
(gimple_omp_body): Likewise.
(gimple_omp_for_collapse): Likewise.
(gimple_omp_for_pre_body): Likewise.
(gimple_transaction_body): Likewise.
* tree-eh.c (lookup_stmt_eh_lp_fn): Make param "t" const.
(lookup_stmt_eh_lp): Likewise.
* tree-eh.h (lookup_stmt_eh_lp_fn): Make param const.
(lookup_stmt_eh_lp): Likewise.
* tree-ssa-alias.h (pt_solution_empty_p): Make param const.
* tree-ssa-structalias.c (pt_solution_empty_p): Likewise.
2019-12-19 Richard Sandiford <richard.sandiford@arm.com>
* config/aarch64/aarch64.c (aarch64_simd_valid_immediate): When
......@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3. If not see
/* Return the predictor of GIMPLE_PREDICT statement GS. */
static inline enum br_predictor
gimple_predict_predictor (gimple *gs)
gimple_predict_predictor (const gimple *gs)
{
GIMPLE_CHECK (gs, GIMPLE_PREDICT);
return (enum br_predictor) (gs->subcode & ~GF_PREDICT_TAKEN);
......@@ -47,7 +47,7 @@ gimple_predict_set_predictor (gimple *gs, enum br_predictor predictor)
/* Return the outcome of GIMPLE_PREDICT statement GS. */
static inline enum prediction
gimple_predict_outcome (gimple *gs)
gimple_predict_outcome (const gimple *gs)
{
GIMPLE_CHECK (gs, GIMPLE_PREDICT);
return (gs->subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
......
......@@ -31,7 +31,8 @@ extern void print_gimple_stmt (FILE *, gimple *, int, dump_flags_t = TDF_NONE);
extern void debug (gimple &ref);
extern void debug (gimple *ptr);
extern void print_gimple_expr (FILE *, gimple *, int, dump_flags_t = TDF_NONE);
extern void pp_gimple_stmt_1 (pretty_printer *, gimple *, int, dump_flags_t);
extern void pp_gimple_stmt_1 (pretty_printer *, const gimple *, int,
dump_flags_t);
extern void gimple_dump_bb (FILE *, basic_block, int, dump_flags_t);
extern void gimple_dump_bb_for_graph (pretty_printer *, basic_block);
extern void dump_ssaname_info_to_file (FILE *, tree, int);
......
......@@ -139,19 +139,19 @@ remove_stmt_from_eh_lp (gimple *t)
statement is not recorded in the region table. */
int
lookup_stmt_eh_lp_fn (struct function *ifun, gimple *t)
lookup_stmt_eh_lp_fn (struct function *ifun, const gimple *t)
{
if (ifun->eh->throw_stmt_table == NULL)
return 0;
int *lp_nr = ifun->eh->throw_stmt_table->get (t);
int *lp_nr = ifun->eh->throw_stmt_table->get (const_cast <gimple *> (t));
return lp_nr ? *lp_nr : 0;
}
/* Likewise, but always use the current function. */
int
lookup_stmt_eh_lp (gimple *t)
lookup_stmt_eh_lp (const gimple *t)
{
/* We can get called from initialized data when -fnon-call-exceptions
is on; prevent crash. */
......
......@@ -27,8 +27,8 @@ extern void using_eh_for_cleanups (void);
extern void add_stmt_to_eh_lp (gimple *, int);
extern bool remove_stmt_from_eh_lp_fn (struct function *, gimple *);
extern bool remove_stmt_from_eh_lp (gimple *);
extern int lookup_stmt_eh_lp_fn (struct function *, gimple *);
extern int lookup_stmt_eh_lp (gimple *);
extern int lookup_stmt_eh_lp_fn (struct function *, const gimple *);
extern int lookup_stmt_eh_lp (const gimple *);
extern bool make_eh_dispatch_edges (geh_dispatch *);
extern void make_eh_edges (gimple *);
extern edge redirect_eh_edge (edge, basic_block);
......
......@@ -162,7 +162,7 @@ extern void dump_alias_stats (FILE *);
/* In tree-ssa-structalias.c */
extern unsigned int compute_may_aliases (void);
extern bool pt_solution_empty_p (struct pt_solution *);
extern bool pt_solution_empty_p (const pt_solution *);
extern bool pt_solution_singleton_or_null_p (struct pt_solution *, unsigned *);
extern bool pt_solution_includes_global (struct pt_solution *);
extern bool pt_solution_includes (struct pt_solution *, const_tree);
......
......@@ -6804,7 +6804,7 @@ pt_solution_ior_into (struct pt_solution *dest, struct pt_solution *src)
/* Return true if the points-to solution *PT is empty. */
bool
pt_solution_empty_p (struct pt_solution *pt)
pt_solution_empty_p (const pt_solution *pt)
{
if (pt->anything
|| pt->nonlocal)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment