|
| 1 | +; RUN: %dxopt %s -hlsl-passes-resume -scalarrepl-param-hlsl -S | FileCheck %s |
| 2 | + |
| 3 | +; COM: Based on tools/clang/test/CodeGenDXIL/hlsl/objects/HitObject/hitobject_traceinvoke.hlsl |
| 4 | + |
| 5 | +; CHECK: %[[HITOBJ:[^ ]+]] = alloca %dx.types.HitObject, align 4 |
| 6 | + |
| 7 | +; COM: Init RayDesc. |
| 8 | +; CHECK-DAG: store <3 x float> <float 0.000000e+00, float 1.000000e+00, float 2.000000e+00>, <3 x float>* %[[ORIGIN_P0:[^ ]+]], align 4 |
| 9 | +; CHECK-DAG: store float 3.000000e+00, float* %[[TMIN_P0:[^ ]+]], align 4 |
| 10 | +; CHECK-DAG: store <3 x float> <float 4.000000e+00, float 5.000000e+00, float 6.000000e+00>, <3 x float>* %[[DIRECTION_P0:[^ ]+]], align 4 |
| 11 | +; CHECK-DAG: store float 7.000000e+00, float* %[[TMAX_P0:[^ ]+]], align 4 |
| 12 | + |
| 13 | +; CHECK-DAG: %[[RTAS:[^ ]+]] = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure)"(i32 14, %dx.types.Handle %{{[^ ]+}}, %dx.types.ResourceProperties { i32 16, i32 0 }, %struct.RaytracingAccelerationStructure undef) |
| 14 | + |
| 15 | +; COM: Copy RayDesc. |
| 16 | +; CHECK-DAG: %[[ORIGIN_L0:[^ ]+]] = load <3 x float>, <3 x float>* %[[ORIGIN_P0]] |
| 17 | +; CHECK-DAG: store <3 x float> %[[ORIGIN_L0]], <3 x float>* %[[ORIGIN_P1:[^ ]+]] |
| 18 | +; CHECK-DAG: %[[TMIN_L0:[^ ]+]] = load float, float* %[[TMIN_P0]] |
| 19 | +; CHECK-DAG: store float %[[TMIN_L0]], float* %[[TMIN_P1:[^ ]+]] |
| 20 | +; CHECK-DAG: %[[DIRECTION_L0:[^ ]+]] = load <3 x float>, <3 x float>* %[[DIRECTION_P0]] |
| 21 | +; CHECK-DAG: store <3 x float> %[[DIRECTION_L0]], <3 x float>* %[[DIRECTION_P1:[^ ]+]] |
| 22 | +; CHECK-DAG: %[[TMAX_L0:[^ ]+]] = load float, float* %[[TMAX_P0]] |
| 23 | +; CHECK-DAG: store float %[[TMAX_L0]], float* %[[TMAX_P1:[^ ]+]] |
| 24 | + |
| 25 | +; COM: Load RayDesc. |
| 26 | +; CHECK-DAG: %[[ORIGIN_L1:[^ ]+]] = load <3 x float>, <3 x float>* %[[ORIGIN_P1]] |
| 27 | +; CHECK-DAG: %[[TMIN_L1:[^ ]+]] = load float, float* %[[TMIN_P1]] |
| 28 | +; CHECK-DAG: %[[DIRECTION_L1:[^ ]+]] = load <3 x float>, <3 x float>* %[[DIRECTION_P1]] |
| 29 | +; CHECK-DAG: %[[TMAX_L1:[^ ]+]] = load float, float* %[[TMAX_P1]] |
| 30 | + |
| 31 | +; COM: RayDesc is scalar replaced in HL op for dx::HitObject::TraceRay. |
| 32 | +; CHECK: call void @"dx.hl.op..void (i32, %dx.types.HitObject*, %dx.types.Handle, i32, i32, i32, i32, i32, <3 x float>, float, <3 x float>, float, %struct.Payload*)"(i32 389, %dx.types.HitObject* %[[HITOBJ]], %dx.types.Handle %[[RTAS]], i32 513, i32 1, i32 2, i32 4, i32 0, <3 x float> %[[ORIGIN_L1]], float %[[TMIN_L1]], <3 x float> %[[DIRECTION_L1]], float %[[TMAX_L1]], %struct.Payload* %[[PLD_P0:[^ ]+]]) |
| 33 | + |
| 34 | +; COM: Copy payload. |
| 35 | +; CHECK: %[[GEP_PLD_P0:[^ ]+]] = getelementptr inbounds %struct.Payload, %struct.Payload* %[[PLD_P0]], i32 0, i32 0 |
| 36 | +; CHECK: %[[PLD_L0:[^ ]+]] = load <3 x float>, <3 x float>* %[[GEP_PLD_P0]] |
| 37 | +; CHECK: store <3 x float> %[[PLD_L0]], <3 x float>* %[[PLD_M0_P0:[^ ]+]] |
| 38 | +; CHECK: %[[GEP_PLD_P1:[^ ]+]] = getelementptr inbounds %struct.Payload, %struct.Payload* %[[PLD_P1:[^ ]+]], i32 0, i32 0 |
| 39 | +; CHECK: [[PLD_L1:[^ ]+]] = load <3 x float>, <3 x float>* %[[PLD_M0_P0]] |
| 40 | +; CHECK: store <3 x float> [[PLD_L1]], <3 x float>* %[[GEP_PLD_P1]] |
| 41 | + |
| 42 | +; COM: dx::HitObject::Invoke |
| 43 | +; CHECK: call void @"dx.hl.op..void (i32, %dx.types.HitObject*, %struct.Payload*)"(i32 382, %dx.types.HitObject* %[[HITOBJ]], %struct.Payload* %[[PLD_P1]]) |
| 44 | + |
| 45 | + |
| 46 | +target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64" |
| 47 | +target triple = "dxil-ms-dx" |
| 48 | + |
| 49 | +%struct.RaytracingAccelerationStructure = type { i32 } |
| 50 | +%"class.RWStructuredBuffer<float>" = type { float } |
| 51 | +%ConstantBuffer = type opaque |
| 52 | +%struct.RayDesc = type { <3 x float>, float, <3 x float>, float } |
| 53 | +%struct.Payload = type { <3 x float> } |
| 54 | +%dx.types.HitObject = type { i8* } |
| 55 | +%dx.types.Handle = type { i8* } |
| 56 | +%dx.types.ResourceProperties = type { i32, i32 } |
| 57 | +%"class.dx::HitObject" = type { i32 } |
| 58 | + |
| 59 | +@"\01?RTAS@@3URaytracingAccelerationStructure@@A" = external global %struct.RaytracingAccelerationStructure, align 4 |
| 60 | +@"\01?UAV@@3V?$RWStructuredBuffer@M@@A" = external global %"class.RWStructuredBuffer<float>", align 4 |
| 61 | +@"$Globals" = external constant %ConstantBuffer |
| 62 | + |
| 63 | +; Function Attrs: nounwind |
| 64 | +define void @"\01?main@@YAXXZ"() #0 { |
| 65 | +entry: |
| 66 | + %rayDesc = alloca %struct.RayDesc, align 4 |
| 67 | + %pld = alloca %struct.Payload, align 4 |
| 68 | + %hit = alloca %dx.types.HitObject, align 4 |
| 69 | + %0 = bitcast %struct.RayDesc* %rayDesc to i8*, !dbg !37 ; line:82 col:3 |
| 70 | + call void @llvm.lifetime.start(i64 32, i8* %0) #0, !dbg !37 ; line:82 col:3 |
| 71 | + |
| 72 | + ; COM: Init RayDesc. |
| 73 | + %Origin = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %rayDesc, i32 0, i32 0, !dbg !41 ; line:83 col:11 |
| 74 | + store <3 x float> <float 0.000000e+00, float 1.000000e+00, float 2.000000e+00>, <3 x float>* %Origin, align 4, !dbg !42, !tbaa !43 ; line:83 col:18 |
| 75 | + %TMin = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %rayDesc, i32 0, i32 1, !dbg !46 ; line:84 col:11 |
| 76 | + store float 3.000000e+00, float* %TMin, align 4, !dbg !47, !tbaa !48 ; line:84 col:16 |
| 77 | + %Direction = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %rayDesc, i32 0, i32 2, !dbg !50 ; line:85 col:11 |
| 78 | + store <3 x float> <float 4.000000e+00, float 5.000000e+00, float 6.000000e+00>, <3 x float>* %Direction, align 4, !dbg !51, !tbaa !43 ; line:85 col:21 |
| 79 | + %TMax = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %rayDesc, i32 0, i32 3, !dbg !52 ; line:86 col:11 |
| 80 | + store float 7.000000e+00, float* %TMax, align 4, !dbg !53, !tbaa !48 ; line:86 col:16 |
| 81 | + |
| 82 | + %1 = bitcast %struct.Payload* %pld to i8*, !dbg !54 ; line:88 col:3 |
| 83 | + call void @llvm.lifetime.start(i64 12, i8* %1) #0, !dbg !54 ; line:88 col:3 |
| 84 | + %dummy = getelementptr inbounds %struct.Payload, %struct.Payload* %pld, i32 0, i32 0, !dbg !55 ; line:89 col:7 |
| 85 | + store <3 x float> <float 7.000000e+00, float 8.000000e+00, float 9.000000e+00>, <3 x float>* %dummy, align 4, !dbg !56, !tbaa !43 ; line:89 col:13 |
| 86 | + %2 = bitcast %dx.types.HitObject* %hit to i8*, !dbg !57 ; line:91 col:3 |
| 87 | + call void @llvm.lifetime.start(i64 4, i8* %2) #0, !dbg !57 ; line:91 col:3 |
| 88 | + %3 = load %struct.RaytracingAccelerationStructure, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !dbg !58 ; line:91 col:23 |
| 89 | + %4 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32 0, %struct.RaytracingAccelerationStructure %3), !dbg !58 ; line:91 col:23 |
| 90 | + %5 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure)"(i32 14, %dx.types.Handle %4, %dx.types.ResourceProperties { i32 16, i32 0 }, %struct.RaytracingAccelerationStructure undef), !dbg !58 ; line:91 col:23 |
| 91 | + |
| 92 | + ; COM: dx::HitObject::TraceRay |
| 93 | + call void @"dx.hl.op..void (i32, %dx.types.HitObject*, %dx.types.Handle, i32, i32, i32, i32, i32, %struct.RayDesc*, %struct.Payload*)"(i32 389, %dx.types.HitObject* %hit, %dx.types.Handle %5, i32 513, i32 1, i32 2, i32 4, i32 0, %struct.RayDesc* %rayDesc, %struct.Payload* %pld), !dbg !58 ; line:91 col:23 |
| 94 | + |
| 95 | + ; COM: dx::HitObject::Invoke |
| 96 | + call void @"dx.hl.op..void (i32, %dx.types.HitObject*, %struct.Payload*)"(i32 382, %dx.types.HitObject* %hit, %struct.Payload* %pld), !dbg !59 ; line:101 col:3 |
| 97 | + |
| 98 | + %6 = bitcast %dx.types.HitObject* %hit to i8*, !dbg !60 ; line:102 col:1 |
| 99 | + call void @llvm.lifetime.end(i64 4, i8* %6) #0, !dbg !60 ; line:102 col:1 |
| 100 | + %7 = bitcast %struct.Payload* %pld to i8*, !dbg !60 ; line:102 col:1 |
| 101 | + call void @llvm.lifetime.end(i64 12, i8* %7) #0, !dbg !60 ; line:102 col:1 |
| 102 | + %8 = bitcast %struct.RayDesc* %rayDesc to i8*, !dbg !60 ; line:102 col:1 |
| 103 | + call void @llvm.lifetime.end(i64 32, i8* %8) #0, !dbg !60 ; line:102 col:1 |
| 104 | + ret void, !dbg !60 ; line:102 col:1 |
| 105 | +} |
| 106 | + |
| 107 | +; Function Attrs: nounwind |
| 108 | +declare void @llvm.lifetime.start(i64, i8* nocapture) #0 |
| 109 | + |
| 110 | +; Function Attrs: nounwind |
| 111 | +declare void @llvm.lifetime.end(i64, i8* nocapture) #0 |
| 112 | + |
| 113 | +; Function Attrs: nounwind |
| 114 | +declare void @"dx.hl.op..void (i32, %dx.types.HitObject*, %dx.types.Handle, i32, i32, i32, i32, i32, %struct.RayDesc*, %struct.Payload*)"(i32, %dx.types.HitObject*, %dx.types.Handle, i32, i32, i32, i32, i32, %struct.RayDesc*, %struct.Payload*) #0 |
| 115 | + |
| 116 | +; Function Attrs: nounwind readnone |
| 117 | +declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32, %struct.RaytracingAccelerationStructure) #1 |
| 118 | + |
| 119 | +; Function Attrs: nounwind readnone |
| 120 | +declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure) #1 |
| 121 | + |
| 122 | +; Function Attrs: nounwind |
| 123 | +declare void @"dx.hl.op..void (i32, %dx.types.HitObject*, %struct.Payload*)"(i32, %dx.types.HitObject*, %struct.Payload*) #0 |
| 124 | + |
| 125 | +attributes #0 = { nounwind } |
| 126 | +attributes #1 = { nounwind readnone } |
| 127 | + |
| 128 | +!llvm.module.flags = !{!0} |
| 129 | +!pauseresume = !{!1} |
| 130 | +!llvm.ident = !{!2} |
| 131 | +!dx.version = !{!3} |
| 132 | +!dx.valver = !{!3} |
| 133 | +!dx.shaderModel = !{!4} |
| 134 | +!dx.typeAnnotations = !{!5, !20} |
| 135 | +!dx.entryPoints = !{!24} |
| 136 | +!dx.fnprops = !{!34} |
| 137 | +!dx.options = !{!35, !36} |
| 138 | + |
| 139 | +!0 = !{i32 2, !"Debug Info Version", i32 3} |
| 140 | +!1 = !{!"hlsl-hlemit", !"hlsl-hlensure"} |
| 141 | +!2 = !{!"dxc(private) 1.8.0.4928 (ser_hlslattributes_patch, 937c16cc6)"} |
| 142 | +!3 = !{i32 1, i32 9} |
| 143 | +!4 = !{!"lib", i32 6, i32 9} |
| 144 | +!5 = !{i32 0, %"class.RWStructuredBuffer<float>" undef, !6, %struct.RayDesc undef, !11, %struct.Payload undef, !16, %"class.dx::HitObject" undef, !18} |
| 145 | +!6 = !{i32 4, !7, !8} |
| 146 | +!7 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 9} |
| 147 | +!8 = !{i32 0, !9} |
| 148 | +!9 = !{!10} |
| 149 | +!10 = !{i32 0, float undef} |
| 150 | +!11 = !{i32 32, !12, !13, !14, !15} |
| 151 | +!12 = !{i32 6, !"Origin", i32 3, i32 0, i32 7, i32 9, i32 13, i32 3} |
| 152 | +!13 = !{i32 6, !"TMin", i32 3, i32 12, i32 7, i32 9} |
| 153 | +!14 = !{i32 6, !"Direction", i32 3, i32 16, i32 7, i32 9, i32 13, i32 3} |
| 154 | +!15 = !{i32 6, !"TMax", i32 3, i32 28, i32 7, i32 9} |
| 155 | +!16 = !{i32 12, !17} |
| 156 | +!17 = !{i32 6, !"dummy", i32 3, i32 0, i32 7, i32 9, i32 13, i32 3} |
| 157 | +!18 = !{i32 4, !19} |
| 158 | +!19 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 4} |
| 159 | +!20 = !{i32 1, void ()* @"\01?main@@YAXXZ", !21} |
| 160 | +!21 = !{!22} |
| 161 | +!22 = !{i32 1, !23, !23} |
| 162 | +!23 = !{} |
| 163 | +!24 = !{null, !"", null, !25, null} |
| 164 | +!25 = !{!26, !29, !32, null} |
| 165 | +!26 = !{!27} |
| 166 | +!27 = !{i32 0, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !"RTAS", i32 -1, i32 -1, i32 1, i32 16, i32 0, !28} |
| 167 | +!28 = !{i32 0, i32 4} |
| 168 | +!29 = !{!30} |
| 169 | +!30 = !{i32 0, %"class.RWStructuredBuffer<float>"* @"\01?UAV@@3V?$RWStructuredBuffer@M@@A", !"UAV", i32 0, i32 0, i32 1, i32 12, i1 false, i1 false, i1 false, !31} |
| 170 | +!31 = !{i32 1, i32 4} |
| 171 | +!32 = !{!33} |
| 172 | +!33 = !{i32 0, %ConstantBuffer* @"$Globals", !"$Globals", i32 0, i32 -1, i32 1, i32 0, null} |
| 173 | +!34 = !{void ()* @"\01?main@@YAXXZ", i32 7} |
| 174 | +!35 = !{i32 -2147483584} |
| 175 | +!36 = !{i32 -1} |
| 176 | +!37 = !DILocation(line: 82, column: 3, scope: !38) |
| 177 | +!38 = !DISubprogram(name: "main", scope: !39, file: !39, line: 81, type: !40, isLocal: false, isDefinition: true, scopeLine: 81, flags: DIFlagPrototyped, isOptimized: false, function: void ()* @"\01?main@@YAXXZ") |
| 178 | +!39 = !DIFile(filename: "D:\5Cgit\5Cdxc\5Cmain\5Ctools\5Cclang\5Ctest\5CCodeGenDXIL\5Chlsl\5Cobjects\5CHitObject\5Chitobject_traceinvoke.hlsl", directory: "") |
| 179 | +!40 = !DISubroutineType(types: !23) |
| 180 | +!41 = !DILocation(line: 83, column: 11, scope: !38) |
| 181 | +!42 = !DILocation(line: 83, column: 18, scope: !38) |
| 182 | +!43 = !{!44, !44, i64 0} |
| 183 | +!44 = !{!"omnipotent char", !45, i64 0} |
| 184 | +!45 = !{!"Simple C/C++ TBAA"} |
| 185 | +!46 = !DILocation(line: 84, column: 11, scope: !38) |
| 186 | +!47 = !DILocation(line: 84, column: 16, scope: !38) |
| 187 | +!48 = !{!49, !49, i64 0} |
| 188 | +!49 = !{!"float", !44, i64 0} |
| 189 | +!50 = !DILocation(line: 85, column: 11, scope: !38) |
| 190 | +!51 = !DILocation(line: 85, column: 21, scope: !38) |
| 191 | +!52 = !DILocation(line: 86, column: 11, scope: !38) |
| 192 | +!53 = !DILocation(line: 86, column: 16, scope: !38) |
| 193 | +!54 = !DILocation(line: 88, column: 3, scope: !38) |
| 194 | +!55 = !DILocation(line: 89, column: 7, scope: !38) |
| 195 | +!56 = !DILocation(line: 89, column: 13, scope: !38) |
| 196 | +!57 = !DILocation(line: 91, column: 3, scope: !38) |
| 197 | +!58 = !DILocation(line: 91, column: 23, scope: !38) |
| 198 | +!59 = !DILocation(line: 101, column: 3, scope: !38) |
| 199 | +!60 = !DILocation(line: 102, column: 1, scope: !38) |
0 commit comments