diff options
| author | Yong He <yonghe@outlook.com> | 2022-06-23 12:41:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-23 12:41:05 -0700 |
| commit | 4aa6344f772d31c1f7b0676cbaf315104c4b30a2 (patch) | |
| tree | 5fe9ded4256691d1e84ca0d9e3f03693dc4105bf /source/slang/slang-ir-generics-lowering-context.cpp | |
| parent | 5bd366fa1d10b93d0460f7779fa24d1572c971ba (diff) | |
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 <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-generics-lowering-context.cpp')
| -rw-r--r-- | source/slang/slang-ir-generics-lowering-context.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
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<IRComInterfaceDecoration>() || type->getOp() == kIROp_ComPtrType) { @@ -309,9 +310,12 @@ namespace Slang case kIROp_lookup_interface_method: { auto lookupInterface = static_cast<IRLookupWitnessMethod*>(paramType); - auto interfaceType = cast<IRInterfaceType>(cast<IRWitnessTableType>( - lookupInterface->getWitnessTable()->getDataType())->getConformanceType()); - if (isBuiltin(interfaceType)) + auto witnessTableType = as<IRWitnessTableType>( + lookupInterface->getWitnessTable()->getDataType()); + if (!witnessTableType) + return (IRType*)paramType; + auto interfaceType = as<IRInterfaceType>(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. |
