diff options
| author | Yong He <yonghe@outlook.com> | 2023-04-02 20:43:09 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-02 20:43:09 -0700 |
| commit | d7ba60c993366b4aaf6ef8ee7d8eab940d61eac8 (patch) | |
| tree | a532154612e6b8370344d43656fc46c478f2c243 /source | |
| parent | 539f17aebf10dc5fabd55f17ae88c52f47a638cd (diff) | |
Fix type legalization pass. (#2768)
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-ir-legalize-types.cpp | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/source/slang/slang-ir-legalize-types.cpp b/source/slang/slang-ir-legalize-types.cpp index 9131a3559..b9d494c21 100644 --- a/source/slang/slang-ir-legalize-types.cpp +++ b/source/slang/slang-ir-legalize-types.cpp @@ -3541,32 +3541,42 @@ struct IRTypeLegalizationPass // In order to process an entire module, we start by adding the // root module insturction to our work list, and then we will // proceed to process instructions until the work list goes dry. + // The entire process is repeated until no more changes can be + // made to the module. // - addToWorkList(module->getModuleInst()); - while( workList.getCount() != 0 ) - { - // The order of items in the work list is signficiant; - // later entries could depend on earlier ones. As such, we - // cannot just do something like the `fastRemoveAt(...)` - // operation that could potentially lead to instructions - // being processed in a different order than they were added. - // - // Instead, we will make a copy of the current work list - // at each step, and swap in an empty work list to be added - // to with any new instructions. - // - List<IRInst*> workListCopy; - Swap(workListCopy, workList); - addedToWorkListSet.Clear(); - - // Now we simply process each instruction on the copy of - // the work list, knowing that `processInst` may add additional - // instructions to the original work list. - // - for( auto inst : workListCopy ) + for (;;) + { + auto lastReplacedInstCount = context->replacedInstructions.Count(); + addToWorkList(module->getModuleInst()); + while( workList.getCount() != 0 ) { - processInst(inst); + // The order of items in the work list is signficiant; + // later entries could depend on earlier ones. As such, we + // cannot just do something like the `fastRemoveAt(...)` + // operation that could potentially lead to instructions + // being processed in a different order than they were added. + // + // Instead, we will make a copy of the current work list + // at each step, and swap in an empty work list to be added + // to with any new instructions. + // + List<IRInst*> workListCopy; + Swap(workListCopy, workList); + addedToWorkListSet.Clear(); + + // Now we simply process each instruction on the copy of + // the work list, knowing that `processInst` may add additional + // instructions to the original work list. + // + for( auto inst : workListCopy ) + { + processInst(inst); + } } + + // Any changes made? Run the process again. + if (lastReplacedInstCount == context->replacedInstructions.Count()) + break; } // After we are done, there might be various instructions that |
