From a3ac6e71cbc922b7c941c45f23ee18a9fc274d1f Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 11 Jan 2023 15:33:28 -0800 Subject: Make backward differentiation work with generics. (#2586) * Make backward differentiation work with generics. * Fix. * Another fix. * More fix. Co-authored-by: Yong He --- source/slang/slang-ir.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index f37a7a1a0..b36a2ebec 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -2810,6 +2810,8 @@ namespace Slang IRBackwardDiffIntermediateContextType* IRBuilder::getBackwardDiffIntermediateContextType( IRInst* func) { + if (!func) + func = getVoidValue(); return (IRBackwardDiffIntermediateContextType*)getType( kIROp_BackwardDiffIntermediateContextType, 1, @@ -6260,6 +6262,8 @@ namespace Slang return type; } + void validateIRInstOperands(IRInst*); + void IRInst::replaceUsesWith(IRInst* other) { // Safety check: don't try to replace something with itself. @@ -6377,6 +6381,10 @@ namespace Slang this->prev = inPrev; this->next = inNext; this->parent = inParent; + +#if _DEBUG + validateIRInstOperands(this); +#endif } void IRInst::insertAfter(IRInst* other) -- cgit v1.2.3