2
0
Эх сурвалжийг харах

PIX: Null check before dyn_cast (#3654) (#3660)

dbg.value can occasionally return a null value. (Hit this in a customer (343) shader via PIX.) This is expected. From IntrinsicInst.cpp:

  // When the value goes to null, it gets replaced by an empty MDNode.

Co-authored-by: Jeff Noyle <[email protected]>
Jeff Noyle 4 жил өмнө
parent
commit
1e84ea8226

+ 5 - 3
lib/DxilPIXPasses/PixPassHelpers.cpp

@@ -24,9 +24,11 @@ using namespace hlsl;
 
 
 namespace PIXPassHelpers {
 namespace PIXPassHelpers {
 bool IsAllocateRayQueryInstruction(llvm::Value *Val) {
 bool IsAllocateRayQueryInstruction(llvm::Value *Val) {
-  if (llvm::Instruction *Inst = llvm::dyn_cast<llvm::Instruction>(Val)) {
-    return hlsl::OP::IsDxilOpFuncCallInst(Inst,
-                                          hlsl::OP::OpCode::AllocateRayQuery);
+  if (Val != nullptr) {
+    if (llvm::Instruction *Inst = llvm::dyn_cast<llvm::Instruction>(Val)) {
+      return hlsl::OP::IsDxilOpFuncCallInst(Inst,
+                                            hlsl::OP::OpCode::AllocateRayQuery);
+    }
   }
   }
   return false;
   return false;
 }
 }