This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

AW: basic asm and memory clobbers - Proposed solution


On 12/15/2015 13:52, Bernd Schmidt wrote:
> On 12/14/2015 09:10 AM, Segher Boessenkool wrote:
> > That, and adding a memory clobber degrades performance for a lot of
> > existing basic asm that does not expect the clobber, e.g. asm(""),
> > asm("#"), asm("nop"), ...
> I wonder about this. People keep bringing up "a lot of existing basic
> asm" in general, but are there any known examples in real software?

Yes, there are, I see a few in our own tree:

./libatomic/config/x86/fenv.c:      asm volatile ("fwait");
./libcilkrts/runtime/config/x86/os-fence.h:#   define __cilkrts_fence() __asm__ volatile ("lock addl $0,(%rsp)")
./libsanitizer/sanitizer_common/sanitizer_atomic_clang_x86.h:    __asm__ __volatile__("pause");
./libgfortran/config/fpu-387.h:      __asm__ __volatile__ ("fwait");
./libgcc/unwind-dw2.c:  asm ("");
./libgcc/config/i386/sfp-exceptions.c:      asm volatile ("fwait");
./libgcc/config/lm32/_udivsi3.c:      __asm__ __volatile__ ("mv ea, ra");
./boehm-gc/include/private/gc_locks.h:#    define GC_clear(addr) { asm("mb"); *(volatile unsigned *)addr = 0; }
!! this one really needs memory clobber !!
./boehm-gc/include/private/gc_locks.h:#  define GC_memory_barrier() asm("mb")
./boehm-gc/mach_dep.c:    asm("pushl r11");     asm("calls $1,_GC_push_one");


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]