Skip to content

[RISC-V] RegisterCoalescer: Assertion `A.valno == B.valno && "Cannot overlap different values"' failed. #134424

@ewlu

Description

@ewlu

Testcase:

target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "riscv64-unknown-linux-gnu"

; Function Attrs: vscale_range(2,2)
define i32 @main(i64 %0, i32 %a.promoted49.i, i1 %tobool.not.us.i.4, i1 %tobool.not.us.i.1.4, i1 %tobool.not.us.i.2.4) #0 {
for.body.us.preheader.i:
  %1 = insertelement <4 x i64> zeroinitializer, i64 %0, i64 1
  %2 = shufflevector <4 x i64> %1, <4 x i64> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 1, i32 1>
  %3 = icmp sle <4 x i64> %2, zeroinitializer
  %cond.us.i.4 = select i1 %tobool.not.us.i.4, i32 %a.promoted49.i, i32 1
  %cond.us.i.1.4 = select i1 %tobool.not.us.i.1.4, i32 %a.promoted49.i, i32 1
  %cond.us.i.2.4 = select i1 %tobool.not.us.i.2.4, i32 %a.promoted49.i, i32 1
  %4 = zext <4 x i1> %3 to <4 x i32>
  %5 = shufflevector <4 x i32> %4, <4 x i32> zeroinitializer, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison>
  %6 = call i32 @llvm.vector.reduce.smin.v8i32(<8 x i32> %5)
  %7 = call i32 @llvm.smin.i32(i32 %6, i32 %cond.us.i.4)
  %8 = call i32 @llvm.smin.i32(i32 %cond.us.i.1.4, i32 %cond.us.i.2.4)
  %9 = call i32 @llvm.smin.i32(i32 %7, i32 %8)
  store i32 %9, ptr null, align 4
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.smin.v8i32(<8 x i32>) #1

; uselistorder directives
uselistorder ptr @llvm.smin.i32, { 2, 1, 0 }

attributes #0 = { vscale_range(2,2) "target-features"="+v" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

Commands/backtrace

$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc reduced.ll
llc: /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/CodeGen/LiveInterval.cpp:1186: bool coalescable(const llvm::LiveRange::Segment&, const llvm::LiveRange::Segment&): Assertion `A.valno == B.valno && "Cannot overlap different values"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc reduced.ll
1.      Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.      Running pass 'Register Coalescer' on function '@main'
 #0 0x00005a12f4407a02 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc+0x206da02)
 #1 0x00005a12f4404a6f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc+0x206aa6f)
 #2 0x00005a12f4404bb4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x000077e678c45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #4 0x000077e678c9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x000077e678c9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x000077e678c9eb2c pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x000077e678c4527e raise ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x000077e678c288ff abort ./stdlib/abort.c:81:7
 #9 0x000077e678c2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x000077e678c3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#11 0x00005a12f318bd85 (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc+0xdf1d85)
#12 0x00005a12f3196630 llvm::LiveRangeUpdater::add(llvm::LiveRange::Segment) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc+0xdfc630)
#13 0x00005a12f3196d01 llvm::LiveRange::join(llvm::LiveRange&, int const*, int const*, llvm::SmallVectorImpl<llvm::VNInfo*>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc+0xdfcd01)
#14 0x00005a12f349d8ad (anonymous namespace)::RegisterCoalescer::joinVirtRegs(llvm::CoalescerPair&) (.constprop.0) RegisterCoalescer.cpp:0:0
#15 0x00005a12f34a282f (anonymous namespace)::RegisterCoalescer::joinCopy(llvm::MachineInstr*, bool&, llvm::SmallPtrSetImpl<llvm::MachineInstr*>&) RegisterCoalescer.cpp:0:0
#16 0x00005a12f34a4bb8 (anonymous namespace)::RegisterCoalescer::copyCoalesceWorkList(llvm::MutableArrayRef<llvm::MachineInstr*>) RegisterCoalescer.cpp:0:0
#17 0x00005a12f34a8303 (anonymous namespace)::RegisterCoalescer::run(llvm::MachineFunction&) RegisterCoalescer.cpp:0:0
#18 0x00005a12f34a9568 (anonymous namespace)::RegisterCoalescerLegacy::runOnMachineFunction(llvm::MachineFunction&) RegisterCoalescer.cpp:0:0
#19 0x00005a12f3277119 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#20 0x00005a12f38fe771 llvm::FPPassManager::runOnFunction(llvm::Function&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc+0x1564771)
#21 0x00005a12f38febc1 llvm::FPPassManager::runOnModule(llvm::Module&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc+0x1564bc1)
#22 0x00005a12f38ff554 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc+0x1565554)
#23 0x00005a12f2ae68e3 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#24 0x00005a12f2a00167 main (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc+0x666167)
#25 0x000077e678c2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#26 0x000077e678c2a28b call_init ./csu/../csu/libc-start.c:128:20
#27 0x000077e678c2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#28 0x00005a12f2adc295 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/llc+0x742295)
Aborted (core dumped)

Godbolt: https://godbolt.org/z/PG7E64x3z

Found via fuzzer (C program before reduction)

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions