diff options
Diffstat (limited to 'source/slang/slang-ir-specialize-function-call.cpp')
| -rw-r--r-- | source/slang/slang-ir-specialize-function-call.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/source/slang/slang-ir-specialize-function-call.cpp b/source/slang/slang-ir-specialize-function-call.cpp index 7a9fc5f6f..c03e644de 100644 --- a/source/slang/slang-ir-specialize-function-call.cpp +++ b/source/slang/slang-ir-specialize-function-call.cpp @@ -338,7 +338,9 @@ struct FunctionParameterSpecializationContext // correctly check the preconditions. // auto oldFunc = as<IRFunc>(oldCall->getCallee()); - SLANG_ASSERT(oldFunc); + if (!oldFunc) + return; + SLANG_ASSERT(oldFunc->isDefinition()); // Our first information-gathering pass will @@ -390,6 +392,14 @@ struct FunctionParameterSpecializationContext newCall->insertBefore(oldCall); oldCall->replaceUsesWith(newCall); oldCall->removeAndDeallocate(); + + // If old func is no longer used after the specialization, + // remove it. + if (!oldFunc->hasUses()) + { + if (!shouldInstBeLiveIfParentIsLive(oldFunc, IRDeadCodeEliminationOptions{})) + oldFunc->removeAndDeallocate(); + } } // Before diving into the details on how we gather information |
