From: Andrew Pinski Date: Thu, 16 Jan 2020 02:07:28 +0000 (+0000) Subject: Uninitialized padding in struct _dep. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7c6056d52ef7ea43b503b11a571b316d55f392c7;p=gcc.git Uninitialized padding in struct _dep. In struct _dep, there is an implicit padding of 4bits. This bit-field padding is uninitialized when init_dep_1 is being called. This means we access uninitialized memory but never use it for anything. Adding an unused bit-field field and initializing it in init_dep_1 will improve code generation also as we initialize the whole 32bits now rather than just part of it. ChangeLog: * sched-int.h (_dep): Add unused bit-field field for the padding. * sched-deps.c (init_dep_1): Init unused field. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4196998ff69..bbb7e06c7fb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2020-01-16 Andrew Pinski + + * sched-int.h (_dep): Add unused bit-field field for the padding. + * sched-deps.c (init_dep_1): Init unused field. + 2020-01-16 Andrew Pinski * optabs.h (create_expand_operand): Initialize target field also. diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c index 9182aba5588..331af5ffdb3 100644 --- a/gcc/sched-deps.c +++ b/gcc/sched-deps.c @@ -101,6 +101,7 @@ init_dep_1 (dep_t dep, rtx_insn *pro, rtx_insn *con, enum reg_note type, ds_t ds DEP_NONREG (dep) = 0; DEP_MULTIPLE (dep) = 0; DEP_REPLACE (dep) = NULL; + dep->unused = 0; } /* Init DEP with the arguments. diff --git a/gcc/sched-int.h b/gcc/sched-int.h index 833b552a340..a847f876e65 100644 --- a/gcc/sched-int.h +++ b/gcc/sched-int.h @@ -238,6 +238,8 @@ struct _dep /* Cached cost of the dependency. Make sure to update UNKNOWN_DEP_COST when changing the size of this field. */ int cost:20; + + unsigned unused:4; }; #define UNKNOWN_DEP_COST ((int) ((unsigned int) -1 << 19))