diff mbox

Fix compile time warning caused by PIC_OFFSET_TABLE_REGNUM

Message ID 5421C6C1.4030308@arm.com
State New
Headers show

Commit Message

Jiong Wang Sept. 23, 2014, 7:15 p.m. UTC
PIC_OFFSET_TABLE_REGNUM is default to be INVALID_NUM, we need to make sure
it's not used as unsigned type register index, otherwise there will be array
index out of bound warning which will be treated as error.

the code in shrink-wrap.c is not guarded by this check which will cause trouble for
any target that define PIC_OFFSET_TABLE_REGNUM as INVALID_REGNUM, for example aarch64.

(sorry, my BOOT_CFLAGS was -O2 -w -fdump-rtl-pro_and_epilogue which hidden this issue...)

ok for trunk as obivious?

Thanks.

gcc/
   * shrink-wrap.c (try_shrink_wrapping): Check PIC_OFFSET_TABLE_REGNUM not be INVALID_REGNUM.

Comments

Jeff Law Sept. 23, 2014, 8:59 p.m. UTC | #1
On 09/23/14 13:15, Jiong Wang wrote:
> PIC_OFFSET_TABLE_REGNUM is default to be INVALID_NUM, we need to make sure
> it's not used as unsigned type register index, otherwise there will be
> array
> index out of bound warning which will be treated as error.
>
> the code in shrink-wrap.c is not guarded by this check which will cause
> trouble for
> any target that define PIC_OFFSET_TABLE_REGNUM as INVALID_REGNUM, for
> example aarch64.
>
> (sorry, my BOOT_CFLAGS was -O2 -w -fdump-rtl-pro_and_epilogue which
> hidden this issue...)
>
> ok for trunk as obivious?
>
> Thanks.
>
> gcc/
>    * shrink-wrap.c (try_shrink_wrapping): Check PIC_OFFSET_TABLE_REGNUM
> not be INVALID_REGNUM.
OK.
Jeff
diff mbox

Patch

diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c
index fd24135..9ae8a08 100644
--- a/gcc/shrink-wrap.c
+++ b/gcc/shrink-wrap.c
@@ -495,7 +495,7 @@  try_shrink_wrapping (edge *entry_edge, edge orig_entry_edge,
       if (frame_pointer_needed)
 	add_to_hard_reg_set (&set_up_by_prologue.set, Pmode,
 			     HARD_FRAME_POINTER_REGNUM);
-      if (pic_offset_table_rtx)
+      if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM)
 	add_to_hard_reg_set (&set_up_by_prologue.set, Pmode,
 			     PIC_OFFSET_TABLE_REGNUM);
       if (crtl->drap_reg)