https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121762
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Just some notes on optimize_stack_restore. The comment in front says: ``` ... Optimize it out if there is another __builtin_stack_restore in the same basic block and no calls or ASM_EXPRs are in between, or if this block's only outgoing edge is to EXIT_BLOCK and there are no calls or ASM_EXPRs after this __builtin_stack_restore. ``` But the loop does something different. It checks if there are calls but allows normal builtins too. So it could allow __atomic_*. It does not allow internal functions nor target builtins. I think the check should allow pure/const functions but not all normal builtins. PR 43220 happened because of the comment was not the same as the code.