- 论坛徽章:
- 1
|
Had anybody had test the 'memory' in the clobbered list? I tested it in my machine by using gcc with -O and it took no effect.
Here is my code:
#include <stdio.h>
void foo(int x)
{
__asm__ __volatile__ ("add $0x0a,%0"::"c"(x));
__asm__ __volatile__("": : :"memory");
printf("%d\n",x);
}
int main(int argc,char* argv[])
{
foo(10);
return 0;
}
It seems should output 10,but the result is 20. Gcc still use the ecx instead the variable 'x' in memory.
BTW, i thought the 'memory' in clobbered list did not invalid the cache, it just told the gcc to reload the variables when being used, quite like the 'volatile' key word in C language, other than
invalid the data in caches and registers. |
|