[BUG ?] Compiler doesn't emit static variables with __attribute__((used))

[BUG ?] Compiler doesn't emit static variables with __attribute__((used))

While compiling the following code with any options:

static unsigned long long __attribute__((used)) x = 0xdeadbeefdeadbeefLL, y;

main () {
asm volatile ("movq x, %%mm0
"movq %%mm0, y
" : :);
printf ("%llx
", y);

I've got the following message:

/tmp/icc2Y4M2y.o: In function `main':
t.c:(.text+0x16): undefined reference to `x'

Looking through assembly code (produced with 'icc -S') shows
that 'x' just not emitted. This behaviour brokes the (claimed) compatibility with variable attributes supported by GNU C.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You should use the asm in the following way. Then icc should work fine. I've tried it.

asm ("movq %1, %%mm0
"movq %%mm0, %0" : "=ym"(y) : "ym" (x) : "%mm0");



Leave a Comment

Please sign in to add a comment. Not a member? Join today