]> gcc.gnu.org Git - gcc.git/commit
c++, tree: optimize walk_tree_1 and cp_walk_subtrees
authorPatrick Palka <ppalka@redhat.com>
Fri, 21 Apr 2023 16:59:37 +0000 (12:59 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 21 Apr 2023 16:59:37 +0000 (12:59 -0400)
commit857c8e3b3bba14bfb078a194993f5f31e0d90391
tree59b11cbdc964155b47fa50c356159e05ce7bb311
parent7508aacf95dca3e340513e08256c19f8e3d38dae
c++, tree: optimize walk_tree_1 and cp_walk_subtrees

These functions currently repeatedly dereference tp during the subtree
walks, dereferences which the compiler can't CSE because it can't
guarantee that the subtree walking doesn't modify *tp.

But we already implicitly require that TREE_CODE (*tp) remains the same
throughout the subtree walks, so it doesn't seem to be a huge leap to
strengthen that to requiring *tp remains the same.

So this patch manually CSEs the dereferences of *tp.  This means that a
callback function can no longer replace *tp with another tree (of the
same TREE_CODE) when walking one of its subtrees, but that doesn't sound
like a useful capability anyway.

gcc/cp/ChangeLog:

* tree.cc (cp_walk_subtrees): Avoid repeatedly dereferencing tp.
<case DECLTYPE_TYPE>: Use cp_unevaluated and WALK_SUBTREE.
<case ALIGNOF_EXPR etc>: Likewise.

gcc/ChangeLog:

* tree.cc (walk_tree_1): Avoid repeatedly dereferencing tp
and type_p.
gcc/cp/tree.cc
gcc/tree.cc
This page took 0.06493 seconds and 6 git commands to generate.