We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
on amd64 with SSE enabled, if it doesnt crash for you try to make the "Test1" string longer (ie. "Test12" etc.):
pes ~$ cat llvm-align.c #if 0
peter@daintree[10:28AM]-1051> cc -O1 -o bar bar.c peter@daintree[10:28AM]-1052> ./bar Test1 foo1bar2foo3bar
peter@daintree[10:28AM]-1053> cc -O2 -o bar bar.c peter@daintree[10:28AM]-1054> ./bar Test1 foo1bar2foo3bar zsh: bus error (core dumped) ./bar
If you look at assembler output, with -O1, the constant string appears twice. One has .align 16 constraint, due to SSE use, the other does not.
With -O2, both strings are merged, and the alignment constraint is lost. #endif
int foo(int a) { char id[] = "foo1bar2foo3bar"; id[0] += a; for (a = 0; id[a] != 0; a++) ; return a; }
int main(void) { printf("Test1 %s\n", "foo1bar2foo3bar"); return foo(1); return 0; }
The text was updated successfully, but these errors were encountered:
the "cc" here is clang:
pes ~$ clang -v clang version 3.0 (trunk 136211) Target: x86_64-unknown-freebsd8.2 Thread model: posix
Sorry, something went wrong.
With -O1 the assembler output is: ... foo: # @foo movaps foo.id(%rip), %xmm0 ... .section .rodata.str1.16,"aMS",@progbits,1 .align 16 foo.id: .asciz "foo1bar2foo3bar" .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Test %s\n" .L.str1: .asciz "foo1bar2foo3bar"
With -O2: ... foo: # @foo movaps .L.str1(%rip), %xmm0 ... .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Test %s\n" .L.str1: .asciz "foo1bar2foo3bar"
Note missing ".align 16". Luck will determine if it is aligned for the SSE data copy.
Fixed in r136250.
No branches or pull requests
Extended Description
on amd64 with SSE enabled, if it doesnt crash for you try to make the "Test1"
string longer (ie. "Test12" etc.):
pes ~$ cat llvm-align.c
#if 0
peter@daintree[10:28AM]
-1051> cc -O1 -o bar bar.c-1052> ./barpeter@daintree[10:28AM]
Test1 foo1bar2foo3bar
peter@daintree[10:28AM]
-1053> cc -O2 -o bar bar.c-1054> ./barpeter@daintree[10:28AM]
Test1 foo1bar2foo3bar
zsh: bus error (core dumped) ./bar
If you look at assembler output, with -O1, the constant string appears
twice. One has .align 16 constraint, due to SSE use, the other does not.
With -O2, both strings are merged, and the alignment constraint is lost.
#endif
int foo(int a)
{
char id[] = "foo1bar2foo3bar";
id[0] += a;
for (a = 0; id[a] != 0; a++)
;
return a;
}
int main(void)
{
printf("Test1 %s\n", "foo1bar2foo3bar");
return foo(1);
return 0;
}
The text was updated successfully, but these errors were encountered: