summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-util.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-03-30 11:41:54 -0700
committerGitHub <noreply@github.com>2023-03-30 11:41:54 -0700
commitd01e28a49b47c9fadf2b764a74f318e3f95061e5 (patch)
treefcb1dc172690d9ef83abb108d0b943408da43dee /source/slang/slang-ir-util.cpp
parent37594df883a7b4d62b2aae80ee73f195dbfb6d77 (diff)
Fix autodiff pass duplicates exported functions. (#2759)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-util.cpp')
-rw-r--r--source/slang/slang-ir-util.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp
index bff80392f..c5cebb8b5 100644
--- a/source/slang/slang-ir-util.cpp
+++ b/source/slang/slang-ir-util.cpp
@@ -582,6 +582,32 @@ void sortBlocksInFunc(IRGlobalValueWithCode* func)
block->insertAtEnd(func);
}
+void removeLinkageDecorations(IRGlobalValueWithCode* func)
+{
+ List<IRInst*> toRemove;
+ for (auto inst : func->getDecorations())
+ {
+ switch (inst->getOp())
+ {
+ case kIROp_ImportDecoration:
+ case kIROp_ExportDecoration:
+ case kIROp_ExternCppDecoration:
+ case kIROp_PublicDecoration:
+ case kIROp_KeepAliveDecoration:
+ case kIROp_DllImportDecoration:
+ case kIROp_CudaDeviceExportDecoration:
+ case kIROp_DllExportDecoration:
+ case kIROp_HLSLExportDecoration:
+ toRemove.add(inst);
+ break;
+ default:
+ break;
+ }
+ }
+ for (auto inst : toRemove)
+ inst->removeAndDeallocate();
+}
+
void setInsertBeforeOrdinaryInst(IRBuilder* builder, IRInst* inst)
{
if (as<IRParam>(inst))