llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

opt cannot terminate with "opt -loop-rotate -loop-extract"

Open coffezhou opened this issue 7 years ago • 1 comments

Bugzilla Link 40950
Resolution DUPLICATE
Resolved on Apr 24, 2020 11:02
Version trunk
OS Linux
Attachments .bc file of the source code
CC @ekatz

Extended Description

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

;

;

;

;

;

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"}

coffezhou avatar Mar 04 '19 11:03 coffezhou

*** This bug has been marked as a duplicate of bug llvm/llvm-project#3454 ***

ekatz avatar Apr 24 '20 18:04 ekatz