https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109112
--- Comment #18 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Dominic Plunkett <[email protected]>: https://gcc.gnu.org/g:97a90a261aad24efd931272127df570cac833e54 commit r17-6877-g97a90a261aad24efd931272127df570cac833e54 Author: Dominic P <[email protected]> Date: Fri Nov 27 22:16:05 2026 +0000 ipa: Fix argument indices in modify_call for .ASSUME callback edges For a callback edge to an assume function, modify_call looked up mod_info->index_map, which is indexed by arguments of the original call, with the callee parameter index apm->base_index, and then mapped the result through ci->arg_mapping as if it were a parameter index. When a clone of the function containing the .ASSUME had removed or split one of the .ASSUME arguments, this hit the index_map assert. Map the parameter index through ci->arg_mapping first and index_map second, and take the argument directly; callback_call_arg_summary has no other users and is removed. modify_call_stmt recorded pass_through_map base indices of a callback call in parameter space through ci->inverted_mapping, while record_argument_state_1 and index_map work on call arguments; record the call argument index as for any other call and compare it with the mapped index. Count old_nargs, orig_nargs and kept in call arguments again, as before r17-5631-g592a97c9441. old_nargs was ci->arg_mapping.length (), which does not follow always_copy_delta, so when a clone dropped an .ASSUME argument without a replacement, such as an unused sub-object of a split parameter, the always-copy assert fired. Assume functions are never variadic, so skip copying trailing arguments for callback edges. vargs also holds the assume body address, so reserve LEN + 1 elements; with 16 or more pushed arguments the last quick_push overflowed. Assisted-by: Claude Opus 5.5 (Anthropic) Signed-off-by: Dominic P <[email protected]> gcc/ChangeLog: PR ipa/109112 * callback-info.cc (callback_call_arg_summary): Remove. * callback-info.h (callback_call_arg_summary): Likewise. * ipa-param-manipulation.cc (ipa_param_adjustments::modify_call): Map callee parameter indices to call argument indices before looking them up in the edge modification index_map and pass_through_map. Count old_nargs, orig_nargs and kept in call arguments. Do not copy trailing arguments for callback edges. Reserve space for the assume body address in vargs. (ipa_param_body_adjustments::modify_call_stmt): Record call argument indices in pass_through_map for callback calls too. gcc/testsuite/ChangeLog: PR ipa/109112 * g++.dg/ipa/ipa-sra-assume-4.C: New test. * g++.dg/ipa/ipa-sra-assume-5.C: New test. * g++.dg/ipa/ipa-sra-assume-6.C: New test. * g++.dg/ipa/ipa-sra-assume-7.C: New test.
