[LLVMdev] Equivalent alignment of __attribute__((__aligned__))
edwintorok at gmail.com
Mon Feb 1 11:20:14 PST 2010
On 02/01/2010 09:06 PM, Garrison Venn wrote:
> Is there a way using llvm::TargetData to determine the alignment of what would be equivalent
> to __attribute__((__aligned__))? I'm looking for something like a max alignment number for the
> target platform so that I know what the max alignment of an address returned by malloc(...) will
malloc() doesn't have anything to do with attribute(aligned).
You can request objects allocated on the stack (with attrib aligned)
with alignment greater than what malloc could give you.
AFAIK the alignment of malloc() is guaranteed be to at least the
alignment of a long double (since that is the
C type with the largest alignment requirement).
I don't know what guarantees malloc() has regarding vector types, I
guess none, it just happens to work because malloc() returns
data aligned to 16 bytes.
IIRC if you run the program under valgrind for example it would only
give you sizeof(void*) alignment.
You can find out the minimum ABI alignment for a particular type using
More information about the llvm-dev