diff options
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 |
