This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

[Bug ipa/80728] New: IPA-reference suppresses compiler memory barrier


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80728

            Bug ID: 80728
           Summary: IPA-reference suppresses compiler memory barrier
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---

Consider:

static int i;
static int b;

void sighandler(void)
{
  b = i = 1;
}

__attribute__((noinline))
static int x(void)
{
  asm volatile("":::"memory");
  return b;
}

int f(void)
{
  i = 0;
  return x() ? i : 0;
}


This is compiled as expected with either -Dnoinline= , or with
-fno-ipa-reference, but otherwise IPA-reference suppresses the effect of
compiler memory barrier in 'x', causing 'f' to be optimized to 'return 0'.

A similar issue exists for atomic accesses (i.e. if x contained one rather than
the volatile asm).

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