Skip to content

Commit 07ce57f

Browse files
authored
[DirectX] Add support for implicit binding to DXILForwardHandleAccesses pass (#142061)
Since the `DXILResourceImplicitBinding` pass has been moved after `DXILForwardHandleAccesses` pass the forward-handle pass needs to handle `llvm.dx.resource.handlefromimplicitbinding` calls as well.
1 parent ed71a4f commit 07ce57f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

llvm/lib/Target/DirectX/DXILForwardHandleAccesses.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ static bool forwardHandleAccesses(Function &F, DominatorTree &DT) {
7575
if (auto *II = dyn_cast<IntrinsicInst>(&Inst)) {
7676
switch (II->getIntrinsicID()) {
7777
case Intrinsic::dx_resource_handlefrombinding:
78+
case Intrinsic::dx_resource_handlefromimplicitbinding:
7879
processHandle(II, HandleMap);
7980
break;
8081
default:

llvm/test/CodeGen/DirectX/ForwardHandleAccesses/buffer-O0.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ entry:
1818
store target("dx.RawBuffer", <4 x float>, 1, 0) %_ZL2In_h.i.i, ptr @_ZL2In, align 4
1919
store ptr @_ZL2In, ptr %this.addr.i.i, align 4
2020
%this1.i.i = load ptr, ptr %this.addr.i.i, align 4
21-
; CHECK: [[OUT:%.*]] = call target("dx.RawBuffer", <4 x float>, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_v4f32_1_0t(i32 0, i32 1, i32 1, i32 0, i1 false, ptr null)
22-
%_ZL3Out_h.i.i = call target("dx.RawBuffer", <4 x float>, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_v4f32_1_0t(i32 0, i32 1, i32 1, i32 0, i1 false, ptr null)
21+
; CHECK: [[OUT:%.*]] = call target("dx.RawBuffer", <4 x float>, 1, 0) @llvm.dx.resource.handlefromimplicitbinding.tdx.RawBuffer_v4f32_1_0t(i32 100, i32 0, i32 1, i32 0, i1 false, ptr null)
22+
%_ZL3Out_h.i.i = call target("dx.RawBuffer", <4 x float>, 1, 0) @llvm.dx.resource.handlefromimplicitbinding.tdx.RawBuffer_v4f32_1_0t(i32 100, i32 0, i32 1, i32 0, i1 false, ptr null)
2323
store target("dx.RawBuffer", <4 x float>, 1, 0) %_ZL3Out_h.i.i, ptr @_ZL3Out, align 4
2424
store ptr @_ZL3Out, ptr %this.addr.i.i.i, align 4
2525
%this1.i.i.i = load ptr, ptr %this.addr.i.i.i, align 4

llvm/test/CodeGen/DirectX/ForwardHandleAccesses/cbuffer-access.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
; RUN: opt -S -dxil-forward-handle-accesses -mtriple=dxil--shadermodel6.3-library %s | FileCheck %s
22

33
%__cblayout_CB = type <{ float, i32, i32 }>
4+
%__cblayout_CB2 = type <{ float }>
45
%struct.Scalars = type { float, i32, i32 }
56

67
@CB.cb = local_unnamed_addr global target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 12, 0, 4, 8)) poison
8+
@CB2.cb = local_unnamed_addr global target("dx.CBuffer", target("dx.Layout", %__cblayout_CB2, 4, 0)) poison
79

810
define void @main() local_unnamed_addr #1 {
911
entry:
@@ -17,6 +19,13 @@ entry:
1719
%0 = call { float, float, float, float } @llvm.dx.resource.load.cbufferrow.4(target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 12, 0, 4, 8)) %cb, i32 0)
1820
%1 = extractvalue { float, float, float, float } %0, 0
1921
call void @llvm.dx.resource.store.rawbuffer(target("dx.RawBuffer", %struct.Scalars, 1, 0) %_ZL3Out_h.i.i, i32 0, i32 0, float %1)
22+
23+
; CHECK: [[CB2:%.*]] = tail call target({{.*}}) @llvm.dx.resource.handlefromimplicitbinding
24+
%h2 = tail call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB2, 4, 0)) @llvm.dx.resource.handlefromimplicitbinding(i32 100, i32 0, i32 1, i32 0, i1 false, ptr null)
25+
store target("dx.CBuffer", target("dx.Layout", %__cblayout_CB2, 4, 0)) %h2, ptr @CB2.cb, align 4
26+
; CHECK-NOT: load target({{.*}}), ptr @CB2.cb
27+
%cb2 = load target("dx.CBuffer", target("dx.Layout", %__cblayout_CB2, 4, 0)), ptr @CB2.cb, align 4
28+
2029
ret void
2130
}
2231

0 commit comments

Comments
 (0)