This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH i386] fix x86_64 bootstrap failure


Hi, 

I've been told that my checkin to enable -Warray-bounds for -Wall causes 
a -Werror bootstrap failure on x86_64 due to a warning triggred in 
regclass.c. The issue is that PIC_OFFSET_TABLE_REGNUM, as defined in 
config/i386/i386.h can return INVALID_REGNUM when not in pic mode, and 
although surrounding code is testing for INVALID_REGNUM, the optimizing 
passes can not simplify the code and detect the case of INVALID_REGNUM is 
dead code. This seems to be due to the complexity of the conditional. trying 
to reduce the test in any way makes the failure disappear. 

As a quick fix I would either suggest to disable -Warray-bounds from -Wall 
again or to install the patch below. It splits the condition from the actual 
access, simplifies the code and thereby avoids the warning. I've checked 
other targets and none of them have such a complicated test for PIC mode like 
i386.h has, so this problem should be unique. I'm apoligizing for the glitch. 
I'm now testing ppc, ppc64, ia64 and s390x as well to make sure they 
bootstrap. 

patch below bootstraps with -Werror on i686 and x86_64. Regtest is in 
progress. 


2007-01-19  Dirk Mueller  <dmueller@suse.de>
	
	* config/i386/i386.h (PIC_OFFSET_TABLE_REGNUM ): split into
	HAS_VALID_PIC_OFFSET_TABLE_REGNUM and
	GET_PIC_OFFSET_TABLE_REGNUM. 
	(CONDITIONAL_REGISTER_USAGE): Use 
	HAS_VALID_PIC_OFFSET_TABLE_REGNUM and 
	GET_PIC_OFFSET_TABLE_REGNUM. 

--- config/i386/i386.h	(revision 120904)
+++ config/i386/i386.h	(working copy)
@@ -862,10 +862,10 @@ do {									\
 	  call_used_regs[i] = (call_used_regs[i]			\
 			       == (TARGET_64BIT ? 3 : 2));		\
       }									\
-    if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM)			\
+    if (HAS_VALID_PIC_OFFSET_TABLE_REGNUM)				\
       {									\
-	fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1;			\
-	call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1;			\
+	fixed_regs[GET_PIC_OFFSET_TABLE_REGNUM] = 1;			\
+	call_used_regs[GET_PIC_OFFSET_TABLE_REGNUM] = 1;			\
       }									\
     if (! TARGET_MMX)							\
       {									\
@@ -1062,12 +1062,20 @@ do {									\
 
 #define REAL_PIC_OFFSET_TABLE_REGNUM  3
 
-#define PIC_OFFSET_TABLE_REGNUM				\
-  ((TARGET_64BIT && ix86_cmodel == CM_SMALL_PIC)	\
-   || !flag_pic ? INVALID_REGNUM			\
-   : reload_completed ? REGNO (pic_offset_table_rtx)	\
+/* true if PIC_OFFSET_TABLE_REGNUM is != INVALID_REGNUM.  */
+#define HAS_VALID_PIC_OFFSET_TABLE_REGNUM \
+  (!((TARGET_64BIT && ix86_cmodel == CM_SMALL_PIC) || !flag_pic))
+
+/* access PIC_OFFSET_TABLE_REGNUM directly. Do not use
+   if HAS_VALID_PIC_OFFSET_TABLE_REGNUM could be false.  */
+#define GET_PIC_OFFSET_TABLE_REGNUM \
+   (reload_completed ? REGNO (pic_offset_table_rtx)	\
    : REAL_PIC_OFFSET_TABLE_REGNUM)
 
+#define PIC_OFFSET_TABLE_REGNUM				\
+  (!HAS_VALID_PIC_OFFSET_TABLE_REGNUM ? INVALID_REGNUM	\
+   : GET_PIC_OFFSET_TABLE_REGNUM)
+
 #define GOT_SYMBOL_NAME "_GLOBAL_OFFSET_TABLE_"
 
 /* A C expression which can inhibit the returning of certain function




Dirk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]