On 7/15/2026 11:24 PM, Sebastian Huber wrote:
> Instead of inserting each generated statement onto an edge individually, which
> happens repeatedly for the same edge while flushing the condition coverage
> accumulators, build up a local gimple_seq for the edge and insert it once with
> a single gsi_insert_seq_on_edge() call.  emit_assign() and emit_bitwise_op()
> are changed to append to a caller-supplied gimple_seq instead of inserting
> directly on an edge.
>
> Suggested by Andrew Pinski:
>
> https://inbox.sourceware.org/gcc-patches/CALvbMcD_BM-PESKx1nei4vccLomXLgvS=yto8kkgrpmahif...@mail.gmail.com/#t
>
> Tested on x86_64-pc-linux-gnu (gcov.exp, gcc.dg gcov*.c, tree-prof.exp) with 
> no
> regressions.
>
> gcc/ChangeLog:
>
>       * tree-profile.cc (emit_assign): Append to a gimple_seq instead
>       of inserting on an edge.
>       (emit_bitwise_op): Likewise.
>       (instrument_decisions): Build up a local gimple_seq per edge and
>       insert it once instead of inserting each statement individually.
>
> Signed-off-by: Sebastian Huber <[email protected]>
OK for the trunk.  One minor thing you might want to incorporate into 
your change or as a followup noted below...
> ---
>   gcc/tree-profile.cc | 56 ++++++++++++++++++++++-----------------------
>   1 file changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
> index cf81608df0c..12a5b00a886 100644
> --- a/gcc/tree-profile.cc
> +++ b/gcc/tree-profile.cc
> @@ -612,38 +612,32 @@ masking_vectors (conds_ctx& ctx, 
> array_slice<basic_block> blocks,
>       }
>   }
>   
> -/* Emit LHS = RHS on edges.  This is just a short hand that automates the
> -   building of the assign and immediately puts it on the edge, which becomes
> -   noisy.  */
> +/* Emit LHS = RHS onto SEQ.  This is just a short hand that automates the
> +   building of the assign, which becomes noisy.  */
>   tree
> -emit_assign (edge e, tree lhs, tree rhs)
> +emit_assign (gimple_seq *seq, tree lhs, tree rhs)
Consider making the emit_assign functions static since they're not used 
out of tree-profile.  No need for another review if you decide to make 
that change, it's pre-approved as either part of this kit or as a 
separate patch.

Thanks again!

jeff

Reply via email to