This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix C++0x memory model for -fno-strict-volatile-bitfields on ARM


On Fri, Oct 25, 2013 at 10:40 AM, Bernd Edlinger
<bernd.edlinger@hotmail.de> wrote:
> Hello,
>
> this patch fixes the recently discovered data store race on arm-eabi-gcc with -fno-strict-volatile-bitfields
> for structures like this:
>
> #define test_type unsigned short
>
> typedef struct s{
>  unsigned char Prefix[1];
>  test_type Type;
> }__attribute((__packed__,__aligned__(4))) ss;
>
> volatile ss v;
>
> void __attribute__((noinline))
> foo (test_type u)
> {
>   v.Type = u;
> }
>
> test_type __attribute__((noinline))
> bar (void)
> {
>   return v.Type;
> }
>
>
> I've manually confirmed the correct code generation using variations of the
> example above on an ARM cross-compiler for -fno-strict-volatile-bitfields.
>
> Note, that this example is still causes ICE's for -fstrict-volatile-bitfields,
> but I'd like to fix that separately.
>
> Boot-strapped and regression-tested on x86_64-linux-gnu.
>
> Ok for trunk?

Isn't it more appropriate to fix it here:

      if (TREE_CODE (to) == COMPONENT_REF
          && DECL_BIT_FIELD_TYPE (TREE_OPERAND (to, 1)))
        get_bit_range (&bitregion_start, &bitregion_end, to, &bitpos, &offset);

?

Btw, the C++ standard doesn't cover packed or aligned attributes so
we could declare this a non-issue.  Any opinion on that?

Thanks,
Richard.

> Thanks
> Bernd.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]