summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-dce.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-02-25 20:49:31 -0800
committerGitHub <noreply@github.com>2022-02-25 20:49:31 -0800
commitc31577953d5041c82375c22d847c2eba06106c58 (patch)
treebc685a8b63fc13cb85d160ae13df950056ca6e91 /source/slang/slang-ir-dce.cpp
parent8990d270e3a0c01b1f7abbf4f79556c5ef82a096 (diff)
Improved SCCP, inlining and resource specialization passes, legalize `ImageSubscript` for GLSL (#2146)
Diffstat (limited to 'source/slang/slang-ir-dce.cpp')
-rw-r--r--source/slang/slang-ir-dce.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/source/slang/slang-ir-dce.cpp b/source/slang/slang-ir-dce.cpp
index 285e5100c..9ed5249fe 100644
--- a/source/slang/slang-ir-dce.cpp
+++ b/source/slang/slang-ir-dce.cpp
@@ -81,7 +81,7 @@ struct DeadCodeEliminationContext
// dive into the task of actually finding all
// the live code in a module.
//
- void processModule()
+ bool processModule()
{
// First of all, we know that the root module instruction
// should be considered as live, because otherwise
@@ -174,11 +174,12 @@ struct DeadCodeEliminationContext
// recursively and eliminate those that are "dead" by
// virtue of not having been found live.
//
- eliminateDeadInstsRec(module->getModuleInst());
+ return eliminateDeadInstsRec(module->getModuleInst());
}
- void eliminateDeadInstsRec(IRInst* inst)
+ bool eliminateDeadInstsRec(IRInst* inst)
{
+ bool changed = false;
// Given the instruction `inst` we need to eliminate
// any dead code at, or under it.
//
@@ -192,6 +193,7 @@ struct DeadCodeEliminationContext
// mark the parent of a live instruction as live).
//
inst->removeAndDeallocate();
+ changed = true;
}
else
{
@@ -208,9 +210,10 @@ struct DeadCodeEliminationContext
for( IRInst* child = inst->getFirstDecorationOrChild(); child; child = next )
{
next = child->getNextInst();
- eliminateDeadInstsRec(child);
+ changed |= eliminateDeadInstsRec(child);
}
}
+ return changed;
}
// Now we come to the decision procedure we put off before:
@@ -336,7 +339,7 @@ struct DeadCodeEliminationContext
// is straighforward. We set up the context object
// and then defer to it for the real work.
//
-void eliminateDeadCode(
+bool eliminateDeadCode(
IRModule* module,
IRDeadCodeEliminationOptions const& options)
{
@@ -344,7 +347,7 @@ void eliminateDeadCode(
context.module = module;
context.options = options;
- context.processModule();
+ return context.processModule();
}
}