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, x86, 63534] Fix '-p' profile for 32 bit PIC mode


On Fri, Oct 17, 2014 at 06:30:42PM +0400, Evgeny Stupachenko wrote:
> Hi,
> 
> The patch fixes profile in 32bits PIC mode (only -p option affected).
> 
> x86 bootstrap, make check passed
> 
> spec2000 o2 -p train data on Corei7:
> CINT -5%
> CFP  +1,5
> compared to a compiler before "enabling ebx".
> 
> There is a potential performance improve after the patch applied
> suggested by Jakub:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63534#c8
> There is opened bug on this: PR63527. However the fix of the bug is
> more complicated.
> 
> Is it ok?

Unfortunately I don't think it is ok.
1) you don't set the appropriate bit in pic_labels_used (for ebx)
2) more importantly, it causes the stack to be misaligned (i.e. violating
   ABI) for the _mcount call, and, break unwind info.

> 2014-10-16  Evgeny Stupachenko  <evstupac@gmail.com>
> 
>         PR target/63534
>         * config/i386/i386.c (x86_function_profiler): Add GOT register init
>         for mcount call.
> 
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index a3ca2ed..5117572 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -39119,11 +39126,15 @@ x86_function_profiler (FILE *file, int
> labelno ATTRIBUTE_UNUSED)
>      }
>    else if (flag_pic)
>      {
> +      fprintf (file,"\tpush\t%%ebx\n");
> +      fprintf (file,"\tcall\t__x86.get_pc_thunk.bx\n");
> +      fprintf (file,"\taddl\t$_GLOBAL_OFFSET_TABLE_, %%ebx\n");
>  #ifndef NO_PROFILE_COUNTERS
>        fprintf (file, "\tleal\t%sP%d@GOTOFF(%%ebx),%%"
> PROFILE_COUNT_REGISTER "\n",
>                LPREFIX, labelno);
>  #endif
>        fprintf (file, "1:\tcall\t*%s@GOT(%%ebx)\n", mcount_name);
> +      fprintf (file,"\tpop\t%%ebx\n");
>      }
>    else
>      {

	Jakub


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