This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/51784] PIC register not correctly preserved in nested funcs / with non-local goto
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 14 Jan 2012 11:03:26 +0000
- Subject: [Bug target/51784] PIC register not correctly preserved in nested funcs / with non-local goto
- Auto-submitted: auto-generated
- References: <bug-51784-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51784
--- Comment #23 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-01-14 11:03:26 UTC ---
How would that help? With nonlocal goto, you need to recompute the PIC
register (if different from the function doing nonlocal goto) in the nonlocal
goto receiver.
Consider:
extern void baz (void (*) (void));
volatile int z, z1;
static volatile int z2, z3;
int
foo (void)
{
__label__ l;
void bar ()
{
goto l;
}
baz (bar);
return z1 + z3;
l:
return z + z2;
}
If you attempt to restore the PIC register in bar before doing the jump,
you'd restore it to baz PIC register rather than foo PIC register.
md.texi clearly hints it:
@cindex @code{nonlocal_goto_receiver} instruction pattern
@item @samp{nonlocal_goto_receiver}
This pattern, if defined, contains code needed at the target of a
nonlocal goto after the code already generated by GCC@. You will not
normally need to define this pattern. A typical reason why you might
need this pattern is if some value, such as a pointer to a global table,
must be restored when the frame pointer is restored. Note that a nonlocal
goto only occurs within a unit-of-translation, so a global table pointer
that is shared by all functions of a given module need not be restored.
There are no arguments.
darwin clearly doesn't have a PIC pointer shared by all functions of a given
module, therefore it needs to be restored.