From 28fa2c3342805b227a012aaae2bd3bac6402ca5b Mon Sep 17 00:00:00 2001 From: Ronan Keryell Date: Mon, 25 Nov 2024 12:40:04 -0800 Subject: [PATCH] Fix topological sort use Probably this code was never exercised since the API was wrongly used (topologicalSort does not mutate its parameter) and it was probably not the right function at the first place. --- .../Transforms/AIEObjectFifoStatefulTransform.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp b/lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp index 0d2e6c5821..9934e6fcda 100644 --- a/lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp +++ b/lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp @@ -15,16 +15,11 @@ #include "mlir/Analysis/TopologicalSortUtils.h" #include "mlir/Dialect/Arith/IR/Arith.h" -#include "mlir/Dialect/Index/IR/IndexDialect.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/IR/SCF.h" #include "mlir/Dialect/SCF/Utils/Utils.h" #include "mlir/IR/Attributes.h" -#include "mlir/IR/IRMapping.h" -#include "mlir/IR/Iterators.h" -#include "mlir/IR/PatternMatch.h" #include "mlir/Pass/Pass.h" -#include "mlir/Tools/mlir-translate/MlirTranslateMain.h" #include "mlir/Transforms/DialectConversion.h" #include @@ -1841,14 +1836,14 @@ struct AIEObjectFifoStatefulTransformPass ObjectFifoSubviewAccessOp, ObjectFifoReleaseOp>(op)) opsToErase.insert(op); }); - topologicalSort(opsToErase); - IRRewriter rewriter(&getContext()); - for (auto it = opsToErase.rbegin(); it != opsToErase.rend(); ++it) - (*it)->erase(); + SmallVector sorted{opsToErase.begin(), opsToErase.end()}; + computeTopologicalSorting(sorted); + for (auto *op : llvm::reverse(sorted)) + op->erase(); } }; std::unique_ptr> AIE::createAIEObjectFifoStatefulTransformPass() { return std::make_unique(); -} \ No newline at end of file +}