Skip to content

Commit 2a18dca

Browse files
author
Greg Roth
committed
Respond to sundry feedback
Format IntrinsicsDirectX.td Add todo comment about future work clean up test to remove unneeded elements and better name check prefixes
1 parent 5cc11c7 commit 2a18dca

File tree

3 files changed

+16
-61
lines changed

3 files changed

+16
-61
lines changed

llvm/include/llvm/IR/IntrinsicsDirectX.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ def int_dx_handle_fromBinding
2828
[IntrNoMem]>;
2929

3030
def int_dx_typedBufferLoad
31-
: DefaultAttrsIntrinsic<[llvm_any_ty], [llvm_any_ty, llvm_i32_ty], [IntrReadMem]>;
31+
: DefaultAttrsIntrinsic<[llvm_any_ty], [llvm_any_ty, llvm_i32_ty],
32+
[IntrReadMem]>;
3233
def int_dx_typedBufferLoad_checkbit
3334
: DefaultAttrsIntrinsic<[llvm_any_ty, llvm_i1_ty],
3435
[llvm_any_ty, llvm_i32_ty], [IntrReadMem]>;
3536
def int_dx_typedBufferStore
36-
: DefaultAttrsIntrinsic<[], [llvm_any_ty, llvm_i32_ty, llvm_anyvector_ty], [IntrWriteMem]>;
37+
: DefaultAttrsIntrinsic<[], [llvm_any_ty, llvm_i32_ty, llvm_anyvector_ty],
38+
[IntrWriteMem]>;
3739

3840
// Cast between target extension handle types and dxil-style opaque handles
3941
def int_dx_cast_handle : Intrinsic<[llvm_any_ty], [llvm_any_ty]>;

llvm/lib/Target/DirectX/DXILOpLowering.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ class OpLowerer {
206206

207207
// Remove the resource global associated with the handleFromBinding call
208208
// instruction and their uses as they aren't needed anymore.
209+
// TODO: We should verify that all the globals get removed.
210+
// It's expected we'll need a custom pass in the future that will eliminate
211+
// the need for this here.
209212
void removeResourceGlobals(CallInst *CI) {
210213
for (User *User : make_early_inc_range(CI->users())) {
211214
if (StoreInst *Store = dyn_cast<StoreInst>(User)) {
Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
; RUN: opt -S -passes='early-cse<memssa>' %s -o %t
22
; RUN: FileCheck --check-prefixes=CSE,CHECK %s < %t
3-
; finish compiling to verify that dxil-op-lower removes the globals entirely
4-
; RUN: opt -S -dxil-op-lower %t -o - | FileCheck --check-prefixes=LLC,CHECK %s
5-
; RUN: llc -mtriple=dxil-pc-shadermodel6.0-compute --filetype=asm -o - %t | FileCheck --check-prefixes=LLC,CHECK %s
6-
; RUN: llc -mtriple=dxil-pc-shadermodel6.6-compute --filetype=asm -o - %t | FileCheck --check-prefixes=LLC,CHECK %s
3+
; Finish compiling to verify that dxil-op-lower removes the globals entirely.
4+
; RUN: opt -mtriple=dxil-pc-shadermodel6.0-compute -S -dxil-op-lower %t -o - | FileCheck --check-prefixes=DXOP,CHECK %s
5+
; RUN: opt -mtriple=dxil-pc-shadermodel6.6-compute -S -dxil-op-lower %t -o - | FileCheck --check-prefixes=DXOP,CHECK %s
6+
; RUN: llc -mtriple=dxil-pc-shadermodel6.0-compute --filetype=asm -o - %t | FileCheck --check-prefixes=DXOP,CHECK %s
7+
; RUN: llc -mtriple=dxil-pc-shadermodel6.6-compute --filetype=asm -o - %t | FileCheck --check-prefixes=DXOP,CHECK %s
78

89
; Ensure that EarlyCSE is able to eliminate unneeded loads of resource globals across typedBufferLoad.
910
; Also that DXILOpLowering eliminates the globals entirely.
1011

11-
target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
12-
target triple = "dxilv1.6-unknown-shadermodel6.6-compute"
13-
1412
%"class.hlsl::RWBuffer" = type { target("dx.TypedBuffer", <4 x float>, 1, 0, 0) }
1513

16-
; LLC-NOT: @In = global
17-
; LLC-NOT: @Out = global
14+
; DXOP-NOT: @In = global
15+
; DXOP-NOT: @Out = global
1816
@In = global %"class.hlsl::RWBuffer" zeroinitializer, align 4
1917
@Out = global %"class.hlsl::RWBuffer" zeroinitializer, align 4
2018

21-
; Function Attrs: convergent noinline norecurse
2219
; CHECK-LABEL define void @main()
2320
define void @main() local_unnamed_addr #0 {
2421
entry:
25-
; LLC: %In_h.i1 = call %dx.types.Handle @dx.op.createHandle
26-
; LLC: %Out_h.i2 = call %dx.types.Handle @dx.op.createHandle
22+
; DXOP: %In_h.i1 = call %dx.types.Handle @dx.op.createHandle
23+
; DXOP: %Out_h.i2 = call %dx.types.Handle @dx.op.createHandle
2724
%In_h.i = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0) @llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_1_0_0t(i32 0, i32 0, i32 1, i32 0, i1 false)
2825
store target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %In_h.i, ptr @In, align 4
2926
%Out_h.i = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0) @llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_1_0_0t(i32 4, i32 1, i32 1, i32 0, i1 false)
@@ -43,52 +40,5 @@ entry:
4340
ret void
4441
}
4542

46-
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
47-
declare i32 @llvm.dx.flattened.thread.id.in.group() #1
48-
49-
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
50-
; CSE: declare <4 x float> @llvm.dx.typedBufferLoad.v4f32.tdx.TypedBuffer_v4f32_1_0_0t(target("dx.TypedBuffer", <4 x float>, 1, 0, 0), i32) [[ROAttr:#[0-9]+]]
51-
declare <4 x float> @llvm.dx.typedBufferLoad.v4f32.tdx.TypedBuffer_v4f32_1_0_0t(target("dx.TypedBuffer", <4 x float>, 1, 0, 0), i32) #2
52-
53-
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
54-
; CSE: declare void @llvm.dx.typedBufferStore.tdx.TypedBuffer_v4f32_1_0_0t.v4f32(target("dx.TypedBuffer", <4 x float>, 1, 0, 0), i32, <4 x float>) [[WOAttr:#[0-9]+]]
55-
declare void @llvm.dx.typedBufferStore.tdx.TypedBuffer_v4f32_1_0_0t.v4f32(target("dx.TypedBuffer", <4 x float>, 1, 0, 0), i32, <4 x float>) #2
56-
57-
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none)
58-
declare target("dx.TypedBuffer", <4 x float>, 1, 0, 0) @llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_1_0_0t(i32, i32, i32, i32, i1) #3
59-
60-
; CSE: attributes [[ROAttr]] = { {{.*}} memory(read) }
61-
; CSE: attributes [[WOAttr]] = { {{.*}} memory(write) }
62-
6343
attributes #0 = { convergent noinline norecurse "frame-pointer"="all" "hlsl.numthreads"="8,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
64-
attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) }
65-
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn }
66-
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(none) }
67-
68-
!llvm.module.flags = !{!0, !1}
69-
!dx.valver = !{!2}
70-
!llvm.ident = !{!3}
7144

72-
!0 = !{i32 1, !"wchar_size", i32 4}
73-
!1 = !{i32 7, !"frame-pointer", i32 2}
74-
!2 = !{i32 1, i32 8}
75-
!3 = !{!"clang version 20.0.0git ([email protected]:llvm/llvm-project.git 54dc966bd3d375d7c1604fac5fdac20989c1072a)"}
76-
!4 = !{!5}
77-
!5 = distinct !{!5, !6, !"_ZN4hlsl8RWBufferIDv4_fEixEi: %agg.result"}
78-
!6 = distinct !{!6, !"_ZN4hlsl8RWBufferIDv4_fEixEi"}
79-
!7 = !{!8, !9, i64 0}
80-
!8 = !{!"_ZTSN4hlsl8RWBufferIDv4_fEE", !9, i64 0}
81-
!9 = !{!"omnipotent char", !10, i64 0}
82-
!10 = !{!"Simple C++ TBAA"}
83-
!11 = !{!12}
84-
!12 = distinct !{!12, !13, !"_ZN4hlsl8RWBufferIDv4_fEixEi: %agg.result"}
85-
!13 = distinct !{!13, !"_ZN4hlsl8RWBufferIDv4_fEixEi"}
86-
!14 = !{!15}
87-
!15 = distinct !{!15, !16, !"_ZN4hlsl8RWBufferIDv4_fEixEi: %agg.result"}
88-
!16 = distinct !{!16, !"_ZN4hlsl8RWBufferIDv4_fEixEi"}
89-
!17 = !{!18, !9, i64 0}
90-
!18 = !{!"_ZTSN4hlsl8__detail18TypedResourceProxyIU9_Res_u_CTDv4_fu17__hlsl_resource_tS2_EE", !9, i64 0, !19, i64 4}
91-
!19 = !{!"int", !9, i64 0}
92-
!20 = !{!21}
93-
!21 = distinct !{!21, !22, !"_ZN4hlsl8__detail18TypedResourceProxyIU9_Res_u_CTDv4_fu17__hlsl_resource_tS2_EaSES2_: %agg.result"}
94-
!22 = distinct !{!22, !"_ZN4hlsl8__detail18TypedResourceProxyIU9_Res_u_CTDv4_fu17__hlsl_resource_tS2_EaSES2_"}

0 commit comments

Comments
 (0)