summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-dce.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir-dce.cpp')
-rw-r--r--source/slang/slang-ir-dce.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/slang-ir-dce.cpp b/source/slang/slang-ir-dce.cpp
index 64e0e3648..c6636aaee 100644
--- a/source/slang/slang-ir-dce.cpp
+++ b/source/slang/slang-ir-dce.cpp
@@ -104,6 +104,9 @@ struct DeadCodeEliminationContext
bool processInst(IRInst* root)
{
bool result = false;
+
+ module->invalidateAllAnalysis();
+
for (;;)
{
liveInsts.clear();
@@ -185,6 +188,12 @@ struct DeadCodeEliminationContext
// decision of whether a child (or decoration)
// should be live when its parent is to a subroutine.
//
+
+ if (auto func = as<IRGlobalValueWithCode>(inst))
+ {
+ module->findOrCreateDominatorTree(func);
+ }
+
for (auto child : inst->getDecorationsAndChildren())
{
if (shouldInstBeLiveIfParentIsLive(child))
@@ -208,6 +217,8 @@ struct DeadCodeEliminationContext
//
phiRemoved = false;
result |= eliminateDeadInstsRec(root);
+
+
if (!phiRemoved)
break;
}
@@ -271,6 +282,12 @@ struct DeadCodeEliminationContext
{
changed |= eliminateDeadInstsRec(child);
}
+ if (changed)
+ {
+ // If the function body is changed, invalidate its dominator tree.
+ if (auto func = as<IRGlobalValueWithCode>(inst))
+ module->invalidateAnalysisForInst(func);
+ }
}
return changed;
}