Skip to content

[DirectX] DXILBitcodeWriter incorrectly writes ConstantExpr GEPs #153304

@Icohedron

Description

@Icohedron

The following LLVM IR fails to be written to valid DXIL:

@g = local_unnamed_addr addrspace(3) global [10 x i32] zeroinitializer, align 8
define void @CSMain() local_unnamed_addr #0 {
  %gep = getelementptr [10 x i32], ptr addrspace(3) @g, i32 0, i32 1
  %ld = load i32, ptr addrspace(3) %gep, align 2
  ret void
}
attributes #0 = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) "approx-func-fp-math"="true" "frame-pointer"="all" "hlsl.numthreads"="4,1,1" "hlsl.shader"="compute" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
> llc -filetype=obj -mtriple=dxil-pc-shadermodel6.7-compute Reproduce.ll -o tmp.dat
> dxv tmp.dat
Load/Store operand is not a pointer type
Validation failed.

This is because the DXIL Flatten Arrays pass turns the GEP instruction into a ConstantExpr GEP:

  %ld = load i32, ptr addrspace(3) getelementptr ([10 x i32], ptr addrspace(3) @g, i32 0, i32 1). align 2

and the DXILBitcodeWriter seems to incorrectly encode ConstantExpr GEPs.

This is preventing 120 DML shaders from successfully validating.

Metadata

Metadata

Assignees

Type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions