This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++0x] contiguous bitfields race implementation
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Aldy Hernandez <aldyh at redhat dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 2 Sep 2011 16:38:00 +0200
- Subject: Re: [C++0x] contiguous bitfields race implementation
- References: <4DC8155A.3040401@redhat.com> <4E2E0264.30909@redhat.com> <4E2EED10.5030901@redhat.com> <4E2EF1E7.4020606@redhat.com> <4E2EFA1C.10803@redhat.com> <4E2EFB89.7060503@redhat.com> <CAFiYyc2Li+KXHKsG268UvPWJE-s+wVNuC7A5GsT8f5dTV9Gzsw@mail.gmail.com> <CAFiYyc0TnEwvrUG2oofTp1NNBfxVuKPze7W1FOni6XybbY0D8g@mail.gmail.com> <CAFiYyc1Z95E8gsyvrR=EsHXo30Qyz3dN1DmS+os1ROzwTcPC3Q@mail.gmail.com> <CAFiYyc0+mTBfXtDdNaYGExHwk3CBDK63jhehwEtMcMh+mtGbUg@mail.gmail.com> <4E3C2773.30502@redhat.com> <CAFiYyc0hYNQ+uCc_4VUTvME9FjVYWD=6fipWb7r46DjtA60vYg@mail.gmail.com> <4E417EE4.9040501@redhat.com> <CAFiYyc3Dsj_-JKby=u1rEdKewXtqP3qc6b7iyGEAhc1GFW=1LQ@mail.gmail.com> <4E495D11.5000306@redhat.com> <4E57EBDC.9090900@redhat.com> <CAFiYyc16y44Y+-ivxD-1dzL3Yxuf8fLHqkpkj7C55kkd6qGUsg@mail.gmail.com> <4E5F9C3E.1050405@redhat.com> <4E5F9E37.6010608@redhat.com> <4E5FA04E.3020206@redhat.com> <4E5FA28F.9090306@redhat.com> <CAFiYyc3mX+EFPmsUtNDp5ckZd0HL-XUr-Bx-b6+uQG=X827Qsw@mail.gmail.com> <4E60E3C6.7000203@redhat.com>
On Fri, Sep 2, 2011 at 4:10 PM, Jason Merrill <jason@redhat.com> wrote:
> On 09/02/2011 04:53 AM, Richard Guenther wrote:
>>
>> On Thu, Sep 1, 2011 at 5:19 PM, Jason Merrill<jason@redhat.com> ?wrote:
>>>
>>> I think it would make sense to expose this information to the back end
>>> somehow. ?A hook would do the trick: call it type_data_size or
>>> type_min_size
>>> or some such, which in the C++ front end would return TYPE_SIZE
>>> (CLASSTYPE_AS_BASE (t)) for classes or just TYPE_SIZE for other types.
>>
>> That's too late to work with LTO, you'd need to store that information
>> permanently somewhere.
>
> OK.
>
>> Maybe move this whole C++ specific bitfield handling where it belongs,
>> namely to the C++ frontend?
>
> I don't think that is the way to go; C is adopting the same memory model,
> and this is the only sane thing to do with bit-fields.
>
>> I suggest to always not re-use tail padding for now (I believe if your
>> parent object is a COMPONENT_REF, thus, x.parent.bitfield,
>> you can use the TYPE_SIZE vs. field-decl DECL_SIZE discrepancy
>> to decide about whether the tail-padding was reused, but please
>> double-check that ;)))
>
> But you don't always have a COMPONENT_REF; you still need to avoid touching
> the tail padding when you just have a pointer to the type because it might
> be a base sub-object.
>
> I wonder what would break if C++ just set TYPE_SIZE to the as-base size?
Good question. Probably argument passing, as the as-base size wouldn't
get a proper mode assigned form layout_type then(?) for small structs?
Maybe worth a try ...
Richard.
> Jason
>