https://llvm.org/bugs/show_bug.cgi?id=27860

            Bug ID: 27860
           Summary: gvn miscompile with restrict and call to exit()
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: eli.fried...@gmail.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

Testcase:

#include <stdlib.h>
void f() { exit(0); }
void (*ff)() = f;
int r;
int g(int *__restrict x, int a) {
  if (a) {
    r = *x;
  }
  ff();
  return *x;
}
int (*gg)(int *__restrict, int) = g;
int main() {
  gg(0, 0);
}

Works with gcc and clang -O0, segfaults with clang -O2.

Load PRE is missing a check that the pointer is actually dereferenceable.

(Artificial testcase.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to