GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
aarch64

AArch64: Move pass_narrow_gp_writes before pass_free_cfg to fix DF state.

The narrow_gp_writes pass now runs before pass_free_cfg in GCC for AArch64, preventing stale dataflow (DF) state issues.

The narrow_gp_writes pass in GCC for AArch64 architectures uses RTL-SSA and updates dataflow (DF) state. The pass_free_cfg pass was clearing per-instruction pointers before narrow_gp_writes ran, leading to stale DF information and potentially incorrect optimizations. Moving narrow_gp_writes to run before pass_free_cfg resolves this issue.

In Details

The narrow_gp_writes pass optimizes AArch64 code by replacing 64-bit general-purpose register writes with narrower 32-bit writes when possible; it relies on RTL-SSA and DF analysis. The pass_free_cfg pass frees the control flow graph (CFG) data structures, including the BLOCK_FOR_INSN pointers. Running narrow_gp_writes after pass_free_cfg results in null BLOCK_FOR_INSN lookups during df_insn_rescan or df_insn_delete, causing stale DF state.

For Context

Modern compilers use a variety of passes to transform source code into optimized machine code. Dataflow analysis tracks how data flows through the program to enable optimizations. This commit addresses an issue in the AArch64 backend of GCC where the narrow_gp_writes pass, which attempts to reduce register sizes, was running after the pass_free_cfg pass, invalidating the dataflow information it used. By reordering these passes, the compiler can now perform this optimization more reliably.

Filed Under: aarch64optimizationdataflowbugfix