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.
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)

Reply via email to