Skip to content

[DirectX] PostOptimizationValidation asserts on overlapping bindings when the free space is out of order with the overlapping binding #150534

@bogner

Description

@bogner

Consider:

; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.3-library %s 2>&1 | FileCheck %s

; Check overlap with a gap in the binding space.

; A overlaps with B
; RWBuffer<float> A[3] : register(u0);
; RWBuffer<float> B[] : register(u4);
; RWBuffer<float> C : register(u17);

; CHECK: error: resource C at register 17 overlaps with resource B at register 4 in space 0

@A.str = private unnamed_addr constant [2 x i8] c"A\00", align 1
@B.str = private unnamed_addr constant [2 x i8] c"B\00", align 1
@C.str = private unnamed_addr constant [2 x i8] c"C\00", align 1

define void @test_overlapping() {
entry:
  %h1 = call target("dx.TypedBuffer", float, 1, 0, 0) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 3, i32 0, i1 false, ptr @A.str)
  %h2 = call target("dx.TypedBuffer", float, 1, 0, 0) @llvm.dx.resource.handlefrombinding(i32 0, i32 4, i32 -1, i32 0, i1 false, ptr @B.str)
  %h3 = call target("dx.TypedBuffer", float, 1, 0, 0) @llvm.dx.resource.handlefrombinding(i32 0, i32 17, i32 1, i32 0, i1 false, ptr @C.str)
  ret void
}

We should see an overlapping binding error here, but we currently trigger an assert instead:

assert(LastFreeRange.UpperBound == UINT32_MAX);

This needs to correctly report that there's an overlap instead of asserting.

Metadata

Metadata

Assignees

Labels

backend:DirectXllvm:analysisIncludes value tracking, cost tables and constant folding

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions