[Pixman] [PATCH] Workaround bug in llvm-gcc
Andrea Canciani
ranma42 at gmail.com
Mon Aug 22 23:43:48 PDT 2011
On Mon, Aug 22, 2011 at 3:24 PM, Soeren Sandmann <sandmann at cs.au.dk> wrote:
> Andrea Canciani <ranma42 at gmail.com> writes:
>
>> llvm-gcc (shipped in Apple XCode 4.1.1 as the default compiler or in
>> the 2.9 release of LLVM) performs an invalid optimization which
>> unifies the empty_region and the bad_region structures because they
>> have the same content.
>>
>> A bug has been filed against Apple Developers Tool for this
>> issue. This commit works around this bug by making one of the two
>> structures volatile, so that it cannot be merged.
>
> Is the bug report publicly readable?
>
>> static const box_type_t PREFIX (_empty_box_) = { 0, 0, 0, 0 };
>> static const region_data_type_t PREFIX (_empty_data_) = { 0, 0 };
>> +#if defined (__llvm__) && !defined (__clang__)
>> +static const volatile region_data_type_t PREFIX (_broken_data_) = { 0, 0 };
>> +#else
>> static const region_data_type_t PREFIX (_broken_data_) = { 0, 0 };
>> +#endif
>
> It worries me a little that these #ifdefs will still trigger when Apple
> fix their compiler.
The same issue affects non-Apple llvm-gcc, but it's deprecated and
there will be no further releases. I would not be surprised if Apple
just started using clang as the default compiler in future XCode
versions.
> Can we detect it at configure time instead by
> running something like this:
It's not that easy. Unfortunately simple code snippets like this one
compute the correct result, because the if condition gets optimized
to a constant and the blah_t structures are not emitted at all.
It is definitely possible to do it, but the code will probably be
ugly or not that obvious.
Andrea
>
> typedef struct { int x, y; } blah_t;
>
> static const blah_t b1 = { 0, 0 };
> static const blah_t b2 = { 0, 0 };
>
> int
> main ()
> {
> if (&b1 == &b2)
> return 1;
> else
> return 0;
> }
>
>
> Soren
>
More information about the Pixman
mailing list