Re: Local variables reordering and 'asm volatile("" ::: "memory");'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 8 Sep 2019, Ayrat Gaskarov wrote:

> But it would be a real pain to add asm volatile for every possible
> variable and computations that were previously (and after) done (may
> be even from callers up a stacktrace). Could we somehow avoid this?

You can move the code-that-shall-not-be-disturbed in a separate function
and limit visibility of interprocedural analysis into that function,
for example by compiling it in a separate file without LTO,
or calling it via a pointer received from an asm, e.g.:

  int (*fptr)(void);
  asm("" : "=r"(fptr) : "0"(&critical_function));
  /* The above has the effect of assigning fptr = &critical_function,
     but the compiler cannot prove the equality. In principle it could
     emit a check and optimize speculatively. */
  fptr();

Alexander



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux