df: Rescan only sibling calls in df_update_entry_exit_and_calls
Optimization in dataflow analysis reduces unnecessary rescanning of call instructions.
This commit optimizes the df_update_entry_exit_and_calls function in GCC’s dataflow analysis. Previously, this function rescanned all call instructions within a function, even if their references hadn’t changed, which was a performance bottleneck. The change narrows the scope to only rescan ‘sibling calls’ and only when the exit block’s uses have actually changed. This optimization was observed to reduce compilation instructions by 3% for the fmtlib test suite on AArch64.
In Details
The df_update_entry_exit_and_calls function, used by passes like dataflow analysis, shrink-wrapping, and prologue/epilogue insertion, was inefficiently rescanning all call instructions in a function. This commit refactors it to only rescan sibling calls and only if df_update_exit_block_uses returns true, indicating a change in exit block uses. This optimization targets the performance impact of df_get_call_refs, which previously incurred overhead regardless of actual changes. The call site in stack-ptr-mod.cc is updated to use the new function, ensuring sibling calls are re-evaluated…
- dataflow analysis
- A static code analysis technique that gathers information about the possible values of variables throughout the execution of a program.
- sibling call
- In control flow graphs, a sibling call refers to a call instruction that is not the only call instruction within its basic block, or has certain structural relationships with other calls.
- basic block
- A sequence of instructions with a single entry point and a single exit point, such that execution proceeds through the block without halt or possibility of branching except at the exit.
- shrink-wrapping
- An optimization pass that attempts to move invariant code, such as function prologues and epilogues, to the boundary of a loop or function to reduce redundancy.