[PATCH] FIx a valgrind reported issue in build tools (PR other/58712)
Jakub Jelinek
jakub@redhat.com
Tue Jan 28 22:48:00 GMT 2014
Hi!
I've started an --enable-checking=valgrind bootstrap during the weekend,
but only on Sunday afternoon and thus killed it on Monday morning, so it
didn't get very far, but still reported a problem where the build tools
had uninitialized memory use in copy_rtx:
case CLOBBER:
/* Share clobbers of hard registers (like cc0), but do not share
* pseudo reg
clobbers or clobbers of hard registers that originated as pseudos.
This is needed to allow safe register renaming. */
if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < FIRST_PSEUDO_REGISTER
&& ORIGINAL_REGNO (XEXP (orig, 0)) == REGNO (XEXP (orig, 0)))
return orig;
- ORIGINAL_REGNO was uninitialized. The problem is that read_rtx_code uses
rtx_alloc, which clears only the first int in the structure (header), and
then ignores the fields with 0 format character. For ORIGINAL_REGNO, we
want to set it to REGNO, for others IMHO it is best to just clear those
fields.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
2014-01-28 Jakub Jelinek <jakub@redhat.com>
PR other/58712
* read-rtl.c (read_rtx_code): Clear all of RTX_CODE_SIZE (code).
For REGs set ORIGINAL_REGNO.
--- gcc/read-rtl.c.jj 2014-01-03 11:40:57.000000000 +0100
+++ gcc/read-rtl.c 2014-01-27 10:01:44.154527266 +0100
@@ -1131,6 +1131,7 @@ read_rtx_code (const char *code_name)
/* If we end up with an insn expression then we free this space below. */
return_rtx = rtx_alloc (code);
format_ptr = GET_RTX_FORMAT (code);
+ memset (return_rtx, 0, RTX_CODE_SIZE (code));
PUT_CODE (return_rtx, code);
if (iterator)
@@ -1154,6 +1155,8 @@ read_rtx_code (const char *code_name)
/* 0 means a field for internal use only.
Don't expect it to be present in the input. */
case '0':
+ if (code == REG)
+ ORIGINAL_REGNO (return_rtx) = REGNO (return_rtx);
break;
case 'e':
Jakub
More information about the Gcc-patches
mailing list