[LLVMdev] global alignment
Baozeng
sploving1 at gmail.com
Tue Aug 14 07:31:08 PDT 2012
Hello all,
I found that the alignment for stack value has no limitation, but for
global value, it has a limitation.
Here is an example:
#include <stdio.h>
#include <stdlib.h>
char x[4000] __attribute__((aligned(4096)));
int
main (int argc, char ** argv) {
char y[4000] __attribute__((aligned(4096)));
printf("x is %p\n", x);
printf("y is %p\n", y);
return 0;
}
After compiled with clang, the result is:
x is 0x804b000
y is 0xbf9d8000
They are both aligned to be 4096 as we expected.
Then we change the example as the following:
char x[4000] __attribute__((aligned(8192)));
int
main (int argc, char ** argv) {
char y[4000] __attribute__((aligned(8192)));
printf("x is %p\n", x);
printf("y is %p\n", y);
return 0;
}
The result is :
x is 0x804d000
y is 0xbffd2000
We can see that the stack value y is aligned to be 8192, but the global
value x is not!
My target OS is 32-bit Linux. Anyone can explain this? or is this a bug of
clang?
--
Best Regards,
Baozeng
Ding
OSTG,NFS,ISCAS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120814/582d9da1/attachment.html>
More information about the llvm-dev
mailing list