[llvm-bugs] [Bug 27859] New: loop-idiom miscompile with restrict and unwinding

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 24 12:44:44 PDT 2016


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

            Bug ID: 27859
           Summary: loop-idiom miscompile with restrict and unwinding
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: eli.friedman at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Testcase:

#include <cstdlib>
void f() { throw 1; }
void (*ff)() = f;
void g(char* __restrict base, unsigned size) {
  for (unsigned i = 0; i < size; ++i) {
    ff();
    base[i] = 0;
  }
}
void (*gg)(char*__restrict,unsigned) = g;
int main() {
  char a[8] = {1};
  try {
    gg(a, 8);
  } catch (...) {
    if (a[0] != 1) abort();
  }
}

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

There's a missing safety check in LoopIdiomRecognize.

(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/561158ba/attachment.html>


More information about the llvm-bugs mailing list