summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-specialize-function-call.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-01-26 16:04:44 -0500
committerGitHub <noreply@github.com>2021-01-26 13:04:44 -0800
commit50676c741e10ffe6f710c5de86387eaacd274a9a (patch)
tree55e306d241df65af7746e5f8ba593ae72002c704 /source/slang/slang-ir-specialize-function-call.cpp
parent798d7731eca286df456bc2ec56c0695ba006b472 (diff)
Obfuscation naming issue fix (#1676)
* #include an absolute path didn't work - because paths were taken to always be relative. * Work around for issue with obfuscation (and lack of name hints) leading to names in output not being correctly uniquified. * Improve appendChar Remove unrequired memory juggling to scrub names. * Remove test code. * Small fixes in comments and method called. * Remove linkage decoration on functions that are specialized. * Obfuscation naming with specialization test. * Fix instruction deletion. Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-ir-specialize-function-call.cpp')
-rw-r--r--source/slang/slang-ir-specialize-function-call.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/slang/slang-ir-specialize-function-call.cpp b/source/slang/slang-ir-specialize-function-call.cpp
index 7e6c819d3..531078fc7 100644
--- a/source/slang/slang-ir-specialize-function-call.cpp
+++ b/source/slang/slang-ir-specialize-function-call.cpp
@@ -762,6 +762,36 @@ struct FunctionParameterSpecializationContext
oldFunc,
newFunc);
+ // If we have added an Linkage decoration, we want to remove and destroy it,
+ // because the linkage should only be on the original function and
+ // not on the "torn off" copies made in this function.
+ //
+ // It *could* be argued that we don't want to duplicate the decoration instructions
+ // to begin with, just to throw them away. That may be true, but it's simpler to just remove
+ // them than filter out in cloning.
+
+ {
+ auto decorationList = newFunc->getDecorations();
+
+ const auto end = decorationList.end();
+ auto cur = decorationList.begin();
+
+ while(cur != end)
+ {
+ IRDecoration* decoration = *cur;
+
+ // We step before before the test/destroying to ensure cur is not pointing
+ // to a potentially destroyed instruction
+ ++cur;
+
+ if (as<IRLinkageDecoration>(decoration))
+ {
+ decoration->removeAndDeallocate();
+ }
+ }
+ }
+
+
// We are almost done at this point, except that `newFunc`
// is lacking its parameters, as well as any of the body
// instructions that we decided were needed during