[PATCH] Introduce __BIGGEST_ALIGNMENT__ macro
mats petersson
mats at planetcatfish.com
Sat Dec 13 14:56:34 PST 2014
Ok, so how do you know WHAT to use as '__alignof__' in the C code that
allocates memory for a void* with a size_t? Because that is, typically, the
stuff that happens in APIs of the type that I expect this to be useful in.
(And yes, if we add a `align` value to the allocator, then that's fixing
the problem, but I don't see that happening right now).
I appreciate that maybe I've misunderstood the whole concept, and this is
useless. In which case, i'd appreciate a suggestion on how to MAKE it
useful.
And by the way, if you were to make, say something like this:
if (opts.noSSE2) SuitableAlignment = 64;
in Targets.cpp, as long as that is done before the preprocessor is
initialized (and from my understanding, it does), then my change will work
just fine [Well, subject to compiling ALL of the code with the same
settings].
I'm probably missing some big thing that I'm not at all understanding... I
can be a bit simple in how I see things at times...
--
Mats
On 13 December 2014 at 22:26, Jonathan Roelofs <jonathan at codesourcery.com>
wrote:
>
>
> On 12/13/14 2:32 PM, Joerg Sonnenberger wrote:
>
>> On Sat, Dec 13, 2014 at 09:15:53PM +0000, mats petersson wrote:
>>
>>> So, what kind of documentation would you like to see?
>>>
>>> The GCC docs here:
>>> https://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html
>>>
>>> say: GCC also provides a target specific macro __BIGGEST_ALIGNMENT__,
>>> which
>>> is the largest alignment ever used for any data type on the target
>>> machine
>>> you are compiling for.
>>>
>>
>> How does that interact with codegen flags like -mno-sse2? What about
>> support for new target types in later version -- from the writing it is
>> nowhere clear that this macro is not fixed.
>>
> The gcc page on it says that it *can* change with codegen flags, and I
> agree, it says nothing about when it will change, nor how flags affect it.
>
> Given that, my feeling is that Mats' intent on use of this macro is wrong.
> __BIGGEST_ALIGNMENT__ should be used in the same way that the int*_fast_t
> types are: where you don't care about the actual alignment, but you just
> want an alignment that is 'fast' on the platform.
>
>
> "we discussed some code that had accidentally aligned it's sub-allocated
> block to 4 bytes for a 64-bit type, and got a unaligned access trap."
>
> For that, you should probably be using __alignof__.
>
>
> Jon
>
>
>> Joerg
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>>
> --
> Jon Roelofs
> jonathan at codesourcery.com
> CodeSourcery / Mentor Embedded
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141213/13003fa8/attachment.html>
More information about the cfe-commits
mailing list