-
Notifications
You must be signed in to change notification settings - Fork 15k
Description
The Problem
157 DML shaders are failing to validate due to a validation error simply reported as "Invalid record" with no additional details.
Invalid record
Validation failed.
This is particularly problematic because DXC's BitcodeReader.cpp contains 191 locations where such an error of the same name can be emitted.
Fortunately, it appears that all (current) cases of "Invalid record" are caused by llvm.lifetime.* intrinsics in the resulting DXIL.
Removing these intrinsics from the DXIL allows validation to proceed in all 157 cases.
This was found by using lldb to inspect where in dxv the "Invalid record" error was emitted, and it occurred in
https://github.com/microsoft/DirectXShaderCompiler/blob/main/lib/Bitcode/Reader/BitcodeReader.cpp#L4722
(lldb) expr FTy->dump()
void (i64, i8*)
(lldb) expr Callee->getName()
(llvm::StringRef) $0 = (Data = "llvm.lifetime.start.p0", Length = 22)
Reproducing the problem
One such DML shader failing to validate with this error is CumulativeOperationProduct_256_int64_native_8.hlsl
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.datA small test shader that can reproduce the same "Invalid record" validation error is shown below.
uint2 Foo(uint2 a[2], uint i) {
return a[i];
}
cbuffer Constants {
uint2 arr[2];
}
RWStructuredBuffer<uint> output;
[numthreads(1, 1, 1)]
void CSMain(uint3 Tid : SV_DispatchThreadID) {
output[0] = Foo(arr, Tid.x).x;
}https://godbolt.org/z/3Wx8zsn1e
Causes
Case 1 - Invalid encoding of lifetime intrinsics
The validation error occurs regardless of shader model, and the error implies that the lifetime intrinsic calls are not encoded properly.
https://github.com/microsoft/DirectXShaderCompiler/blob/main/lib/Bitcode/Reader/BitcodeReader.cpp#L4722
Case 2 - Use of lifetime intrinsics in DXIL versions < 1.6
We should not be emitting lifetime intrinsics for DXIL versions < 1.6. We should instead emit stores of 0 or undef just like DXC: https://github.com/microsoft/DirectXShaderCompiler/blob/d751c827ed3b61e87fdf57d0f424cb2d7af30cd0/lib/HLSL/DxilPreparePasses.cpp#L693-L699
Sub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
Status