On 06/05/2026 10:13, Soumya AR wrote:
> The narrow_gp_writes pass uses RTL-SSA and updates DF state via
> df_insn_rescan / df_insn_delete.  Both routines look up the insn's bb via
> BLOCK_FOR_INSN to mark it dirty after a change, but pass_free_cfg has already
> cleared those per-insn pointers by the time narrow_gp_writes runs. When
> BLOCK_FOR_INSN returns NULL, the dirty-marking step is silently skipped,
> leaving the DF stale.
> 
> Move the pass to run before pass_free_cfg.
> 
> Bootstrapped and regtested on aarch64-linux-gnu.
> SPEC CPU 2017 shows no codegen differences (compared to previous placement).
> OK for trunk?
> 
> Signed-off-by: Soumya AR <[email protected]>
> 
>       PR target/124895
> 
> gcc/ChangeLog:
> 
>       * config/aarch64/aarch64-passes.def (INSERT_PASS_BEFORE): Move pass

I think the text in parens here should be pass_narrow_gp_writes.

LGTM with that change, but please give others 24 hours to comment.

Thanks,
Alex

>       before pass_free_cfg.
> 
> gcc/testsuite/ChangeLog:
> 
>       * gcc.target/aarch64/narrow-gp-writes-8.c: New test.
> ---
>  gcc/config/aarch64/aarch64-passes.def                 |  2 +-
>  gcc/testsuite/gcc.target/aarch64/narrow-gp-writes-8.c | 10 ++++++++++
>  2 files changed, 11 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.target/aarch64/narrow-gp-writes-8.c
> 
> diff --git a/gcc/config/aarch64/aarch64-passes.def 
> b/gcc/config/aarch64/aarch64-passes.def
> index f4307aab551..2df7459af92 100644
> --- a/gcc/config/aarch64/aarch64-passes.def
> +++ b/gcc/config/aarch64/aarch64-passes.def
> @@ -26,4 +26,4 @@ INSERT_PASS_BEFORE (pass_late_thread_prologue_and_epilogue, 
> 1, pass_late_track_s
>  INSERT_PASS_BEFORE (pass_shorten_branches, 1, pass_insert_bti);
>  INSERT_PASS_BEFORE (pass_early_remat, 1, pass_ldp_fusion);
>  INSERT_PASS_BEFORE (pass_peephole2, 1, pass_ldp_fusion);
> -INSERT_PASS_BEFORE (pass_cleanup_barriers, 1, pass_narrow_gp_writes);
> +INSERT_PASS_BEFORE (pass_free_cfg, 1, pass_narrow_gp_writes);
> diff --git a/gcc/testsuite/gcc.target/aarch64/narrow-gp-writes-8.c 
> b/gcc/testsuite/gcc.target/aarch64/narrow-gp-writes-8.c
> new file mode 100644
> index 00000000000..94ef761e801
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/narrow-gp-writes-8.c
> @@ -0,0 +1,10 @@
> +/* PR target/124895 */
> +/* { dg-do compile } */
> +/* { dg-options "-Os -fpath-coverage -fno-tree-ccp -fprofile-generate 
> -mnarrow-gp-writes" } */
> +
> +void
> +foo (unsigned u)
> +{
> +  while (u)
> +    ;
> +}
> -- 
> 2.43.0

Reply via email to