From 50676c741e10ffe6f710c5de86387eaacd274a9a Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 26 Jan 2021 16:04:44 -0500 Subject: 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 --- source/slang/slang-ir-specialize-function-call.cpp | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source/slang/slang-ir-specialize-function-call.cpp') 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(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 -- cgit v1.2.3