Issue 141673
Summary [DirectX] Legalization of memcpy is triggering a src/dst array mismatch assert
Labels new issue
Assignees Icohedron
Reporter farzonl
    The memcpy legalization(#137188, #139173)  appears to be incomplete. We are seeing 8 instances of this assert:

## Assert

```bash
Assertion: (DstElemTy == SrcElemTy && "The element types of Src and Dst arrays must match")
Function: emitMemcpyExpansion
File: DXILLegalizePass.cpp:289
```

 ## The following tests are failing:
```bash
clang-dxc DirectML/Product/Shaders/Generated/CumulativeOperationSummation_256_float16_native_accum16_8.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 -I DirectML/Product/Shaders/ -Fo validation/CumulativeOperationSummation_256_float16_native_accum16_8.dat
clang-dxc DirectML/Product/Shaders/Generated/CumulativeOperationSummation_256_int64_native_8.hlsl -E CSMain -T cs_6_0   -O3 -D DXC_COMPILER=1 -D __SHADER_TARGET_MAJOR=6 -D __SHADER_TARGET_MINOR=0 -I DirectML/Product/Shaders/ -Fo validation/CumulativeOperationSummation_256_int64_native_8.dat
clang-dxc DirectML/Product/Shaders/Generated/CumulativeOperationSummation_256_uint64_native_8.hlsl -E CSMain -T cs_6_0   -O3 -D DXC_COMPILER=1 -D __SHADER_TARGET_MAJOR=6 -D __SHADER_TARGET_MINOR=0 -I DirectML/Product/Shaders/ -Fo validation/CumulativeOperationSummation_256_uint64_native_8.dat
clang-dxc DirectML/Product/Shaders/Generated/CumulativeOperationProduct_256_float16_native_accum32_8.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 -I DirectML/Product/Shaders/ -Fo validation/CumulativeOperationProduct_256_float16_native_accum32_8.dat
clang-dxc DirectML/Product/Shaders/Generated/CumulativeOperationProduct_256_int64_native_8.hlsl -E CSMain -T cs_6_0   -O3 -D DXC_COMPILER=1 -D __SHADER_TARGET_MAJOR=6 -D __SHADER_TARGET_MINOR=0 -I DirectML/Product/Shaders/ -Fo validation/CumulativeOperationProduct_256_int64_native_8.dat
clang-dxc DirectML/Product/Shaders/Generated/CumulativeOperationProduct_256_uint64_native_8.hlsl -E CSMain -T cs_6_0   -O3 -D DXC_COMPILER=1 -D __SHADER_TARGET_MAJOR=6 -D __SHADER_TARGET_MINOR=0 -I DirectML/Product/Shaders/ -Fo validation/CumulativeOperationProduct_256_uint64_native_8.dat
```

## Example of one of the call stacks

```gdb
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.\tProgram arguments: /Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-dxc ../DirectML/Product/Shaders/Generated/CumulativeOperationSummation_256_int64_native_8.hlsl -E CSMain -T cs_6_0   -O3 -D DXC_COMPILER=1 -D __SHADER_TARGET_MAJOR=6 -D __SHADER_TARGET_MINOR=0 -I ../DirectML/Product/Shaders/ -Fo /Users/farzonlotfi/Projects/ClangDML/tools/validation/CumulativeOperationSummation_256_int64_native_8.dat
1.\t<eof> parser at end of file
2.\tCode generation
3.\tRunning pass 'Function Pass Manager' on module '../DirectML/Product/Shaders/Generated/CumulativeOperationSummation_256_int64_native_8.hlsl'.
4.\tRunning pass 'DXIL Legalizer' on function '@CSMain'
 #0 0x00000001093d4768 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x104980768)
 #1 0x00000001093d3164 llvm::sys::CleanupOnSignal(unsigned long) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x10497f164)
 #2 0x00000001091b0d8c CrashRecoverySignalHandler(int) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x10475cd8c)
 #3 0x000000018ea24624 (/usr/lib/system/libsystem_platform.dylib+0x1804ac624)
 #4 0x000000018e9ea88c (/usr/lib/system/libsystem_pthread.dylib+0x18047288c)
 #5 0x000000018e8f3c60 (/usr/lib/system/libsystem_c.dylib+0x18037bc60)
 #6 0x000000018e8f2eec (/usr/lib/system/libsystem_c.dylib+0x18037aeec)
 #7 0x0000000104e3241c legalizeMemCpy(llvm::Instruction&, llvm::SmallVectorImpl<llvm::Instruction*>&, llvm::DenseMap<llvm::Value*, llvm::Value*, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, llvm::Value*>>&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x1003de41c)
 #8 0x0000000104e2c4fc (anonymous namespace)::DXILLegalizationPipeline::runLegalizationPipeline(llvm::Function&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x1003d84fc)
 #9 0x0000000104e37f9c (anonymous namespace)::DXILLegalizeLegacy::runOnFunction(llvm::Function&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x1003e3f9c)
#10 0x0000000107699f58 llvm::FPPassManager::runOnFunction(llvm::Function&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x102c45f58)
#11 0x00000001076ae2ac llvm::FPPassManager::runOnModule(llvm::Module&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x102c5a2ac)
#12 0x000000010769af68 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x102c46f68)
#13 0x000000010a220954 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*) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x1057cc954)
#14 0x000000010ab8ef40 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x10613af40)
#15 0x000000010e51a068 clang::ParseAST(clang::Sema&, bool, bool) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x109ac6068)
#16 0x000000010aba0588 clang::CodeGenAction::ExecuteAction() (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x10614c588)
#17 0x000000010baa2f88 clang::FrontendAction::Execute() (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x10704ef88)
#18 0x000000010b912b2c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x106ebeb2c)
#19 0x000000010bcaa748 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x107256748)
#20 0x0000000104a64e00 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x100010e00)
#21 0x0000000104a5db18 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x100009b18)
#22 0x000000010b30c1d4 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) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x1068b81d4)
#23 0x00000001091b0180 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x10475c180)
#24 0x000000010b309d48 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 (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x1068b5d48)
#25 0x000000010b251b0c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x1067fdb0c)
#26 0x000000010b252868 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x1067fe868)
#27 0x000000010b2a9658 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x106855658)
#28 0x0000000104a5b600 clang_main(int, char**, llvm::ToolContext const&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x100007600)
#29 0x0000000104a83da0 main (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+0x10002fda0)
#30 0x000000018e64ab98 
clang-dxc: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 21.0.0git (g...@github.com:llvm/llvm-project.git a9b64bb3180dab6d28bf800a641f9a9ad54d2c0c)
Target: dxilv1.0-unknown-shadermodel6.0-compute
Thread model: posix
InstalledDir: /Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin
Build config: +assertions, +asan
clang-dxc: warning: dxv not found; resulting DXIL will not be validated or signed for use in release environment [-Wdxil-validation]
clang-dxc: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-dxc: note: diagnostic msg: /var/folders/c5/8k67fxsn7gq5d835vtqt_rcm0000gn/T/CumulativeOperationSummation_256_int64_native_8-8d8479.hlsl
clang-dxc: note: diagnostic msg: /var/folders/c5/8k67fxsn7gq5d835vtqt_rcm0000gn/T/CumulativeOperationSummation_256_int64_native_8-8d8479.sh
clang-dxc: note: diagnostic msg: Crash backtrace is located in
clang-dxc: note: diagnostic msg: /Users/farzonlotfi/Library/Logs/DiagnosticReports/clang-21_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang-dxc: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang-dxc: note: diagnostic msg: 

********************

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

Reply via email to