Issue 134749
Summary [SPIRV][HLSL] Crash in SPIRVInstructionSelector::loadHandleBeforePosition
Labels HLSL, backend:SPIR-V
Assignees farzonl
Reporter farzonl
    
## HLSL source
https://hlsl.godbolt.org/z/a3KK9cxKa
```HLSL
// FLAGS: -T cs_6_0  -E main -spirv -fspv-target-env=vulkan1.3

[numthreads(1,1,1)]
void main(uint GI : SV_GroupIndex) {
  Out[GI] = In[GI] * In[GI];
}
```

## LLVM IR
https://hlsl.godbolt.org/z/3cx68n68W
```llvm
define void @main() local_unnamed_addr #0 {
  %1 = tail call i32 @llvm.spv.flattened.thread.id.in.group()
  %2 = tail call noundef nonnull align 16 dereferenceable(16) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_f32_5_2_0_0_2_0t(target("spirv.Image", float, 5, 2, 0, 0, 2, 0) poison, i32 %1), !dbg !58
  %3 = load <4 x float>, ptr %2, align 16, !dbg !60
  %4 = fmul reassoc nnan ninf nsz arcp afn <4 x float> %3, %3, !dbg !66
  %5 = tail call noundef nonnull align 16 dereferenceable(16) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_f32_5_2_0_0_2_0t(target("spirv.Image", float, 5, 2, 0, 0, 2, 0) poison, i32 %1), !dbg !67
  store <4 x float> %4, ptr %5, align 16, !dbg !69
  ret void
}
```

## Crash Dump
https://hlsl.godbolt.org/z/T1s7fK83q
```BASH
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang --driver-mode=dxc -Zi -Qembed_debug -Fc /app/output.s -fcolor-diagnostics -fno-crash-diagnostics -T cs_6_0 -E main -spirv -fspv-target-env=vulkan1.3 <source>
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '<source>'.
4.	Running pass 'InstructionSelect' on function '@main'
 #0 0x0000000003b9cae8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3b9cae8)
 #1 0x0000000003b9ac2c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3b9ac2c)
 #2 0x0000000003aeb558 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007c72b7a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00000000022e820f llvm::foldImm(llvm::MachineOperand const&, llvm::MachineRegisterInfo const*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x22e820f)
 #5 0x000000000232d23b (anonymous namespace)::SPIRVInstructionSelector::loadHandleBeforePosition(llvm::Register&, llvm::MachineInstr const*, llvm::GIntrinsic&, llvm::MachineInstr&) const (.isra.0) SPIRVInstructionSelector.cpp:0:0
 #6 0x000000000232f007 (anonymous namespace)::SPIRVInstructionSelector::selectStore(llvm::MachineInstr&) const SPIRVInstructionSelector.cpp:0:0
 #7 0x000000000233e363 (anonymous namespace)::SPIRVInstructionSelector::selectIntrinsic(llvm::Register, llvm::MachineInstr const*, llvm::MachineInstr&) const SPIRVInstructionSelector.cpp:0:0
 #8 0x0000000002340f69 (anonymous namespace)::SPIRVInstructionSelector::spvSelect(llvm::Register, llvm::MachineInstr const*, llvm::MachineInstr&) const SPIRVInstructionSelector.cpp:0:0
 #9 0x00000000023444e9 (anonymous namespace)::SPIRVInstructionSelector::select(llvm::MachineInstr&) SPIRVInstructionSelector.cpp:0:0
#10 0x0000000004c051eb llvm::InstructionSelect::selectMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4c051eb)
#11 0x0000000004c06875 llvm::InstructionSelect::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4c06875)
#12 0x0000000002f98778 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#13 0x000000000350a432 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x350a432)
#14 0x000000000350a6c1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x350a6c1)
#15 0x000000000350c029 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x350c029)
#16 0x0000000003e464ad clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e464ad)
#17 0x00000000044d26c5 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x44d26c5)
#18 0x00000000060e8dec clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x60e8dec)
#19 0x00000000044d2d9d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x44d2d9d)
#20 0x00000000047ddc21 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x47ddc21)
#21 0x000000000475c38b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x475c38b)
#22 0x00000000048cdfd3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x48cdfd3)
#23 0x0000000000d75af1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xd75af1)
#24 0x0000000000d6e2ed ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#25 0x0000000004544a49 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#26 0x0000000003aeb973 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3aeb973)
#27 0x0000000004544c69 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#28 0x000000000450834d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x450834d)
#29 0x0000000004509311 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x4509311)
#30 0x000000000451365c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x451365c)
#31 0x0000000000d728c1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xd728c1)
#32 0x0000000000c325d4 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xc325d4)
#33 0x00007c72b7a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#34 0x00007c72b7a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#35 0x0000000000d6dd85 _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xd6dd85)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to