summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-specialize-dispatch.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-09-06 16:08:48 -0700
committerGitHub <noreply@github.com>2022-09-06 16:08:48 -0700
commit9f3e83cf0d664c87a618edf08d834829178030e6 (patch)
treef0545822e4f37f18ec847166e6a00912c10251a1 /source/slang/slang-ir-specialize-dispatch.cpp
parent61ff1ba8459d70cbc887040c530b5ce1a125ec77 (diff)
Specialize and SSA in a loop + better diagnostics on dynamic dispatch failure (#2396)
* Report diagnostic when dynamic dispatch failed instead of crashing. * Specialize and SSA in a loop. Explicit specialization only interface. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-specialize-dispatch.cpp')
-rw-r--r--source/slang/slang-ir-specialize-dispatch.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/source/slang/slang-ir-specialize-dispatch.cpp b/source/slang/slang-ir-specialize-dispatch.cpp
index b6e9d2c45..88e2497be 100644
--- a/source/slang/slang-ir-specialize-dispatch.cpp
+++ b/source/slang/slang-ir-specialize-dispatch.cpp
@@ -91,7 +91,10 @@ IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext,
{
auto witnessTable = witnessTables[i];
auto seqIdDecoration = witnessTable->findDecoration<IRSequentialIDDecoration>();
- SLANG_ASSERT(seqIdDecoration);
+ if (!seqIdDecoration)
+ {
+ sharedContext->sink->diagnose(witnessTable->getConcreteType(), Diagnostics::typeCannotBeUsedInDynamicDispatch, witnessTable->getConcreteType());
+ }
if (i != witnessTables.getCount() - 1)
{
@@ -220,6 +223,15 @@ void ensureWitnessTableSequentialIDs(SharedGenericsLoweringContext* sharedContex
}
else
{
+ auto witnessTableType = as<IRWitnessTableType>(inst->getDataType());
+ if (witnessTableType && witnessTableType->getConformanceType()->findDecoration<IRSpecializeDecoration>())
+ {
+ // The interface is for specialization only, it would be an error if dynamic dispatch is used
+ // through the interface.
+ // Skip assigning ID for the witness table.
+ continue;
+ }
+
// If this witness table entry does not have a linkage,
// we need to check if it is transitively visible via
// associatedtypes from an existing witness table with linkage.