[Bug target/51784] PIC register not correctly preserved in nested funcs / with non-local goto

iains at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Jan 15 12:06:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51784

--- Comment #32 from Iain Sandoe <iains at gcc dot gnu.org> 2012-01-15 11:16:42 UTC ---
Created attachment 26329
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26329
test code

firstly, apropos comment #22 and #23.

If you build this test case under linux (or darwin), -fpic -O0

.. you will see that the prologue of x does not save ebx.  However it is used
in y ... and to quote function.h "the exit block is reachable directly from a
nonlocal label".  So I think my comment #22 stands.

[if you build the testcase -O0 -fpic -DUSEPIC, then x uses the pic reg and all
is OK].

this could be fixed thus (but you might well have a better place/way to fix
it):


Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c    (revision 183180)
+++ gcc/config/i386/i386.c    (working copy)
@@ -8698,7 +8698,8 @@ ix86_save_reg (unsigned int regno, bool maybe_eh_r
       && (df_regs_ever_live_p (REAL_PIC_OFFSET_TABLE_REGNUM)
       || crtl->profile
       || crtl->calls_eh_return
-      || crtl->uses_const_pool))
+      || crtl->uses_const_pool
+      || cfun->has_nonlocal_label))
     return ix86_select_alt_pic_regnum () == INVALID_REGNUM;

   if (crtl->calls_eh_return && maybe_eh_return)



More information about the Gcc-bugs mailing list