[Mlir-commits] [mlir] [MLIR][Mem2Reg] Change API to always retry promotion after changes (PR #91464)
Christian Ulmann
llvmlistbot at llvm.org
Wed May 8 07:08:58 PDT 2024
================
@@ -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);
----------------
Dinistro wrote:
This was broken before, but I'll take care of this by extending one of the interface methods.
https://github.com/llvm/llvm-project/pull/91464
More information about the Mlir-commits
mailing list