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]

Re: [Patch] MIPS: Optimize virtual thunks for LOADGP_ABSOLUTE case.


Richard Sandiford wrote:
Richard Sandiford <richard@codesourcery.com> writes:
David Daney <ddaney@avtrex.com> writes:
In my hacking around I noticed that the mips port is emitting useless code in virtual thunks when the -mno-shared option is specified (the default for non -fPIC code in the o32 ABI).
Good catch.

2007-05-31 David Daney <ddaney@avtrex.com>

* config/mips/mips.c (mips_output_mi_thunk): Only load gp if not
LOADGP_ABSOLUTE.
OK, thanks.

Sorry, I should think more before I reply.


Is the thunkee guaranteed to be a locally-binding function?  The current
code tries to cope with non-locally-binding functions too, and the i386
port suggests that this case does indeed occur:

      if (!flag_pic || (*targetm.binds_local_p) (function))
	output_asm_insn ("jmp\t%P0", xops);

So I think you need to check:

  /* Set up the global pointer for n32 or n64 abicalls.  This is only
     necessary if mips_load_call_address involves a GOT load.  */
  if (mips_current_loadgp_style () != LOADGP_ABSOLUTE
      || !targetm.binds_local_p (function))
    mips_emit_loadgp ();

OK with that change.

Richard
After re-testing, committed this version:

2007-06-01 David Daney <ddaney@avtrex.com>

       * config/mips/mips.c (mips_output_mi_thunk): Only load gp if not
       LOADGP_ABSOLUTE and not binds_local_p.


Index: config/mips/mips.c
===================================================================
--- config/mips/mips.c	(revision 125234)
+++ config/mips/mips.c	(working copy)
@@ -7335,8 +7335,12 @@
       = REGNO (pic_offset_table_rtx)
       = TARGET_CALL_SAVED_GP ? 15 : GLOBAL_POINTER_REGNUM;
 
-  /* Set up the global pointer for n32 or n64 abicalls.  */
-  mips_emit_loadgp ();
+  /* Set up the global pointer for n32 or n64 abicalls.  If
+     LOADGP_ABSOLUTE then the thunk does not use the gp and there is
+     no need to load it.*/
+  if (mips_current_loadgp_style () != LOADGP_ABSOLUTE
+      || !targetm.binds_local_p (function))
+    mips_emit_loadgp ();
 
   /* We need two temporary registers in some cases.  */
   temp1 = gen_rtx_REG (Pmode, 2);

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