diff options
| author | Yong He <yonghe@outlook.com> | 2025-07-01 19:09:29 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-02 02:09:29 +0000 |
| commit | c701ec00ccce6dfa8094d6550ce2db929fc8cefe (patch) | |
| tree | 4f729e8fa5700b2d6d7d99f34514682e3ad351f8 /source/slang/slang-ir-specialize-function-call.cpp | |
| parent | 83c72fd8772d312233f4e3ccd4154b81030d4795 (diff) | |
Defer immutable buffer loads when emitting spirv. (#7579)
* Defer immutable buffer loads when emitting spirv.
* Fix.
* Fix.
* Fix.
* Fix tests.
* Fix test.
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 |
