Browse Source

Fix SROA of RayQuery alloca, update test

Skip RayQuery alloca for SROA_HLSL, but don't treat as HLSLObjectType elsewhere
Tex Riddell 6 years ago
parent
commit
02d4ba3095

+ 0 - 3
lib/DXIL/DxilUtil.cpp

@@ -557,9 +557,6 @@ bool IsHLSLObjectType(llvm::Type *Ty) {
       return true;
     if (name.startswith("LineStream<"))
       return true;
-
-    if (name.startswith("RayQuery<"))
-      return true;
   }
   return false;
 }

+ 2 - 2
lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp

@@ -2721,8 +2721,8 @@ bool SROA_Helper::DoScalarReplacement(Value *V, std::vector<Value *> &Elts,
   IRBuilder<> AllocaBuilder(dxilutil::FindAllocaInsertionPt(Builder.GetInsertPoint()));
 
   if (StructType *ST = dyn_cast<StructType>(Ty)) {
-    // Skip HLSL object types.
-    if (dxilutil::IsHLSLObjectType(ST)) {
+    // Skip HLSL object types and RayQuery.
+    if (dxilutil::IsHLSLObjectType(ST) || dxilutil::IsHLSLRayQueryType(ST)) {
       return false;
     }
 

+ 2 - 3
tools/clang/test/CodeGenHLSL/batch/shader_stages/raytracing/rayquery/tryAllOps.hlsl

@@ -1,12 +1,11 @@
-// RUN: %dxc -T cs_6_5 -E CS %s
-// TODO: Eliminate ray query handle alloca and phis, then add: | FileCheck %s
+// RUN: %dxc -T cs_6_5 -E CS %s | FileCheck %s
 
 // CHECK: define void @CS()
 
 // RayQuery alloca should have been dead-code eliminated
 // CHECK-NOT: alloca
 
-// %[[hAccelerationStructure:[^ ]+]] = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 0, i32 0, i1 false)
+// CHECK: %[[hAccelerationStructure:[^ ]+]] = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 0, i32 0, i1 false)
 // CHECK: %[[hRayQuery:[^ ]+]] = call i32 @dx.op.allocateRayQuery(i32 178, i32 5)
 // CHECK: call void @dx.op.rayQuery_TraceRayInline(i32 179, i32 %[[hRayQuery]], %dx.types.Handle %[[hAccelerationStructure]], i32 0, i32 255, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 9.999000e+03)
 // CHECK: call i1 @dx.op.rayQuery_Proceed.i1(i32 180, i32 %[[hRayQuery]])