Issue 149179
Summary [DirectX] Crash in DXILFlattenArrays.cpp in visitGetElementPtrInst
Labels backend:DirectX
Assignees Icohedron
Reporter farzonl
    The crash is because of this line:
https://github.com/llvm/llvm-project/blob/3a6ef8b359fc3f2459ef60013b8938ebe847831b/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp#L348

Didn't debug this but this would indicate that `NewGEP` is not a `GEPOperator`. Likely we need to change an assumption.

LLVM IR repro Case 1:
```llvm
@switch.table = private unnamed_addr constant [4 x i32] [i32 1, i32 257, i32 65793, i32 16843009], align 4

define void @anchor_function() #0 {
entry:
  %switch_ptr = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table, i32 0, i32 0
  %switch_val = load i32, i32* %switch_ptr
 ret void
}
```

LLVM IR repro Case 2:
```llvm
define void @blah() #0 {
entry:
%array_ptr = getelementptr inbounds [3 x float], [3 x float]* @private_array, i64 0, i64 0
 %array_val = load float, float* %array_ptr
 ret void
}
```

Crash stack
```gdb
Stack dump:
0.      Program arguments: /home/kaitlinpeng/llvm-build-debug/bin/llc /home/kaitlinpeng/llvm-project/llvm/test/CodeGen/DirectX/finalize_linkage.ll --filetype=asm -o -
1.      Running pass 'DXIL Array Flattener' on module '/home/kaitlinpeng/llvm-project/llvm/test/CodeGen/DirectX/finalize_linkage.ll'.
#0 0x000055c05a7530c1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/kaitlinpeng/llvm-project/llvm/lib/Support/Unix/Signals.inc:834:11
#1 0x000055c05a75364b PrintStackTraceSignalHandler(void*) /home/kaitlinpeng/llvm-project/llvm/lib/Support/Unix/Signals.inc:918:1
#2 0x000055c05a751396 llvm::sys::RunSignalHandlers() /home/kaitlinpeng/llvm-project/llvm/lib/Support/Signals.cpp:104:5
#3 0x000055c05a753dcd SignalHandler(int, siginfo_t*, void*) /home/kaitlinpeng/llvm-project/llvm/lib/Support/Unix/Signals.inc:426:38
#4 0x00007f446704e330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x00007f44670a7b2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
#6 0x00007f446704e27e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x00007f44670318ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x00007f446703181b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x00007f4467044517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x000055c057dd4938 decltype(auto) llvm::cast<llvm::GEPOperator, llvm::Value>(llvm::Value*) /home/kaitlinpeng/llvm-project/llvm/include/llvm/Support/Casting.h:579:10
#11 0x000055c057dd0a8a (anonymous namespace)::DXILFlattenArraysVisitor::visitGetElementPtrInst(llvm::GetElementPtrInst&) /home/kaitlinpeng/llvm-project/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp:348:29
#12 0x000055c057dcee9d llvm::InstVisitor<(anonymous namespace)::DXILFlattenArraysVisitor, bool>::visitGetElementPtr(llvm::GetElementPtrInst&) /home/kaitlinpeng/llvm-project/llvm/include/llvm/IR/Instruction.def:174:1
#13 0x000055c057dce4f2 llvm::InstVisitor<(anonymous namespace)::DXILFlattenArraysVisitor, bool>::visit(llvm::Instruction&) /home/kaitlinpeng/llvm-project/llvm/include/llvm/IR/Instruction.def:174:1
#14 0x000055c057dcd735 (anonymous namespace)::DXILFlattenArraysVisitor::visit(llvm::Function&) /home/kaitlinpeng/llvm-project/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp:367:21
#15 0x000055c057dcd019 flattenArrays(llvm::Module&) /home/kaitlinpeng/llvm-project/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp:469:19
#16 0x000055c057dd3029 (anonymous namespace)::DXILFlattenArraysLegacy::runOnModule(llvm::Module&) /home/kaitlinpeng/llvm-project/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp:488:3
#17 0x000055c05973129b (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/kaitlinpeng/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1513:23
#18 0x000055c059730e1a llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/kaitlinpeng/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:531:16
#19 0x000055c0597356a1 llvm::legacy::PassManager::run(llvm::Module&) /home/kaitlinpeng/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1640:3
#20 0x000055c057b05c9a compileModule(char**, llvm::LLVMContext&) /home/kaitlinpeng/llvm-project/llvm/tools/llc/llc.cpp:761:9
#21 0x000055c057b03d71 main /home/kaitlinpeng/llvm-project/llvm/tools/llc/llc.cpp:404:13
#22 0x00007f44670331ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#23 0x00007f446703328b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#24 0x000055c057b03525 _start (/home/kaitlinpeng/llvm-build-debug/bin/llc+0x3409525)
FileCheck error: '<stdin>' is empty.
FileCheck command line: /home/kaitlinpeng/llvm-build-debug/bin/FileCheck /home/kaitlinpeng/llvm-project/llvm/test/CodeGen/DirectX/finalize_linkage.ll --check-prefixes=CHECK-LLC
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to