[llvm-bugs] [Bug 51657] New: Infinite loop at -O2 and above at compile-time on clang 12.0.x to trunk version

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 27 22:22:05 PDT 2021


            Bug ID: 51657
           Summary: Infinite loop at -O2 and above at compile-time on
                    clang 12.0.x to trunk version
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org

Hi all.

The following test program makes clang 12.0.x to trunk version hang on -O2 and

$cat small.c
#include <stdint.h>
int a,b,c;
void d(int e) {
  int8_t *f;
  int16_t g;
  int32_t i = &a;
  uint16_t *j;
  int8_t *k = &c;
  int16_t l = 246;
  uint64_t m;
  int8_t **n = &k;
  int64_t o;
  int16_t *p;
  for (; p;) {
    int64_t *q = o;
    for (*q = 5; *q; *q += 1)
      if (*k = b)
        for (*j = 3; *j; j++) {
          int8_t r;
          o = r;
    for (; p <= 2; p++)
      l = 1;
  g = m = e;
  uint64_t v;
  int32_t **u = &i;
  uint64_t t = &v;
  f = *u;
  *f = c = l;
  v = (g ?: (**u = m << **n)) == *f;
  for (; i <= 8; *f = t)
  goto s;

$clang -w -O2 -m32 small.c
//endless compiling, same as -O3 and -Os

$time clang -c -w -O1 -m32 small.c

real    0m0.059s
user    0m0.028s
sys     0m0.031s

The clang version I used:
clang version 14.0.0 (https://github.com/llvm/llvm-project
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/haoxin-data/compilers/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

Reproduced in Godbolt: https://godbolt.org/z/ndxn1cT91


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/20210828/01734ca7/attachment.html>

More information about the llvm-bugs mailing list