Issue |
152348
|
Summary |
[DirectX] Select of two different RawBuffer can not easily be reduced to a callInst.
|
Labels |
backend:DirectX
|
Assignees |
|
Reporter |
farzonl
|
This bug is very similar to [#140819](https://github.com/llvm/llvm-project/issues/140819)
However instead of an alloca store like pattern we have two different RawBuffer determined via a select.
## Possible Solution
What we might want to do here is replace the select with a branch and then create two calls for each RawBuffer
## Assert location
```gdb
frame #4: 0x00000001003b7430 clang-dxc`(anonymous namespace)::OpLowerer::lowerIntrinsics() [inlined] decltype(auto) llvm::cast<llvm::CallInst, llvm::Value>(Val=0x000060f00000a3c0) at Casting.h:578:3 [opt]
575
576 template <typename To, typename From>
577 [[nodiscard]] inline decltype(auto) cast(From *Val) {
-> 578 assert(isa<To>(Val) && "cast<Ty>() argument of incompatible type!");
579 return CastInfo<To, From *>::doCast(Val);
580 }
581
```
Like before the issue is we were expecting a CallInst
```gdb
frame #5: 0x00000001003b73e8 clang-dxc`(anonymous namespace)::OpLowerer::lowerIntrinsics() at DXILOpLowering.cpp:177:23 [opt]
174 }
175 // Otherwise, we're the second handle in a pair. Forward the arguments and
176 // remove the (second) cast.
-> 177 CallInst *Def = cast<CallInst>(Cast->getOperand(0));
178 assert(Def->getIntrinsicID() == Intrinsic::dx_resource_casthandle &&
179 "Unbalanced pair of temporary handle casts");
180 Cast->replaceAllUsesWith(Def->getOperand(0));
```
Crashing instruction:
```llvm
%. = select i1 %cmp14.not.i, target("dx.RawBuffer", half, 1, 0) %15, target("dx.RawBuffer", half, 1, 0) %11
```
```gdb
clang-dxc: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 22.0.0git (g...@github.com:llvm/llvm-project.git 6d25d1d5508b7ba9aca77188a175d0a6348c581f)
Target: dxilv1.2-unknown-shadermodel6.2-compute
Thread model: posix
InstalledDir: /llvm_rel_with_deb_info/bin
Build config: +assertions, +asan
Cause instances: 60
Cause:
0. Program arguments: /llvm_rel_with_deb_info/bin/clang-dxc ../DirectML/Product/Shaders/Generated/Quantize_256_4_float16_native_accum32_int4_packed32.hlsl -E CSMain -T cs_6_2 -enable-16bit-types -O3 -D DXC_COMPILER=1 -D __SHADER_TARGET_MAJOR=6 -D __SHADER_TARGET_MINOR=2 -Vd -I ../DirectML/Product/Shaders/ -Fo ClangDML/tools/validation/Quantize_256_4_float16_native_accum32_int4_packed32.dat
1. <eof> parser at end of file
2. Code generation
3. Running pass 'DXIL Embedder' on module '../DirectML/Product/Shaders/Generated/Quantize_256_4_float16_native_accum32_int4_packed32.hlsl'.
----------------------------------------
============================================================
Stack Traces:
#0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm_rel_with_deb_info/bin/clang-21+)
#1 llvm::sys::CleanupOnSignal(unsigned long) (llvm_rel_with_deb_info/bin/clang-21+)
#2 CrashRecoverySignalHandler(int) (llvm_rel_with_deb_info/bin/clang-21+)
#3 (/usr/lib/system/libsystem_platform.dylib+)
#4 (/usr/lib/system/libsystem_pthread.dylib+)
#5 (/usr/lib/system/libsystem_c.dylib+)
#6 (/usr/lib/system/libsystem_c.dylib+)
#7 (anonymous namespace)::OpLowerer::lowerIntrinsics() (/llvm_rel_with_deb_info/bin/clang-21+)
#8 (anonymous namespace)::DXILOpLoweringLegacy::runOnModule(llvm::Module&) (/llvm_rel_with_deb_info/bin/clang-21+)
#9 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/llvm_rel_with_deb_info/bin/clang-21+)
#10 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/llvm_rel_with_deb_info/bin/clang-21+)
#11 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (llvm_rel_with_deb_info/bin/clang-21+)
#12 clang::ParseAST(clang::Sema&, bool, bool) (lvm_rel_with_deb_info/bin/clang-21+)
#13 clang::CodeGenAction::ExecuteAction() (llvm_rel_with_deb_info/bin/clang-21+)
#14 clang::FrontendAction::Execute() (/llvm_rel_with_deb_info/bin/clang-21+)
#15 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/llvm_rel_with_deb_info/bin/clang-21+)
#16 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/llvm_rel_with_deb_info/bin/clang-21+)
#17 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/llvm_rel_with_deb_info/bin/clang-21+)
#18 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/llvm_rel_with_deb_info/bin/clang-21+)
#19 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0>(long) (/llvm_rel_with_deb_info/bin/clang-21+)
#20 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/llvm_rel_with_deb_info/bin/clang-21+)
#21 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (/llvm_rel_with_deb_info/bin/clang-21+)
#22 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/llvm_rel_with_deb_info/bin/clang-21+)
#23 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const (/llvm_rel_with_deb_info/bin/clang-21+)
#24 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (/llvm_rel_with_deb_info/bin/clang-21+)
#25 clang_main(int, char**, llvm::ToolContext const&) (/llvm_rel_with_deb_info/bin/clang-21+)
#26 main (/llvm_rel_with_deb_info/bin/clang-21+)
#27
clang-dxc: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 22.0.0git (g...@github.com:llvm/llvm-project.git 6d25d1d5508b7ba9aca77188a175d0a6348c581f)
Target: dxilv1.2-unknown-shadermodel6.2-compute
Thread model: posix
InstalledDir: /llvm_rel_with_deb_info/bin
Build config: +assertions, +asan
Cause instances: 2
Cause:
0. Program arguments: /llvm_rel_with_deb_info/bin/clang-dxc ../DirectML/Product/Shaders/Generated/RNNOverwrite_16.hlsl -E CSMain -T cs_6_2 -enable-16bit-types -O3 -D DXC_COMPILER=1 -D __SHADER_TARGET_MAJOR=6 -D __SHADER_TARGET_MINOR=2 -Vd -I ../DirectML/Product/Shaders/ -Fo /ClangDML/tools/validation/RNNOverwrite_16.dat
1. <eof> parser at end of file
2. Code generation
3. Running pass 'DXIL Op Lowering' on module '../DirectML/Product/Shaders/Generated/RNNOverwrite_16.hlsl'.
----------------------------------------
============================================================
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs