ipa-icf: Correctly process callers past thunks in redirect_all_callers.
Ensures interprocedural inlining consolidator redirects all necessary callers, even when jumping over thunks.
The IPA-ICF pass’s redirect_all_callers function previously failed to redirect callers that appeared after a thunk in the call list. This was because it advanced to the thunk’s callee instead of the next caller in the list. This change corrects the logic to ensure all callers are processed, preventing some function calls from being incorrectly left unredirected.
In Details
In GCC's IPA-ICF (Interprocedural Analysis - Identical Code Folding) pass, redirect_all_callers is responsible for updating call sites when identical functions are merged. When encountering a 'thunk' (a small function that simply transfers control to another function), the next_callee logic was incorrectly used instead of advancing to the actual next caller in the list of callers being iterated. This commit fixes redirect_all_callers to correctly step to the next caller, ensuring that all callers of a function, including those after a thunk, are properly updated.
- IPA-ICF
- Interprocedural Analysis - Identical Code Folding. A GCC optimization pass that identifies identical functions or code sections across a program and merges them to reduce code size and potentially improve instruction cache usage.
- Thunk
- A small piece of code that acts as an intermediary, often used to transfer control from one function to another, potentially with some parameter manipulation or context switching.
- Callers
- Functions that invoke or call a particular function.