Hi!

On Mon, Jun 03, 2024 at 04:55:05PM +0200, Jakub Jelinek wrote:
> PCH doesn't work properly in --enable-host-pie configurations on
> powerpc*-linux*.

PCH and PIE, two of my favourites ;-)

> For PCH though it actually results in saving those huge arrays (one is
> 130832 bytes, another 81568 bytes) into the .gch files and loading them back
> in full.  While the bifname and attr_string and next pointers are marked as
> GTY((skip)), they are actually saved to point to the .rodata and .data
> sections of the process which writes the PCH, but because cc1/cc1plus etc.
> are position independent executables with --enable-host-pie, when it is
> loaded from the PCH file, it can point in a completely different addresses
> where nothing is mapped at all or some random different thing appears at.

Yuck.

> So, either we'd need to add some further GTY extensions, or the following
> patch instead reworks it such that the fntype members which were the only
> reason for PCH in those arrays are moved to separate arrays.

And that just sidesteps the limitation in PCH?

>  void
>  rs6000_init_generated_builtins ()
>  {
> +  bifdata *rs6000_builtin_info_p;
> +  tree *rs6000_builtin_info_fntype_p;
> +  ovlddata *rs6000_instance_info_p;
> +  tree *rs6000_instance_info_fntype_p;
> +  ovldrecord *rs6000_overload_info_p;
> +  __asm ("" : "=r" (rs6000_builtin_info_p) : "0" (rs6000_builtin_info));

Bah.

It should not be called _p of course, it is not a predicate.  And
relying on the operand tie to not have to do a much more obvious
assignment, please don't.  Just *do* write assignments, and then use
a simple "+r"?

But you call this a hack anyway, you wouldn't propose to actually
include this patch :-)

> Bootstrapped/regtested on powerpc64le-linux and powerpc64-linux (-m32/-m64
> testing there), ok for trunk and after a while for release branches?

Yes please.  What nastiness.  Thanks for dealing with it!


Segher


> 2024-06-03  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR target/115324
>       * config/rs6000/rs6000-gen-builtins.cc (write_decls): Remove
>       GTY markup from struct bifdata and struct ovlddata and remove their
>       fntype members.  Change next member in struct ovlddata and
>       first_instance member of struct ovldrecord to have int type rather
>       than struct ovlddata *.  Remove GTY markup from rs6000_builtin_info
>       and rs6000_instance_info arrays, declare new
>       rs6000_builtin_info_fntype and rs6000_instance_info_fntype arrays,
>       which have GTY markup.
>       (write_bif_static_init): Adjust for the above changes.
>       (write_ovld_static_init): Likewise.
>       (write_init_bif_table): Likewise.
>       (write_init_ovld_table): Likewise.
>       * config/rs6000/rs6000-builtin.cc (rs6000_init_builtins): Likewise.
>       * config/rs6000/rs6000-c.cc (find_instance): Likewise.  Make static.
>       (altivec_resolve_overloaded_builtin): Adjust for the above changes.

Reply via email to