]> gcc.gnu.org Git - gcc.git/commit
inter-procedural value range propagation
authorJan Hubicka <jh@suse.cz>
Mon, 20 Nov 2023 18:35:53 +0000 (19:35 +0100)
committerJan Hubicka <jh@suse.cz>
Mon, 20 Nov 2023 18:37:45 +0000 (19:37 +0100)
commit53ba8d669550d3a1f809048428b97ca607f95cf5
tree1c0da57f4c241b70c38a51fcebab3ff5644f6298
parent57c028acbec4f7b594e6b024e02d6c799b51e03d
inter-procedural value range propagation

implement very basic propapgation of return value ranges from VRP
pass.  This helps std::vector's push_back since we work out value range of
allocated block.  This propagates only within single translation unit.  I hoped
we will also do the propagation at WPA stage, but that needs more work on
ipa-cp side.

I also added code auto-detecting return_nonnull and corresponding -Wsuggest-attribute.

gcc/ChangeLog:

* cgraph.cc (add_detected_attribute_1): New function.
(cgraph_node::add_detected_attribute): Likewise.
* cgraph.h (cgraph_node::add_detected_attribute): Declare.
* common.opt: Add -Wsuggest-attribute=returns_nonnull.
* doc/invoke.texi: Document new flag.
* gimple-range-fold.cc (fold_using_range::range_of_call):
Use known reutrn value ranges.
* ipa-prop.cc (struct ipa_return_value_summary): New type.
(class ipa_return_value_sum_t): New type.
(ipa_return_value_sum): New summary.
(ipa_record_return_value_range): New function.
(ipa_return_value_range): New function.
* ipa-prop.h (ipa_return_value_range): Declare.
(ipa_record_return_value_range): Declare.
* ipa-pure-const.cc (warn_function_returns_nonnull): New funcion.
* ipa-utils.h (warn_function_returns_nonnull): Declare.
* symbol-summary.h: Fix comment.
* tree-vrp.cc (execute_ranger_vrp): Record return values.

gcc/testsuite/ChangeLog:

* g++.dg/ipa/devirt-2.C: Add noipa attribute to prevent ipa-vrp.
* g++.dg/ipa/devirt-7.C: Disable ipa-vrp.
* g++.dg/ipa/ipa-icf-2.C: Disable ipa-vrp.
* g++.dg/ipa/ipa-icf-3.C: Disable ipa-vrp.
* g++.dg/ipa/ivinline-1.C: Disable ipa-vrp.
* g++.dg/ipa/ivinline-3.C: Disable ipa-vrp.
* g++.dg/ipa/ivinline-5.C: Disable ipa-vrp.
* g++.dg/ipa/ivinline-8.C: Disable ipa-vrp.
* g++.dg/ipa/nothrow-1.C: Disable ipa-vrp.
* g++.dg/ipa/pure-const-1.C: Disable ipa-vrp.
* g++.dg/ipa/pure-const-2.C: Disable ipa-vrp.
* g++.dg/lto/inline-crossmodule-1_0.C: Disable ipa-vrp.
* gcc.c-torture/compile/pr106433.c: Add noipa attribute to prevent ipa-vrp.
* gcc.c-torture/execute/frame-address.c: Likewise.
* gcc.dg/vla-1.c: Add noipa attribute to prevent ipa-vrp.
* gcc.dg/ipa/fopt-info-inline-1.c: Disable ipa-vrp.
* gcc.dg/ipa/ipa-icf-25.c: Disable ipa-vrp.
* gcc.dg/ipa/ipa-icf-38.c: Disable ipa-vrp.
* gcc.dg/ipa/pure-const-1.c: Disable ipa-vrp.
* gcc.dg/ipa/remref-0.c: Add noipa attribute to prevent ipa-vrp.
* gcc.dg/tree-prof/time-profiler-1.c: Disable ipa-vrp.
* gcc.dg/tree-prof/time-profiler-2.c: Disable ipa-vrp.
* gcc.dg/tree-ssa/pr110269.c: Disable ipa-vrp.
* gcc.dg/tree-ssa/pr20701.c: Disable ipa-vrp.
* gcc.dg/tree-ssa/vrp05.c: Disable ipa-vrp.
* gcc.dg/tree-ssa/return-value-range-1.c: New test.
38 files changed:
gcc/cgraph.cc
gcc/cgraph.h
gcc/common.opt
gcc/doc/invoke.texi
gcc/gimple-range-fold.cc
gcc/ipa-prop.cc
gcc/ipa-prop.h
gcc/ipa-pure-const.cc
gcc/ipa-utils.h
gcc/symbol-summary.h
gcc/testsuite/g++.dg/ipa/devirt-2.C
gcc/testsuite/g++.dg/ipa/devirt-7.C
gcc/testsuite/g++.dg/ipa/ipa-icf-2.C
gcc/testsuite/g++.dg/ipa/ipa-icf-3.C
gcc/testsuite/g++.dg/ipa/ivinline-1.C
gcc/testsuite/g++.dg/ipa/ivinline-3.C
gcc/testsuite/g++.dg/ipa/ivinline-5.C
gcc/testsuite/g++.dg/ipa/ivinline-8.C
gcc/testsuite/g++.dg/ipa/nothrow-1.C
gcc/testsuite/g++.dg/ipa/pure-const-1.C
gcc/testsuite/g++.dg/ipa/pure-const-2.C
gcc/testsuite/g++.dg/lto/inline-crossmodule-1_0.C
gcc/testsuite/gcc.c-torture/compile/pr106433.c
gcc/testsuite/gcc.c-torture/execute/frame-address.c
gcc/testsuite/gcc.dg/ipa/fopt-info-inline-1.c
gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c
gcc/testsuite/gcc.dg/ipa/ipa-icf-38.c
gcc/testsuite/gcc.dg/ipa/pure-const-1.c
gcc/testsuite/gcc.dg/ipa/remref-0.c
gcc/testsuite/gcc.dg/nonnull-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-prof/time-profiler-1.c
gcc/testsuite/gcc.dg/tree-prof/time-profiler-2.c
gcc/testsuite/gcc.dg/tree-ssa/pr110269.c
gcc/testsuite/gcc.dg/tree-ssa/pr20701.c
gcc/testsuite/gcc.dg/tree-ssa/return-value-range-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/vrp05.c
gcc/testsuite/gcc.dg/vla-1.c
gcc/tree-vrp.cc
This page took 0.073598 seconds and 5 git commands to generate.