https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112478
--- Comment #3 from Michael T. Kloos <Michael at MichaelKloos dot com> --- Created attachment 56560 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56560&action=edit Sample program to reproduce the bug I have created and attached a small simple program which shows the bug. If compiled with an earlier version of GCC, it runs fine. If compiled with a later version, after the aforementioned commit, it goes into an infinite loop. The problem is that the ra register clobber is not being honored. You can see the difference in objdump disassembly of the the call_invert_and_sum() function. Here is the disassembly of the good version: 000101e0 <call_invert_and_sum>: 101e0: ff010113 add sp,sp,-16 101e4: 00112623 sw ra,12(sp) 101e8: f21ff0ef jal 10108 <invert_and_sum> 101ec: 00c12083 lw ra,12(sp) 101f0: 01010113 add sp,sp,16 101f4: 00008067 ret Here is the disassembly of the bad version: 000101e0 <call_invert_and_sum>: 101e0: f29ff0ef jal 10108 <invert_and_sum> 101e4: 00008067 ret This should make it very clear why the program gets trapped in an infinite loop in the second example.
