Make gimple_build main workers more flexible
authorRichard Biener <rguenther@suse.de>
Thu, 12 May 2022 06:24:12 +0000 (08:24 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 13 May 2022 06:18:33 +0000 (08:18 +0200)
commitba2068893c37deaa418d9b2126414f6824e66655
tree6f095857999bb756f52b23c33747efef96996981
parent90a8eab4a1292430467f68b65e5127f7760acc94
Make gimple_build main workers more flexible

The following makes the main gimple_build API take a
gimple_stmt_iterator, whether to insert before or after and
an iterator update argument to make it more convenient to use
in certain situations (see the tree-vect-generic.cc hunks for
an example).  It also makes the case we insert into the IL
somewhat distinct from inserting into a standalone sequence in
that it simplifies built expressions the same way as inserting
and calling fold_stmt (..., follow_all_ssa_edges) would.  When
inserting into a standalone sequence we restrict simplification
to defs within the currently building sequence.

The patch only amends the tree_code gimple_build API, I will
followup with converting the rest as well.  The patch got larger
than intended because the template forwarders now use gsi_last
which introduces a dependency on gimple-iterator.h requiring
mass #include re-org across the tree.  There are two frontend
specific files including gimple-fold.h just for some padding
clearing stuff - I've removed the include and instead moved
the declarations to fold-const.h (but not the implementations).
Otherwise I'd have to include half of the middle-end headers in
those files which I didn't much like.

2022-05-12  Richard Biener  <rguenther@suse.de>

gcc/cp/
* constexpr.cc: Remove gimple-fold.h include.

gcc/c-family/
* c-omp.cc: Remove gimple-fold.h include.

gcc/analyzer/
* supergraph.cc: Re-order gimple-fold.h include.

gcc/
* gimple-fold.cc (gimple_build): Adjust for new
main API.
* gimple-fold.h (gimple_build): New main APIs with
iterator, insert direction and iterator update.
(gimple_build): New forwarder template.
(clear_padding_type_may_have_padding_p): Remove.
(clear_type_padding_in_mask): Likewise.
(arith_overflowed_p): Likewise.
* fold-const.h (clear_padding_type_may_have_padding_p): Declare.
(clear_type_padding_in_mask): Likewise.
(arith_overflowed_p): Likewise.
* tree-vect-generic.cc (gimplify_build3): Use main gimple_build API.
(gimplify_build2): Likewise.
(gimplify_build1): Likewise.
* ubsan.cc (ubsan_expand_ptr_ifn): Likewise, avoid extra
compare stmt.
* gengtype.cc (open_base_files): Re-order includes.
* builtins.cc: Re-order gimple-fold.h include.
* calls.cc: Likewise.
* cgraphbuild.cc: Likewise.
* cgraphunit.cc: Likewise.
* config/rs6000/rs6000-builtin.cc: Likewise.
* config/rs6000/rs6000-call.cc: Likewise.
* config/rs6000/rs6000.cc: Likewise.
* config/s390/s390.cc: Likewise.
* expr.cc: Likewise.
* fold-const.cc: Likewise.
* function-tests.cc: Likewise.
* gimple-match-head.cc: Likewise.
* gimple-range-fold.cc: Likewise.
* gimple-ssa-evrp-analyze.cc: Likewise.
* gimple-ssa-evrp.cc: Likewise.
* gimple-ssa-sprintf.cc: Likewise.
* gimple-ssa-warn-access.cc: Likewise.
* gimplify.cc: Likewise.
* graphite-isl-ast-to-gimple.cc: Likewise.
* ipa-cp.cc: Likewise.
* ipa-devirt.cc: Likewise.
* ipa-prop.cc: Likewise.
* omp-low.cc: Likewise.
* pointer-query.cc: Likewise.
* range-op.cc: Likewise.
* tree-cfg.cc: Likewise.
* tree-if-conv.cc: Likewise.
* tree-inline.cc: Likewise.
* tree-object-size.cc: Likewise.
* tree-ssa-ccp.cc: Likewise.
* tree-ssa-dom.cc: Likewise.
* tree-ssa-forwprop.cc: Likewise.
* tree-ssa-ifcombine.cc: Likewise.
* tree-ssa-loop-ivcanon.cc: Likewise.
* tree-ssa-math-opts.cc: Likewise.
* tree-ssa-pre.cc: Likewise.
* tree-ssa-propagate.cc: Likewise.
* tree-ssa-reassoc.cc: Likewise.
* tree-ssa-sccvn.cc: Likewise.
* tree-ssa-strlen.cc: Likewise.
* tree-ssa.cc: Likewise.
* value-pointer-equiv.cc: Likewise.
* vr-values.cc: Likewise.

gcc/testsuite/
* gcc.dg/plugin/diagnostic_group_plugin.c: Reorder or remove
gimple-fold.h include.
* gcc.dg/plugin/diagnostic_plugin_show_trees.c:
Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_inlining.c:
Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_metadata.c:
Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_paths.c:
Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c:
Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_string_literals.c: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c:
Likewise.
* gcc.dg/plugin/finish_unit_plugin.c: Likewise.
* gcc.dg/plugin/ggcplug.c: Likewise.
* gcc.dg/plugin/must_tail_call_plugin.c: Likewise.
* gcc.dg/plugin/one_time_plugin.c: Likewise.
* gcc.dg/plugin/selfassign.c: Likewise.
* gcc.dg/plugin/start_unit_plugin.c: Likewise.
* g++.dg/plugin/selfassign.c: Likewise.
67 files changed:
gcc/analyzer/supergraph.cc
gcc/builtins.cc
gcc/c-family/c-omp.cc
gcc/calls.cc
gcc/cgraphbuild.cc
gcc/cgraphunit.cc
gcc/config/rs6000/rs6000-builtin.cc
gcc/config/rs6000/rs6000-call.cc
gcc/config/rs6000/rs6000.cc
gcc/config/s390/s390.cc
gcc/cp/constexpr.cc
gcc/expr.cc
gcc/fold-const.cc
gcc/fold-const.h
gcc/function-tests.cc
gcc/gengtype.cc
gcc/gimple-fold.cc
gcc/gimple-fold.h
gcc/gimple-match-head.cc
gcc/gimple-range-fold.cc
gcc/gimple-ssa-evrp-analyze.cc
gcc/gimple-ssa-evrp.cc
gcc/gimple-ssa-sprintf.cc
gcc/gimple-ssa-warn-access.cc
gcc/gimplify.cc
gcc/graphite-isl-ast-to-gimple.cc
gcc/ipa-cp.cc
gcc/ipa-devirt.cc
gcc/ipa-prop.cc
gcc/omp-low.cc
gcc/pointer-query.cc
gcc/range-op.cc
gcc/testsuite/g++.dg/plugin/selfassign.c
gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_metadata.c
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
gcc/testsuite/gcc.dg/plugin/finish_unit_plugin.c
gcc/testsuite/gcc.dg/plugin/ggcplug.c
gcc/testsuite/gcc.dg/plugin/must_tail_call_plugin.c
gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
gcc/testsuite/gcc.dg/plugin/selfassign.c
gcc/testsuite/gcc.dg/plugin/start_unit_plugin.c
gcc/tree-cfg.cc
gcc/tree-if-conv.cc
gcc/tree-inline.cc
gcc/tree-object-size.cc
gcc/tree-ssa-ccp.cc
gcc/tree-ssa-dom.cc
gcc/tree-ssa-forwprop.cc
gcc/tree-ssa-ifcombine.cc
gcc/tree-ssa-loop-ivcanon.cc
gcc/tree-ssa-math-opts.cc
gcc/tree-ssa-pre.cc
gcc/tree-ssa-propagate.cc
gcc/tree-ssa-reassoc.cc
gcc/tree-ssa-sccvn.cc
gcc/tree-ssa-strlen.cc
gcc/tree-ssa.cc
gcc/tree-vect-generic.cc
gcc/ubsan.cc
gcc/value-pointer-equiv.cc
gcc/vr-values.cc