diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-16 13:55:32 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-16 13:55:32 -0800 |
| commit | 4c4826d47eeef4675daae4ae53ff76f4d5ebd84a (patch) | |
| tree | ed4af0ded878e4f06e9641ce61d26ffd7c89ccbc /source/slang/slang-ir-dce.cpp | |
| parent | eda88e513e8b1e2abc05e9dc8555f237d96472df (diff) | |
Overhaul global inst deduplication and cpp/cuda backend. (#2654)
* Overhaul global inst deduplication and cpp/cuda backend.
* Update IR documentation.
---------
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 | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/source/slang/slang-ir-dce.cpp b/source/slang/slang-ir-dce.cpp index 05c10b317..251b473e0 100644 --- a/source/slang/slang-ir-dce.cpp +++ b/source/slang/slang-ir-dce.cpp @@ -237,14 +237,16 @@ struct DeadCodeEliminationContext // might still be dead. // // The biggest wrinkle is that we walk the linked list of - // children/decorations a bit carefully, using a temporary - // to hold the next node, in case we eliminate one of - // the children as we go. + // children/decorations a bit carefully, because eliminating one inst + // may cause the other nodes to be hoisted out of the current scope. + // We need to cache all children in a work list to ensure they are + // properly traversed. // - IRInst* next = nullptr; - for( IRInst* child = inst->getFirstDecorationOrChild(); child; child = next ) + List<IRInst*> children; + for (auto child : inst->getDecorationsAndChildren()) + children.add(child); + for(IRInst* child : children) { - next = child->getNextInst(); changed |= eliminateDeadInstsRec(child); } } |
