summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-09-04 19:57:06 -0400
committerGitHub <noreply@github.com>2024-09-04 19:57:06 -0400
commitdc3f2d65848837afaf528beefc305534a29540c8 (patch)
tree8fefbf991f7ff1b33a13cfaddbecc1df38d07ea8 /source
parent599dae52e85d2a86bf3cae1ebd0883fedf44a76e (diff)
Fix resource specialization with `-embed-dxil` (#4990)
* Fix resource specialization with `-embed-dxil` fixes: #4989 Changes: 1. Before handing off to DCE an `oldFunc` which should be removed, clean up any leftover `IRKeepAliveDecoration` (else DCE won't remove our `oldFunc`s)
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-specialize-resources.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/source/slang/slang-ir-specialize-resources.cpp b/source/slang/slang-ir-specialize-resources.cpp
index 5e15098d4..90e3f99a0 100644
--- a/source/slang/slang-ir-specialize-resources.cpp
+++ b/source/slang/slang-ir-specialize-resources.cpp
@@ -248,7 +248,11 @@ struct ResourceOutputSpecializationPass
newFunc->removeAndDeallocate();
// Check if `oldFunc` is the reason for failing,
// Otherwise don't add to 'unspecializableFuncs'
- if(result == SpecializeFuncResult::ThisFuncFailed)
+ //
+ // Ensure oldFunc has uses, else, there is nothing to specialize here.
+ // If oldFunc has IRKeepAlive, this code should be assumed to have a
+ // "dynamic" resource value.
+ if(result == SpecializeFuncResult::ThisFuncFailed && oldFunc->hasUses())
unspecializableFuncs->add(oldFunc);
return false;
}
@@ -315,6 +319,11 @@ struct ResourceOutputSpecializationPass
specializeCallSite(oldCall, newFunc, funcInfo);
}
specializedFuncs.add(oldFunc);
+
+ // Since we can no longer fail and we are replacing all `Func` uses, 'KeepAlive'
+ // can be removed from the oldFunc so DCE can it clean-up.
+ if(auto keepAliveDecoration = oldFunc->findDecoration<IRKeepAliveDecoration>())
+ keepAliveDecoration->removeAndDeallocate();
return true;
}