From 4ad0470025da4e808c46023f9a2525febcf973a2 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 23 Nov 2022 16:02:56 -0800 Subject: Fix issues around dynamic generic function and autodiff. (#2528) * Fix issues around dynamic generic function and autodiff. * Fix return type issue. * Fix type unification for generic `inout` parameter. * Fix. Co-authored-by: Yong He --- source/slang/slang-lower-to-ir.cpp | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) (limited to 'source/slang/slang-lower-to-ir.cpp') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index a0becdafa..09dacc20d 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -6863,14 +6863,6 @@ struct DeclLoweringVisitor : DeclVisitor { operandCount += associatedTypeDecl->getMembersOfType().getCount(); } - else if (auto callableDecl = as(requirementDecl)) - { - // Differentiable functions has additional requirements for the derivatives. - if (callableDecl->getMembersOfType().getCount()) - operandCount++; - if (callableDecl->getMembersOfType().getCount()) - operandCount++; - } } // Allocate an IRInterfaceType with the `operandCount` operands. @@ -6957,33 +6949,10 @@ struct DeclLoweringVisitor : DeclVisitor if (auto callableDecl = as(requirementDecl)) { // Differentiable functions has additional requirements for the derivatives. - for (auto diffDecl : callableDecl->getMembersOfType()) + for (auto diffDecl : callableDecl->getMembersOfType()) { - auto diffKey = getInterfaceRequirementKey(diffDecl); - IRInst* diffVal = ensureDecl(subContext, diffDecl).val; - auto diffEntry = subBuilder->createInterfaceRequirementEntry(diffKey, diffVal); - if (diffVal) - { - switch (diffVal->getOp()) - { - case kIROp_Func: - case kIROp_Generic: - { - // Remove lowered `IRFunc`s since we only care about - // function types. - auto reqType = diffVal->getFullType(); - diffEntry->setRequirementVal(reqType); - break; - } - default: - break; - } - } - irInterface->setOperand(entryIndex, diffEntry); - entryIndex++; - - setValue(context, diffDecl, LoweredValInfo::simple(diffEntry)); - insertRequirementKeyAssociation(irInterface, diffDecl, requirementKey, diffKey); + auto diffKey = getInterfaceRequirementKey(diffDecl->referencedDecl); + insertRequirementKeyAssociation(irInterface, diffDecl->referencedDecl, requirementKey, diffKey); } } // Add lowered requirement entry to current decl mapping to prevent -- cgit v1.2.3