From 4aa6344f772d31c1f7b0676cbaf315104c4b30a2 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 23 Jun 2022 12:41:05 -0700 Subject: Preserve specialization cache in IR for specialization pass. (#2293) * Perserve specialization cache in IR for specialization pass. * Fix compile error. * Fix. * Fix. * Fix test case. * Fix. Co-authored-by: Yong He --- source/slang/slang-ir-generics-lowering-context.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-ir-generics-lowering-context.cpp') diff --git a/source/slang/slang-ir-generics-lowering-context.cpp b/source/slang/slang-ir-generics-lowering-context.cpp index e20b8b680..6377ef00e 100644 --- a/source/slang/slang-ir-generics-lowering-context.cpp +++ b/source/slang/slang-ir-generics-lowering-context.cpp @@ -38,6 +38,7 @@ namespace Slang bool isComInterfaceType(IRType* type) { + if (!type) return false; if (type->findDecoration() || type->getOp() == kIROp_ComPtrType) { @@ -309,9 +310,12 @@ namespace Slang case kIROp_lookup_interface_method: { auto lookupInterface = static_cast(paramType); - auto interfaceType = cast(cast( - lookupInterface->getWitnessTable()->getDataType())->getConformanceType()); - if (isBuiltin(interfaceType)) + auto witnessTableType = as( + lookupInterface->getWitnessTable()->getDataType()); + if (!witnessTableType) + return (IRType*)paramType; + auto interfaceType = as(witnessTableType->getConformanceType()); + if (!interfaceType || isBuiltin(interfaceType)) return (IRType*)paramType; // Make sure we are looking up inside the original interface type (prior to lowering). // Only in the original interface type will an associated type entry have an IRAssociatedType value. -- cgit v1.2.3