[committed] Fix ICE's due to jump-to-return optimization changes

Message ID 86bc153e-8fc7-5654-07f2-a6c16fd346c1@ventanamicro.com
State Committed
Commit 5da546d7e0561def07c783e6ec897aaa9e7837c6
Headers
Series [committed] Fix ICE's due to jump-to-return optimization changes |

Commit Message

Jeff Law Sept. 27, 2022, 6:19 a.m. UTC
  v850 and rl78 failed to build newlib with an ICE.  I've also got a 
report from an ARM automated tester that looks like the same underlying 
problem.


Basically we need to check if simple_return and return insns are 
available before trying to use them.


Bootstrapped on x86_64 (regression testing in progress). Verified this 
fixes the v850 and rl78 build failures.   Installing on the trunk 
momentarily.


Jeff
commit fe527a06a77093bc3de4ee2007516a4e9fa30f18
Author: Jeff Law <jeffreyalaw@gmail.com>
Date:   Tue Sep 27 01:44:38 2022 -0400

    Fix ICEs due to recent jump-to-return optimization
    
    gcc/
            * cfgrtl.cc (fixup_reorder_chain): Verify that simple_return
            and return are available before trying to use them.
  

Patch

diff --git a/gcc/cfgrtl.cc b/gcc/cfgrtl.cc
index 90cd6ee56a7..281a432f6a6 100644
--- a/gcc/cfgrtl.cc
+++ b/gcc/cfgrtl.cc
@@ -4049,7 +4049,8 @@  fixup_reorder_chain (void)
       rtx_insn *ret, *use;
       basic_block dest;
       if (bb_is_just_return (e_fall->dest, &ret, &use)
-	  && (PATTERN (ret) == simple_return_rtx || PATTERN (ret) == ret_rtx))
+	  && ((PATTERN (ret) == simple_return_rtx && targetm.have_simple_return ())
+	      || (PATTERN (ret) == ret_rtx && targetm.have_return ())))
 	{
 	  ret_label = PATTERN (ret);
 	  dest = EXIT_BLOCK_PTR_FOR_FN (cfun);