Skip to content
Snippets Groups Projects
Unverified Commit 5d740f56 authored by Martin Jambor's avatar Martin Jambor Committed by Martin Jambor
Browse files

ipa: Improve how we derive value ranges from IPA invariants

I believe that the current function ipa_range_set_and_normalize lacks
a check that a base of an ADDR_EXPR lacks a test whether the base
really cannot be NULL, so this patch adds it.  Moreover, I never liked
the name as I do not think it makes the value of ranges any more
normal but rather just special-cases non-zero ip_invariant pointers.
Therefore, I have given it a different name and moved it to a .cc
file, our LTO bootstrap should inline (and/or split) it if necessary
anyway.

Because, as Honza correctly pointed out, deriving non-NULLness from a
pointer depends on flag_delete_null_pointer_checks which is an
optimization flag and thus depends on a given function, in this
version of the patch ipa_get_range_from_ip_invariant gets a
context_node parameter for that purpose.  This then needs to be used
within symtab_node::nonzero_address which gets a special overload in
which the value of the flag can be provided as a parameter.

gcc/ChangeLog:

2024-12-11  Martin Jambor  <mjambor@suse.cz>

	* cgraph.h (symtab_node): Add a new overload of nonzero_address.
	* symtab.cc (symtab_node::nonzero_address): Add a new overload whith a
	parameter for delete_null_pointer_checks.  Make the original overload
	call the new one which has retains the actual implementation.
	* ipa-prop.h (ipa_get_range_from_ip_invariant): Declare.
	(ipa_range_set_and_normalize): Remove.
	* ipa-prop.cc (ipa_get_range_from_ip_invariant): New function.
	(ipa_range_set_and_normalize): Remove.
	* ipa-cp.cc (ipa_vr_intersect_with_arith_jfunc): Add a new parameter
	context_node. Use ipa_get_range_from_ip_invariant instead of
	ipa_range_set_and_normalize and pass to it the new parameter.
	(ipa_value_range_from_jfunc): Pass cs->caller as the context_node to
	ipa_vr_intersect_with_arith_jfunc.
	(propagate_vr_across_jump_function): Likewise.
	(ipa_get_range_from_ip_invariant): New function.
	* ipa-fnsummary.cc (evaluate_conditions_for_known_args): Use
	ipa_get_range_from_ip_invariant instead of ipa_range_set_and_normalize
parent 1eb41aeb
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment