SV: [PATCH] libgccjit: Add function to set the initial value of a global variable [PR96089]

Petter Tomner tomner@kth.se
Tue Nov 23 10:51:01 GMT 2021


Hi!

Does it work with pointers to other symbols and unions? I don't think constant symbols end
up in the .rdata section unless they are marked for that.

I did a similar patch that I just dropped in a RFC mail some time ago. (See attachment).

If I remember correctly there need to be alot of folding to not segfault deeper into gcc on
expressions that are not one literal, for e.g. pointer arithmetic.

Regards,
Petter 


Från: Gcc-patches <gcc-patches-bounces+tomner=kth.se@gcc.gnu.org> för Antoni Boucher via Gcc-patches <gcc-patches@gcc.gnu.org>
Skickat: den 23 november 2021 03:01
Till: David Malcolm
Kopia: jit@gcc.gnu.org; gcc-patches@gcc.gnu.org
Ämne: Re: [PATCH] libgccjit: Add function to set the initial value of a global variable [PR96089]
    
Hi David!

I updated the patch to allow initializing global variables with values
of type array or struct.

I also fixed the bug I was talking in my previous message by using the
following workaround: I create a new memento for the action of setting
the global variable initial value and as such, both the global variable
and the initial value are bound to exist when setting the global
variable initializer.
Is that workaround good enough?
(I guess that workaround could be used to fix the same issue that we
have for inline assembly.)

Thanks for the review!

Le vendredi 11 juin 2021 à 16:44 -0400, Antoni Boucher a écrit :
> David: this one wasn't reviewed yet by you, so you can review it.
> 
> Le jeudi 20 mai 2021 à 21:27 -0400, Antoni Boucher a écrit :
> > Hi.
> > 
> > I made this patch to set an arbitrary value to a global variable.
> > 
> > This patch suffers from the same issue as inline assembly
> > (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100380), i.e. it
> > segfaults if the `rvalue` is created after the global variable.
> > It seems to be a design issue so I'm not sure what would be the fix
> > for
> > it and having it fixed would allow me to test this new function
> > much
> > more and see if things are missing (i.e. it might require a way to
> > create a constant struct).
> > See the link above for an explanation of this issue.
> > 
> > Thanks for the review.
> 

    
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Add-suport-for-global-rvalue-initialization-and-ctor.patch
Type: text/x-patch
Size: 125148 bytes
Desc: 0003-Add-suport-for-global-rvalue-initialization-and-ctor.patch
URL: <https://gcc.gnu.org/pipermail/jit/attachments/20211123/5752fece/attachment-0001.bin>


More information about the Jit mailing list