summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-01-11 15:33:28 -0800
committerGitHub <noreply@github.com>2023-01-11 15:33:28 -0800
commita3ac6e71cbc922b7c941c45f23ee18a9fc274d1f (patch)
treeacf8c18601f124e9290494f8b379d2420369fc35 /source/slang/slang-ir.cpp
parent20262684bcbb707d16669b2670039df870b65ca8 (diff)
Make backward differentiation work with generics. (#2586)
* Make backward differentiation work with generics. * Fix. * Another fix. * More fix. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp8
1 files changed, 8 insertions, 0 deletions
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)