[PATCH] Fix PR bootstrap/11297

Jakub Jelinek jakub@redhat.com
Fri Jun 27 21:31:00 GMT 2003


On Fri, Jun 27, 2003 at 10:16:09AM -0700, Janis Johnson wrote:
> On Fri, Jun 27, 2003 at 11:32:46AM -0400, David Edelsohn wrote:
> > >>>>> Jakub Jelinek writes:
> > 
> > Jakub> No idea why is current rs6000_output_mi_thunk clearing SYMBOL_FLAG_LOCAL.
> > Jakub> Certainly the code before 2003-01-08 rewrite used to emit b .LTHUNK0@local
> > Jakub> if function binds locally, now it does not.
> > 
> > 	This was a change to my original logic made by Alan Modra.  I'd
> > like to hear his opinion.
> 
> Before a change I made on 2003-04-30 to use the new SYMBOL_REF_FLAGS
> the code looked like this:
> 
>   funexp = XEXP (DECL_RTL (function), 0);
>   SYMBOL_REF_FLAG (funexp) = 0;
>   if (current_file_function_operand (funexp, VOIDmode)
>       && (! lookup_attribute ("longcall",
>                               TYPE_ATTRIBUTES (TREE_TYPE (function)))
>           || lookup_attribute ("shortcall",
>                                TYPE_ATTRIBUTES (TREE_TYPE (function)))))
>     SYMBOL_REF_FLAG (funexp) = 1;

gcc-3.3 does:

  fname = XSTR (XEXP (DECL_RTL (function), 0), 0);

  if (current_file_function_operand (XEXP (DECL_RTL (function), 0), VOIDmode)
      && (! lookup_attribute ("longcall",
                              TYPE_ATTRIBUTES (TREE_TYPE (function)))
          || lookup_attribute ("shortcall",
                               TYPE_ATTRIBUTES (TREE_TYPE (function)))))
    {
      fprintf (file, "\tb %s", prefix);
      assemble_name (file, fname);
      if (DEFAULT_ABI == ABI_V4 && flag_pic) fputs ("@local", file);
      putc ('\n', file);
    }

  else

    big_block_emitting_call_through_plt

so it looks to me like this was a bug introduced in the January rewrite
where it was supposed to be instead
SYMBOL_REF_FLAG (funexp) = (current_file_function_operand (funexp, VOIDmode) && (!la || la));

With my patch, the following thunks are generated:
{-m64 -fno-pic,-m64 -fpic,-m64 -fPIC}
        ld 12,0(3)
        ld 12,-24(12)
        add 3,3,12
        b ..LTHUNK0
	.long 0
-m32 -fno-pic
        lwz 12,0(3)
        lwz 12,-12(12)
        add 3,3,12
        b .LTHUNK0
{-m32 -fpic,-m32 -fPIC}
        lwz 12,0(3)
        lwz 12,-12(12)
        add 3,3,12
        b .LTHUNK0@local
Now if I back out part of my method.c change, such that alias = function;
instead of alias = make_alias_for_thunk (function), I get:
{-m64 -fno-pic,-m64 -fpic,-m64 -fPIC}
        ld 12,0(3)
        ld 12,-24(12)
        add 3,3,12
        b ._ZN1CD1Ev
	.long 0
-m32 -fno-pic
        lwz 12,0(3)
        lwz 12,-12(12)
        add 3,3,12
        b _ZN1CD1Ev
{-m32 -fpic,-m32 -fPIC}
        lwz 12,0(3)
        lwz 12,-12(12)
        add 3,3,12
        b _ZN1CD1Ev@plt

To me the first 3 sequences (ie. what would gcc generate with my patch
actually) look ok and 32-bit non-local sequences as well.
I'm not sure about 64-bit non-local sequence, as it does not have a nop
after the branch, but current gcc before my method.c patch (and before
my rs6000.c patch) generates similar sequence:
        ld 12,0(3)
        addi 12,12,-24
        ld 12,0(12)
        add 3,3,12
        b ._ZN1CD1Ev
	.long 0

	Jakub



More information about the Gcc-patches mailing list