On Thu, Dec 17, 2020 at 08:25:12AM -0500, Nathan Sidwell wrote:
> > Yeah.  If it is meant as an optimization barrier, shouldn't it be just
> >    __asm__ volatile ("");
> > or
> >    __asm__ volatile ("" : : : "memory");
> > ?  That said, shouldn't that be guarded on the compiler being GCC
> > (or some other that supports inline asm)?  Not all compilers have to support
> > that.
> 
> I can just take it out -- the reason it is there is so when you set a
> breapoint on HCF (via a .gdbinit), gdb will land you at one of those two
> lines, which is a great way of telling you where you are.

So perhaps use something more portable, like:
  volatile int v = 0; v++;
on which GDB should also put the breakpoint.
The problem with nops is that not all targets have a simple nop instruction,
as can be seen in gcc/testsuite/gcc.dg/nop.h:
#if defined (__ia64__) || defined (__s390__) || defined (__s390x__)
#define NOP "nop 0"
#elif defined (__MMIX__)
#define NOP "swym 0"
#elif defined (__or1k__)
#define NOP "l.nop"
#else
#define NOP "nop"
#endif
But another one is that non-GCC system compilers might not handle the inline asm
at all.

        Jakub

Reply via email to