diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-06 10:07:02 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-06 10:07:02 -0800 |
| commit | e893a831d7f64eb52e76df087190247f43b150ae (patch) | |
| tree | 1cf91d943741ed25ad057a1bf34f47ee03b5229b /source | |
| parent | a12c5511a9003efb23b265a7f2f613cf49aa9f07 (diff) | |
Fix crash when processing nested switch. (#2624)
* Fix crash when processing nested switch.
* Clean up.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-ir-eliminate-multilevel-break.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/slang/slang-ir-eliminate-multilevel-break.cpp b/source/slang/slang-ir-eliminate-multilevel-break.cpp index 2330991c5..35412cc07 100644 --- a/source/slang/slang-ir-eliminate-multilevel-break.cpp +++ b/source/slang/slang-ir-eliminate-multilevel-break.cpp @@ -61,15 +61,19 @@ struct EliminateMultiLevelBreakContext void collectBreakableRegionBlocks(BreakableRegionInfo& info) { + // Push break block to a stack so we can easily check if a block is a break block in its + // parent regions. + breakBlocks.Add(info.getBreakBlock()); + auto successors = as<IRBlock>(info.headerInst->getParent())->getSuccessors(); for (auto successor : successors) { + if (!breakBlocks.Add(successor)) + continue; if (info.blockSet.Add(successor)) info.blocks.add(successor); } - // Push break block to a stack so we can easily check if a block is a break block in its - // parent regions. - breakBlocks.Add(info.getBreakBlock()); + for (Index i = 0; i < info.blocks.getCount(); i++) { auto block = info.blocks[i]; @@ -133,7 +137,6 @@ struct EliminateMultiLevelBreakContext break; } } - for (auto& l : regions) { l->forEach( |
