[llvm-bugs] [Bug 51922] New: compile-time explosion (infinite loop) at -O2 on clang trunk version

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 20 21:09:14 PDT 2021


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

            Bug ID: 51922
           Summary: compile-time explosion (infinite loop) at -O2 on clang
                    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.

I guess there are some issues in loop optimization but I am not sure what
exactly it is, so please feel free to change the title to a more appropriate
one.

$cat small.c
#include <stdint.h>
int c_0 = 0x0;
int i_2 = 0x02604788;
int c_4 = 0x60;
int us_7 = 0x0A34;
uint8_t uc_8 = 0x67;
int s_10 = 0x0;
int64_t li_14 = 0x1E342489BD39A630;
int8_t func_5() {
  uint16_t us_20 = 0x2D7F;
  if (0)
    for (us_20 = 15; us_20 <= 31; us_20 += 1)
      ;
  uc_8 = -10;
  for (; uc_8 > 100; uc_8 += 3) {
    i_2 = 5;
    do {
      s_10 = -5;
      while (s_10++) {
        li_14 = -6;
        while (li_14 < 100) {
          li_14 += 2;
          if ((0x0 != c_4)) {
            c_0 = 6;
            for (; c_0 > 2; c_0 -= 5)
              do
                do
                  do
                    return 0;
                  while (us_7 < 100);
                while (c_4 < 100);
              while (0);
          }
        }
      }
    } while (i_2--);
  }
  return 0;
}


$clang -c -O2 small.c
//endless compiling

$time clang -c -O3 small.c

real    0m0.258s
user    0m0.056s
sys     0m0.055s

$clang -v
clang version 14.0.0 (https://github.com/llvm/llvm-project
92904cc68fbc1d000387b30accc8b05b3fe95daa)
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/xoKfjYE1s

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/20210921/fe0d2d9b/attachment.html>


More information about the llvm-bugs mailing list