Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NVPTX] SelectionDAG Cannot select dynamic_stackalloc #57398

Closed
DataCorrupted opened this issue Aug 27, 2022 · 1 comment
Closed

[NVPTX] SelectionDAG Cannot select dynamic_stackalloc #57398

DataCorrupted opened this issue Aug 27, 2022 · 1 comment

Comments

@DataCorrupted
Copy link
Member

DataCorrupted commented Aug 27, 2022

NVPTX will crash on Cannot select a dynamic_stackalloc given the following LLVM IR.
The bug can be reproduced on the latest commit e723c69b9 and LLVM14.

You can find it here: https://llvm.godbolt.org/z/ea3TbvTqE

; ModuleID = 'PoC'
source_filename = "M"

define void @f() {
BB:
  %B = lshr i32 65536, -2147483648
  %A = alloca i8*, i32 %B, align 4
  %G = getelementptr i8*, i8** %A, i1 true
  store i8** %G, i8*** undef, align 4
  ret void
}

The stack trace is following:

LLVM ERROR: Cannot select: t6: i32,ch = dynamic_stackalloc t0, Constant:i32<0>, Constant:i32<0>
  t3: i32 = Constant<0>
  t3: i32 = Constant<0>
In function: f
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/peter/aflplusplus-isel/llvm-project/build-debug/bin/llc -mtriple=nvptx PoC.ll
1.      Running pass 'Function Pass Manager' on module 'PoC.ll'.
2.      Running pass 'NVPTX DAG->DAG Pattern Instruction Selection' on function '@f'
 #0 0x0000000003a45a1a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:11
 #1 0x0000000003a45bcb PrintStackTraceSignalHandler(void*) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/Support/Unix/Signals.inc:636:1
 #2 0x0000000003a44216 llvm::sys::RunSignalHandlers() /home/peter/aflplusplus-isel/llvm-project/llvm/lib/Support/Signals.cpp:103:5
 #3 0x0000000003a462f5 SignalHandler(int) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007f44398a2980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #5 0x00007f4438792e87 raise /build/glibc-uZu3wS/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #6 0x00007f44387947f1 abort /build/glibc-uZu3wS/glibc-2.27/stdlib/abort.c:81:0
 #7 0x000000000396ca74 llvm::report_fatal_error(llvm::Twine const&, bool) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/Support/ErrorHandling.cpp:125:5
 #8 0x00000000037bec8b /home/peter/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:3765:3
 #9 0x00000000037bc222 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:3667:9
#10 0x0000000001e0e299 llvm::NVPTXDAGToDAGISel::SelectCode(llvm::SDNode*) /home/peter/aflplusplus-isel/llvm-project/build-debug/lib/Target/NVPTX/NVPTXGenDAGISel.inc:86754:1
#11 0x0000000001e00944 llvm::NVPTXDAGToDAGISel::Select(llvm::SDNode*) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp:505:1
#12 0x00000000037afdb9 llvm::SelectionDAGISel::DoInstructionSelection() /home/peter/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1153:5
#13 0x00000000037aee0a llvm::SelectionDAGISel::CodeGenAndEmitDAG() /home/peter/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:933:3
#14 0x00000000037ad7dd llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:685:1
#15 0x00000000037ad27b llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1591:11
#16 0x00000000037aa81d llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:464:3
#17 0x0000000001e004e5 llvm::NVPTXDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp:46:3
#18 0x000000000281fadd llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:85:8
#19 0x0000000002ef9146 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:23
#20 0x0000000002efdf72 llvm::FPPassManager::runOnModule(llvm::Module&) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:16
#21 0x0000000002ef9a19 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:23
#22 0x0000000002ef958d llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16
#23 0x0000000002efe251 llvm::legacy::PassManager::run(llvm::Module&) /home/peter/aflplusplus-isel/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1672:3
#24 0x0000000000d1ad70 compileModule(char**, llvm::LLVMContext&) /home/peter/aflplusplus-isel/llvm-project/llvm/tools/llc/llc.cpp:737:41
#25 0x0000000000d190f2 main /home/peter/aflplusplus-isel/llvm-project/llvm/tools/llc/llc.cpp:418:13
#26 0x00007f4438775c87 __libc_start_main /build/glibc-uZu3wS/glibc-2.27/csu/../csu/libc-start.c:344:0
#27 0x0000000000d188fa _start (/home/peter/aflplusplus-isel/llvm-project/build-debug/bin/llc+0xd188fa)
Aborted
@AlexMaclean
Copy link
Member

This should now be fixed. The linked example now shows an error message about insufficient sm and ptx version. Once these are added the program compiles without issue: https://llvm.godbolt.org/z/3Taj6bx17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants