[llvm-bugs] [Bug 40950] New: opt cannot terminate with "opt -loop-rotate -loop-extract"

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 4 03:28:27 PST 2019


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

            Bug ID: 40950
           Summary: opt cannot terminate with "opt -loop-rotate
                    -loop-extract"
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: cszide at 163.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 21559
  --> https://bugs.llvm.org/attachment.cgi?id=21559&action=edit
.bc file of the source code

For this test case, opt cannot terminate. I have tested it using godbolt, and
the opt 6/7/truck versions all have this problem. The outputs of opt 6/7/truck
are as follows.

opt truck:
compiler-explorer/c-preload/compiler-wrapper: line 21: 27482 Killed            
     "$@"

Compiler returned: 137

opt 7:
compiler-explorer/c-preload/compiler-wrapper: line 21: 32256 Killed            
     "$@"

Compiler returned: 137

opt 6:
LLVM ERROR: out of memory

/compiler-explorer/c-preload/compiler-wrapper: line 21: 30493 Killed           
      "$@"

Compiler returned: 137

The followings are my test environment and test steps.

$clang -v
clang version 9.0.0 (trunk 355281)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

$clang -O3 -c -emit-llvm  -mllvm -disable-llvm-optzns small.c -o small.bc

$opt -loop-rotate -loop-extract -o small-opt.bc

In this step, opt will consume all RAM for a computer with 16GB RAM and not
terminate.

The followings are the source code of small.c and IR 

int a;
c(d) {
  for (; a;)
    if (d)
      break;
}
------------------------------
; ModuleID = 'small.bc'
source_filename = "small.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@a = common dso_local global i32 0, align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @c(i32) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 %0, i32* %3, align 4, !tbaa !2
  br label %4

; <label>:4:                                      ; preds = %11, %1
  %5 = load i32, i32* @a, align 4, !tbaa !2
  %6 = icmp ne i32 %5, 0
  br i1 %6, label %7, label %12

; <label>:7:                                      ; preds = %4
  %8 = load i32, i32* %3, align 4, !tbaa !2
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %11

; <label>:10:                                     ; preds = %7
  br label %12

; <label>:11:                                     ; preds = %7
  br label %4

; <label>:12:                                     ; preds = %10, %4
  %13 = load i32, i32* %2, align 4
  ret i32 %13
}

attributes #0 = { nounwind uwtable
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false"
"less-precise-fpmad"="false" "min-legal-vector-width"="0"
"no-frame-pointer-elim"="false" "no-infs-fp-math"="false"
"no-jump-tables"="false" "no-nans-fp-math"="false"
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64"
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false"
"use-soft-float"="false" }

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 9.0.0 (trunk 355281)"}
!2 = !{!3, !3, i64 0}
!3 = !{!"int", !4, i64 0}
!4 = !{!"omnipotent char", !5, i64 0}
!5 = !{!"Simple C/C++ TBAA"}

-- 
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/20190304/65b8fbbc/attachment.html>


More information about the llvm-bugs mailing list