Skip to content

Commit

Permalink
ipa-sra: Forward propagation of sizes which are safe to dereference
Browse files Browse the repository at this point in the history
Hi,

I'm re-posting patches which I have posted at the end of stage 1 but
which have not passed review yet.

8<--------------------------------------------------------------------

The previous patch established a way to propagate information about
parameters from callers to callees (even though then the actual
splitting is done in the opposite direction), this patch adds to that
information about size of the parameters that is known to be safe to
dereference in the callers - the information currently does not come
from actual dereferences but only when we pass a reference to a known
declaration, but we can use e.g. dereferences in BBs dominating the
call, for example too, if we decide it is worth it.

References which look like splitting candidates but are not always
dereferenced are - assuming the dereferences are not improbable - not
discarded straight away but only marked as conditionally
dereferenceable.  IPA phase then makes sure that they stay candidates
only if all incoming edges have big enough known-to-be-safe size.

Bootstrapped and tested individually when I originally posted it and
now bootstrapped and LTO-bootstrapped and tested as part of the whole
series.  OK for master?

gcc/ChangeLog:

2022-11-11  Martin Jambor  <mjambor@suse.cz>

	* ipa-sra.cc (isra_param_desc): New fields safe_size,
	conditionally_dereferenceable and safe_size_set.
	(struct gensum_param_desc): New field conditionally_dereferenceable.
	(struct isra_param_flow): Updated comment of field unit_size.
	(ipa_sra_function_summaries::duplicate): Copy the new fields.
	(isra_call_summary::dump): Dump unit_size when representing safe_size.
	(dump_gensum_param_descriptor): Dump new flag.
	(dump_isra_param_descriptor): Dump new fields.
	(isra_analyze_call): Fill unit_size when it represents known safe
	size.
	(check_gensum_access): Instead of disqualifying pointers which are not
	always dereference, mark them as conditionally dereferencable if loads
	are frequent enough.
	(process_scan_results): Copy the conditionally_dereferenceable flag.
	(isra_write_node_summary): Stream new fields, or assert they are not
	initialized yet.
	(isra_read_node_info): Stream new fields.
	(update_safe_size): New function.
	(propagate_param_hints_accross_call): Propagate safe_sizes.
	(propagate_hints_to_all_callees): New function.
	(adjust_parameter_descriptions): Check conditionally_dereferenceable
	candidates, rework dumping.
	(ipa_sra_analysis): Move most of hint propagation for one node to
	propagate_hints_to_all_callees.  Add another loop to stabilize within
	SCCs and another one to verify.

gcc/testsuite/ChangeLog:

2022-11-11  Martin Jambor  <mjambor@suse.cz>

	* gcc.dg/ipa/ipa-sra-26.c: New test.
	* gcc.dg/ipa/ipa-sra-27.c: Likewise.
	* gcc.dg/ipa/ipa-sra-28.c: Likewise.
  • Loading branch information
jamborm authored and ouuleilei-bot committed Dec 12, 2022
1 parent fec241e commit d1fc975
Show file tree
Hide file tree
Showing 4 changed files with 328 additions and 56 deletions.
Loading

0 comments on commit d1fc975

Please sign in to comment.