[llvm-bugs] [Bug 38670] New: miscompilation: segfault with -O2

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 22 07:06:13 PDT 2018


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

            Bug ID: 38670
           Summary: miscompilation: segfault with -O2
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ohh.epicfail at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Using clang version 8.0.0 (trunk 340324) the following program crashes with
segfault with -O2. It looks like incorrect vectorization in asm. The problem
causes hand-made loop 'peeling' in example3 function. Also, clang 6.0.0 compile
this code incorrectly

#define N 1024
#define ALIGNED16 __attribute__((aligned(16)))
int ia[N] ALIGNED16;
int ib[N] ALIGNED16;

void init_memory(void *start, void *end) {
  unsigned char state = 1;
  while (start != end) {
    state *= 7;
    state ^= 0x27;
    state += 1;
    *((unsigned char *)start) = state;
    start = ((char *)start) + 1;
  }
}

typedef int aint __attribute__((__aligned__(16)));
__attribute__((noinline)) void example3(int n, aint *__restrict__ p,
                                        aint *__restrict q) {

  n--;
  *p++ = *q++;
  while (n--) {
    *p++ = *q++;
  }
}

int main() {
  init_memory(&ia[0], &ia[N]);
  init_memory(&ib[0], &ib[N]);

  example3(N, ia, ib);

  return 0;
}

-- 
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/20180822/ed5ed2d0/attachment.html>


More information about the llvm-bugs mailing list