public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix uninitialised use in mips_split_move
@ 2019-07-05  8:52 Richard Sandiford
  2019-07-06 16:20 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2019-07-05  8:52 UTC (permalink / raw)
  To: gcc-patches

While testing the fix for PR91068, I hit an rtl checking failure
while building newlib.  mips_split_move was decomposing an address that
happened to be symbolic and then tried to access the REGNO of the base
register field, which wasn't initialised but which by chance pointed to
valid memory.

Tested on mipsisa64-elf.  OK to install?

Richard


2019-07-05  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* config/mips/mips.c (mips_split_move): Zero-initialize addr
	and check whether addr.reg is nonnull before using it.

Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2019-07-01 09:37:07.300523814 +0100
+++ gcc/config/mips/mips.c	2019-07-05 09:46:46.407526855 +0100
@@ -4849,7 +4849,7 @@ mips_split_move (rtx dest, rtx src, enum
      can forward SRC for DEST.  This is most useful if the next insn is a
      simple store.   */
   rtx_insn *insn = (rtx_insn *)insn_;
-  struct mips_address_info addr;
+  struct mips_address_info addr = {};
   if (insn)
     {
       rtx_insn *next = next_nonnote_nondebug_insn_bb (insn);
@@ -4862,7 +4862,7 @@ mips_split_move (rtx dest, rtx src, enum
 		{
 		  rtx tmp = XEXP (src, 0);
 		  mips_classify_address (&addr, tmp, GET_MODE (tmp), true);
-		  if (REGNO (addr.reg) != REGNO (dest))
+		  if (addr.reg && REGNO (addr.reg) != REGNO (dest))
 		    validate_change (next, &SET_SRC (set), src, false);
 		}
 	      else

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

* Re: Fix uninitialised use in mips_split_move
  2019-07-05  8:52 Fix uninitialised use in mips_split_move Richard Sandiford
@ 2019-07-06 16:20 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2019-07-06 16:20 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 7/5/19 2:48 AM, Richard Sandiford wrote:
> While testing the fix for PR91068, I hit an rtl checking failure
> while building newlib.  mips_split_move was decomposing an address that
> happened to be symbolic and then tried to access the REGNO of the base
> register field, which wasn't initialised but which by chance pointed to
> valid memory.
> 
> Tested on mipsisa64-elf.  OK to install?
> 
> Richard
> 
> 
> 2019-07-05  Richard Sandiford  <richard.sandiford@arm.com>
> 
> gcc/
> 	* config/mips/mips.c (mips_split_move): Zero-initialize addr
> 	and check whether addr.reg is nonnull before using it.
OK
jeff

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

end of thread, other threads:[~2019-07-06 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-05  8:52 Fix uninitialised use in mips_split_move Richard Sandiford
2019-07-06 16:20 ` 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).