Issue 243265
Summary [Hexagon] Assertion `idx < size()` failed in `RenameIndependentSubregs` pass
Labels backend:Hexagon, llvm:codegen, crash-on-valid
Assignees
Reporter alexrp
    ```llvm
target triple = "hexagon"

define i64 @f(ptr %unused0, i32 %a, i8 %unused1, i4 %sel, i1 %b, i64 %x) {
entry:
  switch i4 %sel, label %exit [
    i4 -4, label %bb2
    i4 -5, label %bb1
  ]

bb1:
  %p = phi i32 [ %a, %bb2 ], [ 0, %entry ]
  %z = zext i1 %b to i32
  %add = add i32 %p, %z
  %cmp = icmp ugt i32 %add, 0
  br i1 %cmp, label %exit, label %bb3

bb2:
  br label %bb1

bb3:
  %cmp2 = icmp eq i32 %a, 0
  br i1 %cmp2, label %bb4, label %exit

bb4:
  %lo = trunc i64 %x to i32
  %sh = lshr i64 %x, 32
  %hi = trunc i64 %sh to i16
  br label %exit

exit:
  %v1 = phi i16 [ 0, %entry ], [ 0, %bb4 ], [ 1, %bb1 ], [ 0, %bb3 ]
  %v2 = phi i16 [ 1, %entry ], [ %hi, %bb4 ], [ 26, %bb1 ], [ 26, %bb3 ]
  %v3 = phi i32 [ 0, %entry ], [ %lo, %bb4 ], [ 0, %bb1 ], [ undef, %bb3 ]
  %e2 = zext i16 %v2 to i64
  %e1 = zext i16 %v1 to i64
  %o1 = or i64 %e2, %e1
  %e3 = zext i32 %v3 to i64
  %r = or i64 %o1, %e3
  ret i64 %r
}
```

```console
❯ llc --version | head -n2
LLVM (http://llvm.org/):
  LLVM version 23.1.5
❯ llc repro.ll
llc: /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/SmallVector.h:304: const T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::operator[](size_type) const [with T = llvm::LiveInterval*; <template-parameter-1-2> = void; const_reference = llvm::LiveInterval* const&; size_type = long unsigned int]: Assertion `idx < size()' 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: llc repro.ll
1.	Running pass 'Function Pass Manager' on module 'repro.ll'.
2.	Running pass 'Rename Disconnected Subregister Components' on function '@f'
 #0 0x000073a9c7efb10c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/alexrp/Sources/llvm/llvm/lib/Support/Unix/Signals.inc:911:3
 #1 0x000073a9c7ef8084 llvm::sys::RunSignalHandlers() /home/alexrp/Sources/llvm/llvm/lib/Support/Signals.cpp:108:20
 #2 0x000073a9c7ef8949 SignalHandler(int, siginfo_t*, void*) /home/alexrp/Sources/llvm/llvm/lib/Support/Unix/Signals.inc:474:14
 #3 0x000073a9c6845cb0 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x45cb0)
 #4 0x000073a9c68a616c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x000073a9c68a616c __pthread_kill_internal ./nptl/pthread_kill.c:89:10
 #6 0x000073a9c68a616c pthread_kill ./nptl/pthread_kill.c:100:10
 #7 0x000073a9c6845b7e raise ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x000073a9c68288ec internal_signal_block_all ./stdlib/../sysdeps/unix/sysv/linux/internal-signals.h:81:3
 #9 0x000073a9c68288ec __abort_lock_wrlock ./stdlib/abort.c:62:3
#10 0x000073a9c68288ec abort ./stdlib/abort.c:85:3
#11 0x000073a9c6829979 _IO_acquire_lock_fct ./libio/libioP.h:991:6
#12 0x000073a9c6829979 _IO_peekc_locked ./libio/peekc.c:37:3
#13 0x000073a9c683bf75 __libc_message_wrapper ./assert/../include/stdio.h:203:3
#14 0x000073a9c683bf75 __assert_fail ./assert/assert.c:37:3
#15 0x000073a9c789f14a llvm::SmallVectorTemplateCommon<llvm::LiveInterval::SubRange*, void>::operator[](unsigned long) (.part.0) /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/SmallVector.h:299:13
#16 0x000073a9c8702a9a llvm::SmallVectorTemplateCommon<llvm::LiveInterval*, void>::operator[](unsigned long) const /home/alexrp/Sources/llvm/llvm/lib/CodeGen/RenameIndependentSubregs.cpp:236:39
#17 0x000073a9c8702a9a rewriteOperands /home/alexrp/Sources/llvm/llvm/lib/CodeGen/RenameIndependentSubregs.cpp:221:29
#18 0x000073a9c8702a9a (anonymous namespace)::RenameIndependentSubregs::renameComponents(llvm::LiveInterval&) const /home/alexrp/Sources/llvm/llvm/lib/CodeGen/RenameIndependentSubregs.cpp:155:18
#19 0x000073a9c8702f0c (anonymous namespace)::RenameIndependentSubregs::run(llvm::MachineFunction&) (.part.0) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/RenameIndependentSubregs.cpp:456:13
#20 0x000073a9c8703835 (anonymous namespace)::RenameIndependentSubregsLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/RenameIndependentSubregs.cpp:431:1
#21 0x000073a9c84b4212 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/MachineFunctionPass.cpp:95:30
#22 0x000073a9c80d6b2e llvm::FPPassManager::runOnFunction(llvm::Function&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1416:40
#23 0x000073a9c80d6ff5 llvm::ilist_detail::node_base_prevnext<llvm::ilist_node_base<true, void>, true>::getNext() const /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_node_base.h:42:38
#24 0x000073a9c80d6ff5 llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>>::getNext() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_node.h:108:66
#25 0x000073a9c80d6ff5 llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>, false, false>::operator++() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_iterator.h:187:25
#26 0x000073a9c80d6ff5 llvm::FPPassManager::runOnModule(llvm::Module&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1469:22
#27 0x000073a9c80d7a23 runOnModule /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1561:38
#28 0x000073a9c80d7a23 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:533:55
#29 0x0000567a9e7456c2 compileModule(char**, llvm::SmallVectorImpl<llvm::PassPlugin>&, llvm::LLVMContext&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) /home/alexrp/Sources/llvm/llvm/tools/llc/llc.cpp:882:34
#30 0x0000567a9e738c6c main /home/alexrp/Sources/llvm/llvm/tools/llc/llc.cpp:460:35
#31 0x000073a9c682a601 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:83:3
#32 0x000073a9c682a718 call_init ./csu/../csu/libc-start.c:128:20
#33 0x000073a9c682a718 __libc_start_main ./csu/../csu/libc-start.c:347:5
#34 0x0000567a9e7397d5 _start (/home/alexrp/.local/opt/llvm-23/bin/llc+0x127d5)
```

I'm not really sure if this is a bug in the backend or in the pass.

This is blocking [zig-bootstrap](https://codeberg.org/ziglang/zig-bootstrap) for `hexagon-linux-musl`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to