summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-strip.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-02-23 10:31:05 -0800
committerGitHub <noreply@github.com>2025-02-23 10:31:05 -0800
commit51ad07d1fbffd41c758eba172aa77ebba3204924 (patch)
treefadd788714c4ad37830846b0274d56b5ae1eff56 /source/slang/slang-ir-strip.cpp
parent0101e5ab59a1678ed7212913c3880edfaf039537 (diff)
Improve performance when compiling small shaders. (#6396)
Improve performance when compiling small shaders. Avoid copying witness table entries that are not getting used during linking. Avoid copying auto-diff related decorations and derivative functions during linking, if the user modules doesn't use autodiff. Cache operator overload resolution results on global session, so each new Session doesn't need to repetitively run through overload resolution from scratch.
Diffstat (limited to 'source/slang/slang-ir-strip.cpp')
-rw-r--r--source/slang/slang-ir-strip.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/slang/slang-ir-strip.cpp b/source/slang/slang-ir-strip.cpp
index e9fbbceb6..6c64bfca2 100644
--- a/source/slang/slang-ir-strip.cpp
+++ b/source/slang/slang-ir-strip.cpp
@@ -51,4 +51,34 @@ void stripFrontEndOnlyInstructions(IRModule* module, IRStripOptions const& optio
_stripFrontEndOnlyInstructionsRec(module->getModuleInst(), options);
}
+void stripImportedWitnessTable(IRModule* module)
+{
+ for (auto globalInst : module->getGlobalInsts())
+ {
+ auto inst = globalInst;
+ switch (globalInst->getOp())
+ {
+ case kIROp_Generic:
+ inst = findInnerMostGenericReturnVal(as<IRGeneric>(globalInst));
+ break;
+ case kIROp_WitnessTable:
+ break;
+ default:
+ continue;
+ }
+ if (inst->getOp() != kIROp_WitnessTable)
+ continue;
+ if (!globalInst->findDecoration<IRImportDecoration>())
+ continue;
+ IRInst* nextChild = nullptr;
+ for (auto child = inst->getFirstChild(); child;)
+ {
+ nextChild = child->getNextInst();
+ if (child->getOp() == kIROp_WitnessTable)
+ child->removeAndDeallocate();
+ child = nextChild;
+ }
+ }
+}
+
} // namespace Slang