diff mbox

[i386] Never fix register for PIC when pseudo PIC reg is used

Message ID 20150128151230.GA58846@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich Jan. 28, 2015, 3:12 p.m. UTC
Hi,

Currently ix86_conditional_register_usage code may mark EBX as a fixed register if it is called when pic_offset_table_rtx is NULL even if we are going to use pseudo PIC register.  It already caused some problem in combination with another issue (PR jit/64722).  This patch will probably help to avoid problems in the future.

BTW if we don't want to support possibility to switch to the fixed PIC register in i386 target then this code may be removed at all.

Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?

Thanks,
Ilya
--
2015-01-28  Ilya Enkovich  <ilya.enkovich@intel.com>

	* config/i386/i386.c (ix86_conditional_register_usage): Never fix
	PIC register if we are going to use a pseudo one.
	(ix86_use_pseudo_pic_reg): Move up.
diff mbox

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index d10d3ff..27316a0 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -4378,6 +4378,19 @@  ix86_offload_options (void)
   return xstrdup ("-foffload-abi=ilp32");
 }
 
+/* Return 1 if pseudo register should be created and used to hold
+   GOT address for PIC code.  */
+static bool
+ix86_use_pseudo_pic_reg (void)
+{
+  if ((TARGET_64BIT
+       && (ix86_cmodel == CM_SMALL_PIC
+	   || TARGET_PECOFF))
+      || !flag_pic)
+    return false;
+  return true;
+}
+
 /* Update register usage after having seen the compiler flags.  */
 
 static void
@@ -4388,7 +4401,7 @@  ix86_conditional_register_usage (void)
 
   /* The PIC register, if it exists, is fixed.  */
   j = PIC_OFFSET_TABLE_REGNUM;
-  if (j != INVALID_REGNUM)
+  if (j != INVALID_REGNUM && !ix86_use_pseudo_pic_reg ())
     fixed_regs[j] = call_used_regs[j] = 1;
 
   /* For 32-bit targets, squash the REX registers.  */
@@ -6254,19 +6267,6 @@  ix86_maybe_switch_abi (void)
     reinit_regs ();
 }
 
-/* Return 1 if pseudo register should be created and used to hold
-   GOT address for PIC code.  */
-static bool
-ix86_use_pseudo_pic_reg (void)
-{
-  if ((TARGET_64BIT
-       && (ix86_cmodel == CM_SMALL_PIC
-	   || TARGET_PECOFF))
-      || !flag_pic)
-    return false;
-  return true;
-}
-
 /* Initialize large model PIC register.  */
 
 static void