diff mbox

[RFA,middle-end] Fix PR middle-end/49220

Message ID 20121107.182318.296903589.kkojima@rr.iij4u.or.jp
State New
Headers show

Commit Message

Kaz Kojima Nov. 7, 2012, 9:23 a.m. UTC
Hi,

The attached is yet another create_pre_exit patch to fix
PR middle-end/49220 which is an ice-on-invalid-code.  It's for
non-void function which returns without value.  The patch is
tested with bootstrap and the top level "make -k check" on
i686-pc-linux-gnu with no new failures and regtested on cross
sh4-unknown-linux-gnu.

Regards,
	kaz
--
2012-11-07  Kaz Kojima  <kkojima@gcc.gnu.org>

	PR middle-end/49220
	* mode-switching.c (create_pre_exit): Set short_block if there
	are no copy insns.

Comments

Eric Botcazou Nov. 7, 2012, 9:57 a.m. UTC | #1
> 2012-11-07  Kaz Kojima  <kkojima@gcc.gnu.org>
> 
> 	PR middle-end/49220
> 	* mode-switching.c (create_pre_exit): Set short_block if there
> 	are no copy insns.

OK, but clearly a rewrite of the function would be in order.
Uros Bizjak Nov. 7, 2012, 10 a.m. UTC | #2
On Wed, Nov 7, 2012 at 10:57 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> 2012-11-07  Kaz Kojima  <kkojima@gcc.gnu.org>
>>
>>       PR middle-end/49220
>>       * mode-switching.c (create_pre_exit): Set short_block if there
>>       are no copy insns.
>
> OK, but clearly a rewrite of the function would be in order.

Please also add the testcase from the PR to the testsuite.

Uros.
diff mbox

Patch

--- ORIG/trunk/gcc/mode-switching.c	2012-11-06 07:33:20.000000000 +0900
+++ trunk/gcc/mode-switching.c	2012-11-07 07:55:25.000000000 +0900
@@ -322,7 +322,14 @@  create_pre_exit (int n_entities, int *en
 			     && GET_CODE (SUBREG_REG (copy_reg)) == REG)
 		      copy_start = REGNO (SUBREG_REG (copy_reg));
 		    else
-		      break;
+		      {
+			/* When control reaches end of non-void function,
+			   there are no return copy insns at all.  This
+			   avoids an ice on that invalid function.  */
+			if (ret_start + nregs == ret_end)
+			  short_block = 1;
+			break;
+		      }
 		    if (copy_start >= FIRST_PSEUDO_REGISTER)
 		      break;
 		    copy_num