llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.81k stars 11.45k forks source link

LLVM ERROR: Broken module found, compilation aborted! #90780

Closed TatyanaDoubts closed 4 months ago

TatyanaDoubts commented 4 months ago

To reproduce run the following test with -passes slp-vectorizer -slp-threshold=-99999

; ModuleID = './reduced.ll'
source_filename = "./reduced.ll"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
target triple = "x86_64-unknown-linux-gnu"

define double @wombat() #0 gc "statepoint-example" {
bb:
  br i1 false, label %bb1, label %bb2

bb1:                                              ; preds = %bb
  br i1 false, label %bb14, label %bb11

bb2:                                              ; preds = %bb9, %bb
  %phi = phi i32 [ 0, %bb9 ], [ 0, %bb ]
  %phi3 = phi i32 [ 0, %bb9 ], [ 0, %bb ]
  %phi4 = phi i32 [ 0, %bb9 ], [ 0, %bb ]
  %phi5 = phi i32 [ 0, %bb9 ], [ 0, %bb ]
  br i1 false, label %bb6, label %bb11

bb6:                                              ; preds = %bb2
  br i1 false, label %bb7, label %bb14

bb7:                                              ; preds = %bb6
  %zext = zext i32 %phi4 to i64
  %zext8 = zext i32 %phi to i64
  %icmp = icmp ult i64 %zext, %zext8
  br label %bb17

bb9:                                              ; No predecessors!
  br label %bb2

bb10:                                             ; No predecessors!
  br label %bb17

bb11:                                             ; preds = %bb2, %bb1
  %phi12 = phi i32 [ 0, %bb1 ], [ %phi3, %bb2 ]
  %phi13 = phi i32 [ 0, %bb1 ], [ %phi5, %bb2 ]
  br label %bb20

bb14:                                             ; preds = %bb6, %bb1
  %phi15 = phi i32 [ %phi, %bb6 ], [ 0, %bb1 ]
  %phi16 = phi i32 [ %phi4, %bb6 ], [ 0, %bb1 ]
  br label %bb20

bb17:                                             ; preds = %bb10, %bb7
  %phi18 = phi i64 [ %zext, %bb7 ], [ 0, %bb10 ]
  %phi19 = phi i64 [ 0, %bb7 ], [ 0, %bb10 ]
  br label %bb20

bb20:                                             ; preds = %bb17, %bb14, %bb11
  ret double 0.000000e+00
}

Reproducer: https://godbolt.org/z/eY7nsqG97 Stack dump:

PHI nodes not grouped at top of basic block!
  %2 = phi <2 x i32> [ poison, %bb9 ], [ zeroinitializer, %bb ]
label %bb2
LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes slp-vectorizer -slp-threshold=-99999 <source>
 #0 0x0000000004d50ef8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d50ef8)
 #1 0x0000000004d4e64c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007430bee42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007430bee969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007430bee42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007430bee287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x00000000007aa2c7 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0
 #7 0x0000000004c92718 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c92718)
 #8 0x0000000004b9b013 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4b9b013)
 #9 0x00000000008c0f9e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8c0f9e)
#10 0x0000000004b5e93c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4b5e93c)
#11 0x00000000008cba52 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8cba52)
#12 0x00000000008bf2a5 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8bf2a5)
#13 0x00007430bee29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#14 0x00007430bee29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#15 0x00000000008b604e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8b604e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
nikic commented 4 months ago

cc @alexey-bataev

alexey-bataev commented 4 months ago

Fixed in 5e67c41a932256e047ae093ae4f7f5a53df1527d