Issue 83920
Summary [DAGCombiner][RISC-V] DAGCombiner.cpp:8692: Assertion `Index < ByteWidth && "invalid index requested"' failed.
Labels new issue
Assignees
Reporter patrick-rivos
    Testcase:
```c
extern char a[][5];
extern int b[];
short c = -13632;
char d[5];
int main() {
  d[0] = 0;
  for (int e = 0; e < 5; e += c - 18446744073709537983ULL) {
    a[e][e] = ({ d[e]; }) | 8;
    b[e] = ({ d[e]; }) >= 0;
  }
}
```

Reduced LLVM IR:
```llvm ir
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "riscv64-unknown-linux-gnu"

define i32 @main() #0 {
entry:
 %0 = load <2 x i8>, ptr null, align 1
  %1 = extractelement <2 x i8> %0, i64 0
  %2 = or i8 %1, 1
  store i8 %2, ptr null, align 1
  ret i32 0
}

attributes #0 = { "target-features"="+64bit,+v" }
```

Backtrace:
```
> /scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc reduced.ll
llc: /scratch/tc-testing/tc-feb-22-llvm/llvm/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:8692: std::optional<llvm::ByteProvider<llvm::SDNode*> > calculateByteProvider(llvm::SDValue, unsigned int, unsigned int, std::optional<long unsigned int>, unsigned int): Assertion `Index < ByteWidth && "invalid index requested"' 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/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc reduced.ll
1.      Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.      Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@main'
 #0 0x000055e74b9d0350 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc+0x1c89350)
 #1 0x000055e74b9cd75f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc+0x1c8675f)
 #2 0x000055e74b9cd8b5 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f1816242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f18162969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f18162969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f18162969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f1816242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f18162287f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f181622871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f1816239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x000055e74b57d3bb calculateByteProvider(llvm::SDValue, unsigned int, unsigned int, std::optional<unsigned long>, unsigned int) (.isra.0) DAGCombiner.cpp:0:0
#12 0x000055e74b57cf7f calculateByteProvider(llvm::SDValue, unsigned int, unsigned int, std::optional<unsigned long>, unsigned int) (.isra.0) DAGCombiner.cpp:0:0
#13 0x000055e74b57d1cb calculateByteProvider(llvm::SDValue, unsigned int, unsigned int, std::optional<unsigned long>, unsigned int) (.isra.0) DAGCombiner.cpp:0:0
#14 0x000055e74b5dd791 (anonymous namespace)::DAGCombiner::visitOR(llvm::SDNode*) DAGCombiner.cpp:0:0
#15 0x000055e74b6266b1 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#16 0x000055e74b62810e (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) DAGCombiner.cpp:0:0
#17 0x000055e74b62a7ad llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOptLevel) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc+0x18e37ad)
#18 0x000055e74b76fcee llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc+0x1a28cee)
#19 0x000055e74b773fbf llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc+0x1a2cfbf)
#20 0x000055e74b775b35 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#21 0x000055e74a95bdf7 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#22 0x000055e74af44cee llvm::FPPassManager::runOnFunction(llvm::Function&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc+0x11fdcee)
#23 0x000055e74af44f39 llvm::FPPassManager::runOnModule(llvm::Module&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc+0x11fdf39)
#24 0x000055e74af458a5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc+0x11fe8a5)
#25 0x000055e74a279cda compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#26 0x000055e74a1d97c6 main (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc+0x4927c6)
#27 0x00007f1816229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#28 0x00007f1816229e40 call_init ./csu/../csu/libc-start.c:128:20
#29 0x00007f1816229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#30 0x000055e74a270505 _start (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc+0x529505)
zsh: IOT instruction (core dumped) /scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/llc reduced.ll
```
Godbolt: https://godbolt.org/z/r4K8rPMzW
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to