From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-relay-2.sys.kth.se (smtp-relay-2.sys.kth.se [130.237.32.40]) by sourceware.org (Postfix) with ESMTPS id B406A3857C7B for ; Wed, 24 Nov 2021 13:38:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B406A3857C7B Received: from exdb3.ug.kth.se (exdb3.ug.kth.se [192.168.32.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp-relay-2.sys.kth.se (Postfix) with ESMTPS id 4Hzhsx1lHMzPR4V; Wed, 24 Nov 2021 14:38:29 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp-relay-2.sys.kth.se 4Hzhsx1lHMzPR4V Received: from exdb6.ug.kth.se (192.168.32.61) by exdb3.ug.kth.se (192.168.32.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Wed, 24 Nov 2021 14:38:28 +0100 Received: from exdb6.ug.kth.se ([192.168.32.61]) by exdb6.ug.kth.se ([192.168.32.61]) with mapi id 15.02.0986.014; Wed, 24 Nov 2021 14:38:28 +0100 From: Petter Tomner To: Antoni Boucher , David Malcolm , "jit@gcc.gnu.org" Subject: SV: SV: [PATCH] libgccjit: Add function to set the initial value of a global variable [PR96089] Thread-Topic: SV: [PATCH] libgccjit: Add function to set the initial value of a global variable [PR96089] Thread-Index: AQHX4A5BvSF/jycHYEaAgABQ/pvBR6wQ4v/4gAAz0oCAAZkN1w== Date: Wed, 24 Nov 2021 13:38:28 +0000 Message-ID: <1002e6401fcf49738743a8b424eb27e7@kth.se> References: <7d6762623f658712a4b802cc3d6524c106affa2b.camel@zoho.com> <62c178b5bb0ab004def3c7869da2b03846e5134c.camel@zoho.com> , , <5e2ae38f9cf3025551a8fe6952b61743f66477ca.camel@zoho.com> In-Reply-To: <5e2ae38f9cf3025551a8fe6952b61743f66477ca.camel@zoho.com> Accept-Language: sv-SE, en-US Content-Language: sv-SE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.32.250] MIME-Version: 1.0 X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: jit@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Jit mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Nov 2021 13:38:34 -0000 Ok cool I'll wrap up the patch for review. I think I will redo the entrypoi= nt like you did with separate entrypoints for union, struct and array. It seems less contrived t= han cramming it all into one entrypoint. Regards, Petter ________________________________ Fr=E5n: Antoni Boucher Skickat: den 23 november 2021 15:10 Till: Petter Tomner; David Malcolm; jit@gcc.gnu.org =C4mne: Re: SV: [PATCH] libgccjit: Add function to set the initial value of= a global variable [PR96089] Le mardi 23 novembre 2021 =E0 10:51 +0000, Petter Tomner a =E9crit : > 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. Since I don't provide a constructor for unions, it doesn't work for them. I believe it works for an address of a global variable, but I can't remember. > > I did a similar patch that I just dropped in a RFC mail some time ago. > (See attachment). That looks indeed much more complete than my patch. I'm gonna try your patch for rustc_codegen_gcc when I'm back from vacation in December and tell you if it works or if it misses something. David, could you please take a look at Petter's patch? > > 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=E5n: Gcc-patches f= =F6r > Antoni Boucher via Gcc-patches > Skickat: den 23 november 2021 03:01 > Till: David Malcolm > Kopia: jit@gcc.gnu.org; gcc-patches@gcc.gnu.org > =C4mne: 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 =E0 16:44 -0400, Antoni Boucher a =E9crit : > > David: this one wasn't reviewed yet by you, so you can review it. > > > > Le jeudi 20 mai 2021 =E0 21:27 -0400, Antoni Boucher a =E9crit : > > > 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=3D100380), 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. > > > >