Issue 176553
Summary [AMDGPU] Assertion `std::abs(NumInsertions) <= 1 && "Unbalanced operations!"' failed.
Labels backend:AMDGPU, crash-on-valid, generated by fuzzer
Assignees
Reporter XChy
    Reproducer: https://godbolt.org/z/dWWx4jdeo
Testcase:
```llvm
target datalayout = "e-m:e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
target triple = "amdgcn-amd-amdhsa"

define void @backsmith_snippet_1058(i32 %0) {
entry:
  switch i32 %0, label %sw.epilog [
    i32 2, label %BS_LABEL_2
    i32 8, label %BS_LABEL_2
    i32 0, label %BS_LABEL_1
 i32 35, label %BS_LABEL_4
    i32 47, label %BS_LABEL_4
  ]

BS_LABEL_2: ; preds = %BS_LABEL_1, %entry, %entry
 br label %BS_LABEL_4

sw.epilog:                                        ; preds = %entry
  unreachable

BS_LABEL_4: ; preds = %BS_LABEL_2, %entry, %entry
  %p_1745.2 = phi i32 [ 0, %BS_LABEL_2 ], [ 1, %entry ], [ 1, %entry ]
  %tobool.not = icmp eq i32 %p_1745.2, 0
  br label %BS_LABEL_1

BS_LABEL_1: ; preds = %BS_LABEL_4, %entry
  %p_1745.3 = phi i32 [ %p_1745.2, %BS_LABEL_4 ], [ 0, %entry ]
  call void @foo()
  br label %BS_LABEL_2
}

declare void @foo()
```

Dump:
```
llc: /root/llvm-project/llvm/include/llvm/Support/CFGUpdate.h:87: void llvm::cfg::LegalizeUpdates(llvm::ArrayRef<llvm::cfg::Update<NodePtr> >, llvm::SmallVectorImpl<llvm::cfg::Update<NodePtr> >&, bool, bool) [with NodePtr = llvm::BasicBlock*]: Assertion `std::abs(NumInsertions) <= 1 && "Unbalanced operations!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -O1 <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'Convert irreducible control-flow into natural loops' on function '@backsmith_snippet_1058'
 #0 0x0000000004252608 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x4252608)
 #1 0x000000000424f4e4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007a3fe0242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007a3fe02969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007a3fe0242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007a3fe02287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x00007a3fe022871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x00007a3fe0239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x0000000002b8eff0 void llvm::cfg::LegalizeUpdates<llvm::BasicBlock*>(llvm::ArrayRef<llvm::cfg::Update<llvm::BasicBlock*>>, llvm::SmallVectorImpl<llvm::cfg::Update<llvm::BasicBlock*>>&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2b8eff0)
 #9 0x0000000002c8acf8 llvm::GraphDiff<llvm::BasicBlock*, false>::GraphDiff(llvm::ArrayRef<llvm::cfg::Update<llvm::BasicBlock*>>, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2c8acf8)
#10 0x00000000036e692e llvm::DominatorTreeBase<llvm::BasicBlock, false>::applyUpdates(llvm::ArrayRef<llvm::cfg::Update<llvm::BasicBlock*>>) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x36e692e)
#11 0x0000000002b851a5 llvm::GenericDomTreeUpdater<llvm::DomTreeUpdater, llvm::DominatorTree, llvm::PostDominatorTree>::applyUpdates(llvm::ArrayRef<llvm::cfg::Update<llvm::BasicBlock*>>) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2b851a5)
#12 0x00000000044c7d8f llvm::ControlFlowHub::finalize(llvm::DomTreeUpdater*, llvm::SmallVectorImpl<llvm::BasicBlock*>&, llvm::StringRef, std::optional<unsigned int>) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x44c7d8f)
#13 0x0000000004304fc3 fixIrreducible(llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function>>&, llvm::GenericCycleInfo<llvm::GenericSSAContext<llvm::Function>>&, llvm::DominatorTree&, llvm::LoopInfo*) FixIrreducible.cpp:0:0
#14 0x0000000004305cbd FixIrreducibleImpl(llvm::Function&, llvm::GenericCycleInfo<llvm::GenericSSAContext<llvm::Function>>&, llvm::DominatorTree&, llvm::LoopInfo*) FixIrreducible.cpp:0:0
#15 0x0000000003773256 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3773256)
#16 0x0000000003773601 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3773601)
#17 0x0000000003773e6f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3773e6f)
#18 0x00000000008eb34d compileModule(char**, llvm::SmallVectorImpl<llvm::PassPlugin>&, llvm::LLVMContext&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) llc.cpp:0:0
#19 0x00000000007c6f8c main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7c6f8c)
#20 0x00007a3fe0229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x00007a3fe0229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#22 0x00000000008e03f5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x8e03f5)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to