[llvm-dev] Default alignment for 'malloc'
Michael Kruse via llvm-dev
llvm-dev at lists.llvm.org
Mon Oct 3 05:43:03 PDT 2016
2016-10-03 13:55 GMT+02:00 Martin J. O'Riordan via llvm-dev
<llvm-dev at lists.llvm.org>:
> I am trying to implement some new alignment based optimisations in our
> target backend, and I am wondering if there a way a target can specify that
> ‘malloc’, ‘realloc’ and ‘calloc’ always return a pointer to memory that is
> aligned to a particular boundary?
malloc is guaranteed to be properly aligned for any C type. This would
be 8 bytes on most systems for double. However, I think in practice
most modern implementations return 16-byte aligned pointers. I don't
think there is a way to annotate calls malloc to have some specific
alignment from the backend, that has effect on passes before the
backend.
> Related too, is it possible to specify that the stack pointer always points
> to memory which is aligned to a particular boundary?
For eg. 16-byte alignment, declare with:
__attribute__((aligned(16)))
Michael
More information about the llvm-dev
mailing list