public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Update check after force_const_mem call in the plus_constant function to see if the value returned is not a NULL_RTX.
@ 2015-06-02 14:28 Andrew Bennett
  2015-06-02 20:14 ` Jeff Law
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Bennett @ 2015-06-02 14:28 UTC (permalink / raw)
  To: gcc-patches

Hi,

In the plus_constant function in explow.c the code to update a constant pool value
does not deal with the case where the value returned from force_const_mem is a 
NULL_RTX.  This occurs for the MIPS target because its 
cannot_force_const_mem target function does not allow constants (so that the 
move expanders can deal with them later on), this then causes the force_const_mem 
function to return a NULL_RTX and then causes GCC to segmentation fault when calling
the memory_address_p function.

The fix is to add a check that the tem variable is not a NULL_RTX before
the memory_address_p function call.  I have tested the fix on the mips-mti-linux-gnu
target for both mips32r2 o32 and mips64r2 n64 and there have been no regressions.

The patch and ChangeLog are below.

Ok to commit?


Many thanks,



Andrew



	* explow.c (plus_constant): Update check after force_const_mem call to see if the
	value returned is not a NULL_RTX.



diff --git a/gcc/explow.c b/gcc/explow.c
index d1a2bf8..8745aea 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -132,7 +132,9 @@ plus_constant (machine_mode mode, rtx x, HOST_WIDE_INT c,
 	{
 	  tem = plus_constant (mode, get_pool_constant (XEXP (x, 0)), c);
 	  tem = force_const_mem (GET_MODE (x), tem);
-	  if (memory_address_p (GET_MODE (tem), XEXP (tem, 0)))
+	  /* Targets may disallow some constants in the constant pool, thus
+	     force_const_mem may return NULL_RTX.  */
+	  if (tem && memory_address_p (GET_MODE (tem), XEXP (tem, 0)))
 	    return tem;
 	}
       break;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Update check after force_const_mem call in the plus_constant function to see if the value returned is not a NULL_RTX.
  2015-06-02 14:28 [PATCH] Update check after force_const_mem call in the plus_constant function to see if the value returned is not a NULL_RTX Andrew Bennett
@ 2015-06-02 20:14 ` Jeff Law
  2015-06-03  9:21   ` Andrew Bennett
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Law @ 2015-06-02 20:14 UTC (permalink / raw)
  To: Andrew Bennett, gcc-patches

On 06/02/2015 08:19 AM, Andrew Bennett wrote:
> Hi,
>
> In the plus_constant function in explow.c the code to update a constant pool value
> does not deal with the case where the value returned from force_const_mem is a
> NULL_RTX.  This occurs for the MIPS target because its
> cannot_force_const_mem target function does not allow constants (so that the
> move expanders can deal with them later on), this then causes the force_const_mem
> function to return a NULL_RTX and then causes GCC to segmentation fault when calling
> the memory_address_p function.
>
> The fix is to add a check that the tem variable is not a NULL_RTX before
> the memory_address_p function call.  I have tested the fix on the mips-mti-linux-gnu
> target for both mips32r2 o32 and mips64r2 n64 and there have been no regressions.
>
> The patch and ChangeLog are below.
>
> Ok to commit?
>
>
> Many thanks,
>
>
>
> Andrew
>
>
>
> 	* explow.c (plus_constant): Update check after force_const_mem call to see if the
> 	value returned is not a NULL_RTX.
OK.  Please install.

Thanks,
Jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] Update check after force_const_mem call in the plus_constant function to see if the value returned is not a NULL_RTX.
  2015-06-02 20:14 ` Jeff Law
@ 2015-06-03  9:21   ` Andrew Bennett
  2015-06-03 10:04     ` Andrew Bennett
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Bennett @ 2015-06-03  9:21 UTC (permalink / raw)
  To: Jeff Law, gcc-patches

> OK.  Please install.

Committed as SVN revision 224064.

Many thanks,


Andrew

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] Update check after force_const_mem call in the plus_constant function to see if the value returned is not a NULL_RTX.
  2015-06-03  9:21   ` Andrew Bennett
@ 2015-06-03 10:04     ` Andrew Bennett
  2015-06-03 12:48       ` Jeff Law
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Bennett @ 2015-06-03 10:04 UTC (permalink / raw)
  To: Jeff Law, gcc-patches

> > OK.  Please install.
> 
> Committed as SVN revision 224064.

Hi Jeff,

Are you also happy for me to backport the patch on to the 4.9 and 5 branches?

Many thanks,


Andrew

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Update check after force_const_mem call in the plus_constant function to see if the value returned is not a NULL_RTX.
  2015-06-03 10:04     ` Andrew Bennett
@ 2015-06-03 12:48       ` Jeff Law
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Law @ 2015-06-03 12:48 UTC (permalink / raw)
  To: Andrew Bennett, gcc-patches

On 06/03/2015 03:46 AM, Andrew Bennett wrote:
>>> OK.  Please install.
>>
>> Committed as SVN revision 224064.
>
> Hi Jeff,
>
> Are you also happy for me to backport the patch on to the 4.9 and 5 branches?
Jakub, Joseph or Richi would need to make that decision as the release 
managers.  I think the patch is quite safe from a backporting standpoint.

jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-03 12:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-02 14:28 [PATCH] Update check after force_const_mem call in the plus_constant function to see if the value returned is not a NULL_RTX Andrew Bennett
2015-06-02 20:14 ` Jeff Law
2015-06-03  9:21   ` Andrew Bennett
2015-06-03 10:04     ` Andrew Bennett
2015-06-03 12:48       ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).