Issue 139791
Summary [AMDGPU][GlobalISel] G_UNMERGE_VALUES combining crash
Labels new issue
Assignees
Reporter mshelego
    Assertion failure is observed in LegalizationArtifactCombiner::tryCombineUnmergeValues() when trying to combine two G_UNMERGE_VALUES instructions with a COPY between them.

Input:
```
---
name: test
body: |
  bb.0:
    %0:_(s32) = COPY $vgpr0
    %1:_(s16), %2:_(s16) = G_UNMERGE_VALUES %0:_(s32)
    %3:_(s16) = COPY %1:_(s16)
    %4:_(s8), %5:_(s8) = G_UNMERGE_VALUES %3:_(s16)
 %6:_(s32) = G_ZEXT %4:_(s8)
    $vgpr0 = COPY %6:_(s32)
...
```
Command:
```
llc -mtriple=amdgcn -run-pass=legalizer input.mir
```
Output:
```
llc: /src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:454: T& llvm::MutableArrayRef<T>::operator[](size_t) const [with T = llvm::MachineOperand; size_t =    long unsigned int]: Assertion `Index < this->size() && "Invalid index!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: ./bin/llc -mtriple=amdgcn -run-pass=legalizer test.mir
1.  Running pass 'Function Pass Manager' on module 'test.mir'.
2.  Running pass 'Legalizer' on function '@test'
 #0 0x00007e7610cf3e46 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /src/llvm-project/llvm/lib/Support/Unix/Signals.inc:804:22
 #1 0x00007e7610cf42cf PrintStackTraceSignalHandler(void*) /src/llvm-project/llvm/lib/Support/Unix/Signals.inc:888:1
 #2 0x00007e7610cf160b llvm::sys::RunSignalHandlers() /src/llvm-project/llvm/lib/Support/Signals.cpp:105:20
 #3 0x00007e7610cf36c8 SignalHandler(int, siginfo_t*, void*) /src/llvm-project/llvm/lib/Support/Unix/Signals.inc:418:13
 #4 0x00007e760f045330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x00007e760f09eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007e760f09eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #7 0x00007e760f09eb2c pthread_kill ./nptl/pthread_kill.c:89:10
 #8 0x00007e760f04527e raise ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x00007e760f0288ff abort ./stdlib/abort.c:81:7
#10 0x00007e760f02881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#11 0x00007e760f03b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#12 0x00007e76112f41fa llvm::MutableArrayRef<llvm::MachineOperand>::operator[](unsigned long) const /src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:455:18
#13 0x00007e76112f1d1a llvm::MachineInstr::getOperand(unsigned int) /src/llvm-project/llvm/include/llvm/CodeGen/MachineInstr.h:595:71
#14 0x00007e761191f7ce llvm::MachineInstrBuilder::getReg(unsigned int) const /src/llvm-project/llvm/include/llvm/CodeGen/MachineInstrBuilder.h:96:74
#15 0x00007e76124f6be0 llvm::LegalizationArtifactCombiner::tryCombineUnmergeValues(llvm::GUnmerge&, llvm::SmallVectorImpl<llvm::MachineInstr*>&, llvm:: SmallVectorImpl<llvm::Register>&, llvm::GISelChangeObserver&) /src/llvm-project/llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h:1122:30
#16 0x00007e76124f7c7c llvm::LegalizationArtifactCombiner::tryCombineInstruction(llvm::MachineInstr&, llvm::SmallVectorImpl<llvm::MachineInstr*>&, llvm:: GISelObserverWrapper&) /src/llvm-project/llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h:1352:40
#17 0x00007e76124ef433 llvm::Legalizer::legalizeMachineFunction(llvm::MachineFunction&, llvm::LegalizerInfo const&, llvm::ArrayRef<llvm::GISelChangeObserver*>, llvm::       LostDebugLocObserver&, llvm::MachineIRBuilder&, llvm::GISelValueTracking*) /src/llvm-project/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp:286:7
#18 0x00007e76124efab2 llvm::Legalizer::runOnMachineFunction(llvm::MachineFunction&) /src/llvm-project/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp:347:44
#19 0x00007e761178ca69 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /src/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:108:30
#20 0x00007e76110917ae llvm::FPPassManager::runOnFunction(llvm::Function&) /src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1406:20
#21 0x00007e7611091a84 llvm::FPPassManager::runOnModule(llvm::Module&) /src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1452:13
#22 0x00007e7611091ee5 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1521:20
#23 0x00007e761108ce39 llvm::legacy::PassManagerImpl::run(llvm::Module&) /src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:539:13
#24 0x00007e76110927db llvm::legacy::PassManager::run(llvm::Module&) /src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1649:1
#25 0x0000564a95465998 compileModule(char**, llvm::LLVMContext&) /src/llvm-project/llvm/tools/llc/llc.cpp:755:34
#26 0x0000564a95462f65 main /src/llvm-project/llvm/tools/llc/llc.cpp:400:35
#27 0x00007e760f02a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#28 0x00007e760f02a28b call_init ./csu/../csu/libc-start.c:128:20
#29 0x00007e760f02a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#30 0x0000564a95461a25 _start (./bin/llc+0x14a25)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to