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.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.cpp')
| -rw-r--r-- | source/slang/slang-ir.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 0a001892a..cac49f5f7 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -5,6 +5,8 @@ #include "../core/slang-basic.h" +#include "slang-ir-dominators.h" + #include "slang-mangle.h" namespace Slang @@ -4067,6 +4069,20 @@ namespace Slang return module; } + IRDominatorTree* IRModule::findOrCreateDominatorTree(IRGlobalValueWithCode* func) + { + IRAnalysis* analysis = m_mapInstToAnalysis.tryGetValue(func); + if (analysis) + return analysis->getDominatorTree(); + else + { + m_mapInstToAnalysis[func] = IRAnalysis(); + analysis = m_mapInstToAnalysis.tryGetValue(func); + } + analysis->domTree = computeDominatorTree(func); + return analysis->getDominatorTree(); + } + void addGlobalValue( IRBuilder* builder, IRInst* value) @@ -7082,6 +7098,8 @@ namespace Slang module->getDeduplicationContext()->getConstantMap().remove(IRConstantKey{ constInst }); } module->getDeduplicationContext()->getInstReplacementMap().remove(this); + if (auto func = as<IRGlobalValueWithCode>(this)) + module->invalidateAnalysisForInst(func); } removeArguments(); removeFromParent(); @@ -7153,10 +7171,6 @@ namespace Slang // common subexpression elimination, etc. // auto call = cast<IRCall>(this); - // If the call has been marked as no-side-effect, we - // will treat it so, by-passing all other checks. - if (call->findDecoration<IRNoSideEffectDecoration>()) - return false; return !isSideEffectFreeFunctionalCall(call); } break; @@ -7610,6 +7624,11 @@ namespace Slang return inst; } + IRDominatorTree* IRAnalysis::getDominatorTree() + { + return static_cast<IRDominatorTree*>(domTree.get()); + } + } // namespace Slang #if SLANG_VC |
