summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2024-11-12 19:46:45 +0200
committerGitHub <noreply@github.com>2024-11-12 09:46:45 -0800
commit567c7e09b6df36b535c4ffbccd6a3658d18e04c2 (patch)
treead29df049844bebf6127a6457baa9030677a697d
parentea04ad12110df6b958c117f5d92f45813316cd70 (diff)
Fix two specialization bugs (#5540)
* Fix two specialization bugs The first bug was introduced in b2ca2d5a4efeae807d3c3f48f60235e47413b559 and ran some code at scope exit that dereferenced a nullptr context. The second bug was introduced in bea1394ad35680940a0b69b9c67efc43764cc194 and would cause the wrong mangled name to be used during specialization. This closes #5516. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
-rw-r--r--source/slang/slang-ir-link.cpp9
-rw-r--r--source/slang/slang-ir-specialize.cpp2
2 files changed, 7 insertions, 4 deletions
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp
index a764db117..28bb63a87 100644
--- a/source/slang/slang-ir-link.cpp
+++ b/source/slang/slang-ir-link.cpp
@@ -873,6 +873,7 @@ static void maybeCopyLayoutInformationToParameters(IRFunc* func, IRBuilder* buil
IRFunc* specializeIRForEntryPoint(
IRSpecContext* context,
+ String const& mangledName,
EntryPoint* entryPoint,
UnownedStringSlice nameOverride)
{
@@ -886,7 +887,6 @@ IRFunc* specializeIRForEntryPoint(
// not the same as the mangled name of the decl.
//
RefPtr<IRSpecSymbol> sym;
- auto mangledName = entryPoint->getEntryPointMangledName(0);
if (!context->getSymbols().tryGetValue(mangledName, sym))
{
String hashedName = getHashedName(mangledName.getUnownedSlice());
@@ -1829,8 +1829,11 @@ LinkedIR linkIR(CodeGenContext* codeGenContext)
auto entryPointMangledName = program->getEntryPointMangledName(entryPointIndex);
auto nameOverride = program->getEntryPointNameOverride(entryPointIndex);
auto entryPoint = program->getEntryPoint(entryPointIndex).get();
- irEntryPoints.add(
- specializeIRForEntryPoint(context, entryPoint, nameOverride.getUnownedSlice()));
+ irEntryPoints.add(specializeIRForEntryPoint(
+ context,
+ entryPointMangledName,
+ entryPoint,
+ nameOverride.getUnownedSlice()));
}
// Layout information for global shader parameters is also required,
diff --git a/source/slang/slang-ir-specialize.cpp b/source/slang/slang-ir-specialize.cpp
index 81ad5ca2a..2757538a6 100644
--- a/source/slang/slang-ir-specialize.cpp
+++ b/source/slang/slang-ir-specialize.cpp
@@ -2979,7 +2979,7 @@ IRInst* specializeGenericImpl(
builder->setInsertBefore(genericVal);
List<IRInst*> pendingWorkList;
- SLANG_DEFER(for (Index ii = pendingWorkList.getCount() - 1; ii >= 0; ii--)
+ SLANG_DEFER(for (Index ii = pendingWorkList.getCount() - 1; ii >= 0; ii--) if (context)
context->addToWorkList(pendingWorkList[ii]););
// Now we will run through the body of the generic and