diff options
| author | Yong He <yonghe@outlook.com> | 2022-06-01 17:37:07 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-01 17:37:07 -0700 |
| commit | 17e3b88b541ed7f45d575f0f9caaa808cd0a6619 (patch) | |
| tree | efacd5d4bf6381a5adf8055daa28f91ddc048a76 /source/slang/slang-ir-deduplicate.cpp | |
| parent | fa10f7dc23f8b93c0f9ef3fb5477871a20aaa974 (diff) | |
New language feature: basic error handling. (#2253)
* New language feature: basic error handling.
* Fix.
* Fix `tryCall` encoding according to code review.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-deduplicate.cpp')
| -rw-r--r-- | source/slang/slang-ir-deduplicate.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source/slang/slang-ir-deduplicate.cpp b/source/slang/slang-ir-deduplicate.cpp index f2c199af6..8aef7736c 100644 --- a/source/slang/slang-ir-deduplicate.cpp +++ b/source/slang/slang-ir-deduplicate.cpp @@ -76,4 +76,37 @@ namespace Slang for (auto inst : instToRemove) inst->removeAndDeallocate(); } + + void SharedIRBuilder::replaceGlobalInst(IRInst* oldInst, IRInst* newInst) + { + List<IRUse*> uses; + for (auto use = oldInst->firstUse; use; use = use->nextUse) + { + uses.add(use); + } + + bool shouldUpdateGlobalNumberedCache = false; + for (auto use : uses) + { + use->set(newInst); + // depending on the type of the user inst, we may need to rebuild and update the global + // numbering cache. + if (isGloballyNumberedInst(use->getUser())) + { + shouldUpdateGlobalNumberedCache = true; + } + } + oldInst->removeAndDeallocate(); + if (shouldUpdateGlobalNumberedCache) + { + deduplicateAndRebuildGlobalNumberingMap(); + } + } + + bool SharedIRBuilder::isGloballyNumberedInst(IRInst* inst) + { + if (!inst->getParent() || inst->getParent()->getOp() != kIROp_Module) + return false; + return m_globalValueNumberingMap.ContainsKey(IRInstKey{inst}); + } } |
