diff options
| author | Yong He <yonghe@outlook.com> | 2023-06-26 15:18:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-26 15:18:06 -0700 |
| commit | 4c9e4de4b68f2612a39e8783e9da89605ecf54e0 (patch) | |
| tree | 83a8efcc45d3d67d07f18caad49a9469252bf509 /source/slang/slang-ir-dce.cpp | |
| parent | 4eef0424a657e19f51f2734ba0199b69ee7354bd (diff) | |
Fix DCE on mutable calls in a loop. (#2943)
* Fix DCE on mutable calls in a loop.
* More accurate in-loop test.
* code review fixes.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-dce.cpp')
| -rw-r--r-- | source/slang/slang-ir-dce.cpp | 17 |
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; } |
