[llvm-bugs] [Bug 27860] New: gvn miscompile with restrict and call to exit()

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 24 13:06:27 PDT 2016


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: unassignedbugs at nondot.org
          Reporter: eli.friedman at gmail.com
                CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160524/1f541958/attachment.html>


More information about the llvm-bugs mailing list