Description
The validator doesn't like GEP chains where an array GEP is followed by a scalar GEP.
If you compile the following LLVM IR to DXIL using llc -filetype=obj -mtriple=dxil-pc-shadermodel6.3-library
define i32 @gep_chain() #0 {
%1 = alloca [4 x i32], align 4
%2 = getelementptr inbounds nuw [4 x i32], ptr %1, i32 0, i32 2
%3 = getelementptr inbounds nuw i32, ptr %2, i32 1
; Effectively, %3 is equivalent to getelementptr inbounds nuw [4 x i32], ptr %1, i32 0, i32 3
%4 = load i32, ptr %3
ret i32 %4
}
attributes #0 = { convergent norecurse nounwind "hlsl.export"}
and then validate the resulting dxil using dxv, you get the following validation error (#140417):
Function: gep_chain: error: Access to out-of-bounds memory is disallowed.
note: at '%3 = getelementptr inbounds i32, i32* %2, i32 1' in block '#0' of function 'gep_chain'.
Validation failed.
These GEP chains can appear when compiling HLSL shaders such as this one: https://godbolt.org/z/ExeGKb7MG
Metadata
Metadata
Assignees
Type
Projects
Status
Active