This is the mail archive of the
mailing list for the GCC project.
Re: ivopts vs. garbage collection
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Michael Matz <matz at suse dot de>,Ian Lance Taylor <iant at golang dot org>
- Cc: Jeff Law <law at redhat dot com>,GCC Development <gcc at gcc dot gnu dot org>,Lynn Boger <laboger at linux dot vnet dot ibm dot com>
- Date: Mon, 11 Jan 2016 21:09:09 +0100
- Subject: Re: ivopts vs. garbage collection
- Authentication-results: sourceware.org; auth=none
- References: <CAOyqgcWphMUdS7pMyo9STBChnimJEWm0Ou+wmRtFM2Z500BiJg at mail dot gmail dot com> <568D3217 dot 6050802 at redhat dot com> <CAFiYyc0L0rduOMicug53bxx3-n2DGF-_1D1bEGw4oDWo3wo4vw at mail dot gmail dot com> <alpine dot LSU dot 2 dot 20 dot 1601111840370 dot 19289 at wotan dot suse dot de> <CAKOQZ8xo5VGos0iy_2SUw9RyPFkqZ4DVO7rNfHkY1PDMpmgm1A at mail dot gmail dot com> <alpine dot LSU dot 2 dot 20 dot 1601111947340 dot 19289 at wotan dot suse dot de>
On January 11, 2016 8:35:25 PM GMT+01:00, Michael Matz <email@example.com> wrote:
>On Mon, 11 Jan 2016, Ian Lance Taylor wrote:
>> > Well, that's a hack. A solution is to design something that works
>> > generally for garbage collected languages with such requirements
>> > instead of arbitrarily limiting transformations here and there. It
>> > could be something like the notion of derived pointers, where the
>> > pointer needs to stay alive as long as the derived pointers are.
>> > potential GC points where a derived pointer is alive also needs to
>> > have the base pointer be alive (they could explicitely add uses of
>> > base pointers, or alternatively anthing computing liveness needs to
>> > deal with this). For normal transformation that don't deal with
>> > explicit liveness sets (i.e. most of our SSA transforms) it's
>> > if the instruction creating the derived pointer from the base can't
>> > looked through, i.e. is an optimization barrier.
>> What do you suggest we do for GCC 6?
>Realistically? The hack of course.
>> Your suggestion of every derived pointer keeping the base pointer
>> sounds too strong to me; it certainly sounds too strong for Go. For
>> it should be sufficient to ensure that every derived pointer points
>> within the bounds of the object.
>Okay, that's a certain type of GC. Others might need exact offset-zero
>> It's also not obvious to me that making a pointer transformation into
>> an optimization barrier would be a win overall.
>It will almost always be a pessimization (the additional live value
>at least a place on the stack).
>> For something like
>> ivopts it seems better to simply not introduce the pointer
>> transformation--to apply ivopts only to non-pointers when GC matters
>Of course that deals only with ivopts. In practice that might be
>even for a long time, but it's not really a full solution, there are
>transformations on pointers (e.g. the vectorizer fiddling with
>some of them creating out of object pointers (e.g. chopping off the
>Another problem is to define "when GC matters". With LTO you can't
>on anything from the frontend, so it needs to be encoded in the IL, or
>the very least in a per-function item, with corresponding avoidance of
>inlining of GC into non-GC aware functions.
Here you can extend the hack to apply said flag to the final link if it is in at least one LTO object. As we do for some already.
And yes, avoiding IVOPTs on pointer values is certainly the easiest fix.
>> (I'm still puzzled by the fact that Java has apparently not
>> this problem in all these years.)
>Probably it just so happened that the base pointer for some derived
>pointer was lying around in some memory location. It's not very likely
>that the only reference is in a register, it can happen only shortly
>allocating the new block, but before it's actually stored into some
>structure (or freed, i.e. when it's only temporary, but then the base
>pointer would be live as well), perhaps this pattern doesn't happen
>often in java code. Obviously it does in Go. Perhaps we can limit the
>ivopts hack also to pointers that are problematic. Only if the base
>pointer comes from a new allocation (is not loaded from memory) and
>stored into memory before use do we need to avoid manipulating it too