================ @@ -636,20 +636,36 @@ LogicalResult mlir::tryToPromoteMemorySlots( // lazily and cached to avoid expensive recomputation. BlockIndexCache blockIndexCache; - for (PromotableAllocationOpInterface allocator : allocators) { - for (MemorySlot slot : allocator.getPromotableSlots()) { - if (slot.ptr.use_empty()) - continue; - - MemorySlotPromotionAnalyzer analyzer(slot, dominance, dataLayout); - std::optional<MemorySlotPromotionInfo> info = analyzer.computeInfo(); - if (info) { - MemorySlotPromoter(slot, allocator, builder, dominance, dataLayout, - std::move(*info), statistics, blockIndexCache) - .promoteSlot(); - promotedAny = true; + SmallVector<PromotableAllocationOpInterface> workList(allocators.begin(), + allocators.end()); + + SmallVector<PromotableAllocationOpInterface> newWorkList; + newWorkList.reserve(workList.size()); + while (true) { + for (PromotableAllocationOpInterface allocator : workList) { + for (MemorySlot slot : allocator.getPromotableSlots()) { + if (slot.ptr.use_empty()) + continue; + + MemorySlotPromotionAnalyzer analyzer(slot, dominance, dataLayout); + std::optional<MemorySlotPromotionInfo> info = analyzer.computeInfo(); + if (info) { + MemorySlotPromoter(slot, allocator, builder, dominance, dataLayout, + std::move(*info), statistics, blockIndexCache) + .promoteSlot(); + promotedAny = true; + continue; + } + newWorkList.push_back(allocator); ---------------- gysit wrote:
I think we may add the same allocator multiple times here, if the allocator returns multiple slots? https://github.com/llvm/llvm-project/pull/91464 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits