[llvm-bugs] [Bug 49556] New: Infinite loop at -Os

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 12 06:25:01 PST 2021


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

            Bug ID: 49556
           Summary: Infinite loop at -Os
           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.

This small and valid code, small.c, makes Clang trunk hung on at compile time
at -Os. It seems that there exists an infinite loop. Note that this issue
exists in all clang-10.0.1 upwards and clang-6.0.1 downwards versions.

$cat small.c
#include <stdint.h>
int a, b;
int16_t c;
void d() {
  uint16_t *e = 0;
  int32_t f = 0;
  uint16_t **g = &e;
  for (; b; b++) {
    int64_t *i = a;
    for (; i; i++)
      *g = &f;
  }
  {
    int16_t *g = &c;
    int16_t **j = &g;
    for (; *e;)
      ;
    *g && (**j = 0);
    for (;; *e %= c)
      ;
  }
}

$clang -v
clang version 13.0.0 (https://github.com/llvm/llvm-project
590ac0a26af4c9f63d5564be8c13b12d409a7fd9)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64



Reproduced in godbolt: https://godbolt.org/z/nfsona

Thanks,
Haoxin

-- 
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/20210312/596b0f61/attachment.html>


More information about the llvm-bugs mailing list