From a3d9ccaecbea042b59073ec34c91a343c1903a5c Mon Sep 17 00:00:00 2001 From: River Riddle Date: Mon, 4 Feb 2019 10:30:45 -0800 Subject: [PATCH] Replace the walkOps/visitOperationInst variants from the InstWalkers with the Instruction variants. PiperOrigin-RevId: 232322030 --- mlir/include/mlir/AffineOps/AffineOps.h | 4 +- mlir/include/mlir/Analysis/NestedMatcher.h | 2 +- mlir/include/mlir/IR/Block.h | 8 +-- mlir/include/mlir/IR/Function.h | 6 +-- mlir/include/mlir/IR/InstVisitor.h | 53 +++---------------- .../mlir/Transforms/MLPatternLoweringPass.h | 2 +- mlir/lib/AffineOps/AffineOps.cpp | 9 ++-- mlir/lib/Analysis/MemRefDependenceCheck.cpp | 2 +- mlir/lib/EDSC/LowerEDSCTestPass.cpp | 2 +- mlir/lib/IR/AsmPrinter.cpp | 2 +- mlir/lib/IR/Block.cpp | 34 ++++++------ mlir/lib/IR/Function.cpp | 32 ++--------- mlir/lib/Transforms/ComposeAffineMaps.cpp | 4 +- mlir/lib/Transforms/ConstantFold.cpp | 4 +- mlir/lib/Transforms/LoopFusion.cpp | 4 +- mlir/lib/Transforms/LoopUnroll.cpp | 4 +- mlir/lib/Transforms/LoopUnrollAndJam.cpp | 2 +- mlir/lib/Transforms/LowerAffine.cpp | 2 +- mlir/lib/Transforms/MemRefDataFlowOpt.cpp | 4 +- mlir/lib/Transforms/PipelineDataTransfer.cpp | 2 +- .../Transforms/SimplifyAffineStructures.cpp | 2 +- mlir/lib/Transforms/StripDebugInfo.cpp | 2 +- .../Utils/GreedyPatternRewriteDriver.cpp | 2 +- mlir/lib/Transforms/Utils/LoopUtils.cpp | 2 +- mlir/lib/Transforms/Utils/Utils.cpp | 4 +- 25 files changed, 61 insertions(+), 133 deletions(-) diff --git a/mlir/include/mlir/AffineOps/AffineOps.h b/mlir/include/mlir/AffineOps/AffineOps.h index 12e4589405f6..46bb91c1bcab 100644 --- a/mlir/include/mlir/AffineOps/AffineOps.h +++ b/mlir/include/mlir/AffineOps/AffineOps.h @@ -182,11 +182,11 @@ public: /// Walk the operation instructions in the 'for' instruction in preorder, /// calling the callback for each operation. - void walkOps(std::function callback); + void walk(std::function callback); /// Walk the operation instructions in the 'for' instruction in postorder, /// calling the callback for each operation. - void walkOpsPostOrder(std::function callback); + void walkPostOrder(std::function callback); private: friend class Instruction; diff --git a/mlir/include/mlir/Analysis/NestedMatcher.h b/mlir/include/mlir/Analysis/NestedMatcher.h index 5c040ecbe087..aba0e11ab915 100644 --- a/mlir/include/mlir/Analysis/NestedMatcher.h +++ b/mlir/include/mlir/Analysis/NestedMatcher.h @@ -127,7 +127,7 @@ private: struct State : public InstWalker { State(NestedPattern &pattern, SmallVectorImpl *matches) : pattern(pattern), matches(matches) {} - void visitOperationInst(Instruction *opInst) { + void visitInstruction(Instruction *opInst) { pattern.matchOne(opInst, matches); } diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h index 479f15d16031..a6a29fb84ea2 100644 --- a/mlir/include/mlir/IR/Block.h +++ b/mlir/include/mlir/IR/Block.h @@ -311,12 +311,12 @@ public: return &Block::instructions; } - /// Walk the operation instructions of this block in preorder, calling the - /// callback for each operation. + /// Walk the instructions of this block in preorder, calling the callback for + /// each operation. void walk(std::function callback); - /// Walk the operation instructions in this block in postorder, calling the - /// callback for each operation. + /// Walk the instructions in this block in postorder, calling the callback for + /// each operation. void walkPostOrder(std::function callback); /// Walk the operation instructions in the specified [begin, end) range of diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h index 3876d750a28f..f483ff462599 100644 --- a/mlir/include/mlir/IR/Function.h +++ b/mlir/include/mlir/IR/Function.h @@ -117,13 +117,11 @@ public: /// Walk the instructions in the function in preorder, calling the callback /// for each instruction or operation. - void walkInsts(std::function callback); - void walkOps(std::function callback); + void walk(std::function callback); /// Walk the instructions in the function in postorder, calling the callback /// for each instruction or operation. - void walkInstsPostOrder(std::function callback); - void walkOpsPostOrder(std::function callback); + void walkPostOrder(std::function callback); //===--------------------------------------------------------------------===// // Arguments diff --git a/mlir/include/mlir/IR/InstVisitor.h b/mlir/include/mlir/IR/InstVisitor.h index 7b74c69ceef3..e11b73508941 100644 --- a/mlir/include/mlir/IR/InstVisitor.h +++ b/mlir/include/mlir/IR/InstVisitor.h @@ -67,34 +67,6 @@ #include "mlir/IR/Instruction.h" namespace mlir { - -/// Base class for instruction visitors. -template class InstVisitor { - //===--------------------------------------------------------------------===// - // Interface code - This is the public interface of the InstVisitor that you - // use to visit instructions. - -public: - // Function to visit a instruction. - RetTy visit(Instruction *s) { - static_assert(std::is_base_of::value, - "Must pass the derived type to this template!"); - return static_cast(this)->visitOperationInst(s); - } - - //===--------------------------------------------------------------------===// - // Visitation functions... these functions provide default fallbacks in case - // the user does not specify what to do for a particular instruction type. - // The default behavior is to generalize the instruction type to its subtype - // and try visiting the subtype. All of this should be inlined perfectly, - // because there are no virtual functions to get in the way. - // - - // When visiting a for inst, if inst, or an operation inst directly, these - // methods get called to indicate when transitioning into a new unit. - void visitOperationInst(Instruction *opInst) {} -}; - /// Base class for instruction walkers. A walker can traverse depth first in /// pre-order or post order. The walk methods without a suffix do a pre-order /// traversal while those that traverse in post order have a PostOrder suffix. @@ -127,36 +99,26 @@ public: static_cast(this)->walkPostOrder(it->begin(), it->end()); } - void walkOpInst(Instruction *opInst) { - static_cast(this)->visitOperationInst(opInst); - for (auto &blockList : opInst->getBlockLists()) - for (auto &block : blockList) - static_cast(this)->walk(block.begin(), block.end()); - } - - void walkOpInstPostOrder(Instruction *opInst) { - for (auto &blockList : opInst->getBlockLists()) - for (auto &block : blockList) - static_cast(this)->walkPostOrder(block.begin(), - block.end()); - static_cast(this)->visitOperationInst(opInst); - } - // Function to walk a instruction. RetTy walk(Instruction *s) { static_assert(std::is_base_of::value, "Must pass the derived type to this template!"); static_cast(this)->visitInstruction(s); - return static_cast(this)->walkOpInst(s); + for (auto &blockList : s->getBlockLists()) + for (auto &block : blockList) + static_cast(this)->walk(block.begin(), block.end()); } // Function to walk a instruction in post order DFS. RetTy walkPostOrder(Instruction *s) { static_assert(std::is_base_of::value, "Must pass the derived type to this template!"); + for (auto &blockList : s->getBlockLists()) + for (auto &block : blockList) + static_cast(this)->walkPostOrder(block.begin(), + block.end()); static_cast(this)->visitInstruction(s); - return static_cast(this)->walkOpInstPostOrder(s); } //===--------------------------------------------------------------------===// @@ -170,7 +132,6 @@ public: // called. These are typically O(1) complexity and shouldn't be recursively // processing their descendants in some way. When using RetTy, all of these // need to be overridden. - void visitOperationInst(Instruction *opInst) {} void visitInstruction(Instruction *inst) {} }; diff --git a/mlir/include/mlir/Transforms/MLPatternLoweringPass.h b/mlir/include/mlir/Transforms/MLPatternLoweringPass.h index c6f810a215c9..c5be3322f43d 100644 --- a/mlir/include/mlir/Transforms/MLPatternLoweringPass.h +++ b/mlir/include/mlir/Transforms/MLPatternLoweringPass.h @@ -144,7 +144,7 @@ PassResult MLPatternLoweringPass::runOnFunction(Function *f) { MLFuncLoweringRewriter rewriter(&builder); llvm::SmallVector ops; - f->walkOps([&ops](Instruction *inst) { ops.push_back(inst); }); + f->walk([&ops](Instruction *inst) { ops.push_back(inst); }); for (Instruction *inst : ops) { for (const auto &pattern : patterns) { diff --git a/mlir/lib/AffineOps/AffineOps.cpp b/mlir/lib/AffineOps/AffineOps.cpp index 682a8e4f1eda..2e657cf7e17d 100644 --- a/mlir/lib/AffineOps/AffineOps.cpp +++ b/mlir/lib/AffineOps/AffineOps.cpp @@ -410,27 +410,26 @@ bool AffineForOp::matchingBoundOperandList() const { return true; } -void AffineForOp::walkOps(std::function callback) { +void AffineForOp::walk(std::function callback) { struct Walker : public InstWalker { std::function const &callback; Walker(std::function const &callback) : callback(callback) {} - void visitOperationInst(Instruction *opInst) { callback(opInst); } + void visitInstruction(Instruction *opInst) { callback(opInst); } }; Walker w(callback); w.walk(getInstruction()); } -void AffineForOp::walkOpsPostOrder( - std::function callback) { +void AffineForOp::walkPostOrder(std::function callback) { struct Walker : public InstWalker { std::function const &callback; Walker(std::function const &callback) : callback(callback) {} - void visitOperationInst(Instruction *opInst) { callback(opInst); } + void visitInstruction(Instruction *opInst) { callback(opInst); } }; Walker v(callback); diff --git a/mlir/lib/Analysis/MemRefDependenceCheck.cpp b/mlir/lib/Analysis/MemRefDependenceCheck.cpp index b2549910a171..6ea47a20f606 100644 --- a/mlir/lib/Analysis/MemRefDependenceCheck.cpp +++ b/mlir/lib/Analysis/MemRefDependenceCheck.cpp @@ -46,7 +46,7 @@ struct MemRefDependenceCheck : public FunctionPass, PassResult runOnFunction(Function *f) override; - void visitOperationInst(Instruction *opInst) { + void visitInstruction(Instruction *opInst) { if (opInst->isa() || opInst->isa()) { loadsAndStores.push_back(opInst); } diff --git a/mlir/lib/EDSC/LowerEDSCTestPass.cpp b/mlir/lib/EDSC/LowerEDSCTestPass.cpp index e891be68fd34..1be6b90985f8 100644 --- a/mlir/lib/EDSC/LowerEDSCTestPass.cpp +++ b/mlir/lib/EDSC/LowerEDSCTestPass.cpp @@ -45,7 +45,7 @@ char LowerEDSCTestPass::passID = 0; #include "mlir/EDSC/reference-impl.inc" PassResult LowerEDSCTestPass::runOnFunction(Function *f) { - f->walkOps([](OperationInst *op) { + f->walk([](OperationInst *op) { if (op->getName().getStringRef() == "print") { auto opName = op->getAttrOfType("op"); if (!opName) { diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 36a4b8e3b5ea..7b59321c8159 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -263,7 +263,7 @@ void ModuleState::initialize(const Module *module) { for (auto &fn : *module) { visitType(fn.getType()); - const_cast(fn).walkInsts( + const_cast(fn).walk( [&](Instruction *op) { ModuleState::visitInstruction(op); }); } diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index 698494144ce7..0e1d21ffed81 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -256,31 +256,31 @@ Block *Block::splitBlock(iterator splitBefore) { return newBB; } -void Block::walk(std::function callback) { +void Block::walk(std::function callback) { walk(begin(), end(), callback); } void Block::walk(Block::iterator begin, Block::iterator end, - std::function callback) { + std::function callback) { struct Walker : public InstWalker { - std::function const &callback; - Walker(std::function const &callback) + std::function const &callback; + Walker(std::function const &callback) : callback(callback) {} - void visitOperationInst(OperationInst *opInst) { callback(opInst); } + void visitInstruction(Instruction *opInst) { callback(opInst); } }; Walker w(callback); w.walk(begin, end); } -void Block::walkPostOrder(std::function callback) { +void Block::walkPostOrder(std::function callback) { struct Walker : public InstWalker { - std::function const &callback; - Walker(std::function const &callback) + std::function const &callback; + Walker(std::function const &callback) : callback(callback) {} - void visitOperationInst(OperationInst *opInst) { callback(opInst); } + void visitInstruction(Instruction *opInst) { callback(opInst); } }; Walker v(callback); @@ -338,19 +338,15 @@ void BlockList::cloneInto(BlockList *dest, BlockAndValueMapping &mapper, BlockAndValueMapping &mapper; Walker(BlockAndValueMapping &mapper) : mapper(mapper) {} - /// Remap the instruction operands. - void visitInstruction(Instruction *inst) { + /// Remap the instruction and successor block operands. + void visitInstruction(OperationInst *inst) { for (auto &instOp : inst->getInstOperands()) if (auto *mappedOp = mapper.lookupOrNull(instOp.get())) instOp.set(mappedOp); - } - // Remap the successor block operands. - void visitOperationInst(OperationInst *opInst) { - if (!opInst->isTerminator()) - return; - for (auto &succOp : opInst->getBlockOperands()) - if (auto *mappedOp = mapper.lookupOrNull(succOp.get())) - succOp.set(mappedOp); + if (inst->isTerminator()) + for (auto &succOp : inst->getBlockOperands()) + if (auto *mappedOp = mapper.lookupOrNull(succOp.get())) + succOp.set(mappedOp); } }; diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp index 35ac5459ad60..3a263fb13f99 100644 --- a/mlir/lib/IR/Function.cpp +++ b/mlir/lib/IR/Function.cpp @@ -214,7 +214,7 @@ void Function::addEntryBlock() { entry->addArguments(type.getInputs()); } -void Function::walkInsts(std::function callback) { +void Function::walk(std::function callback) { struct Walker : public InstWalker { std::function const &callback; Walker(std::function const &callback) @@ -227,39 +227,13 @@ void Function::walkInsts(std::function callback) { v.walk(this); } -void Function::walkOps(std::function callback) { - struct Walker : public InstWalker { - std::function const &callback; - Walker(std::function const &callback) - : callback(callback) {} - - void visitOperationInst(OperationInst *opInst) { callback(opInst); } - }; - - Walker v(callback); - v.walk(this); -} - -void Function::walkInstsPostOrder(std::function callback) { +void Function::walkPostOrder(std::function callback) { struct Walker : public InstWalker { std::function const &callback; Walker(std::function const &callback) : callback(callback) {} - void visitOperationInst(Instruction *inst) { callback(inst); } - }; - - Walker v(callback); - v.walkPostOrder(this); -} - -void Function::walkOpsPostOrder(std::function callback) { - struct Walker : public InstWalker { - std::function const &callback; - Walker(std::function const &callback) - : callback(callback) {} - - void visitOperationInst(OperationInst *opInst) { callback(opInst); } + void visitInstruction(Instruction *inst) { callback(inst); } }; Walker v(callback); diff --git a/mlir/lib/Transforms/ComposeAffineMaps.cpp b/mlir/lib/Transforms/ComposeAffineMaps.cpp index d7327d997c25..4f960ea73afb 100644 --- a/mlir/lib/Transforms/ComposeAffineMaps.cpp +++ b/mlir/lib/Transforms/ComposeAffineMaps.cpp @@ -48,7 +48,7 @@ namespace { struct ComposeAffineMaps : public FunctionPass, InstWalker { explicit ComposeAffineMaps() : FunctionPass(&ComposeAffineMaps::passID) {} PassResult runOnFunction(Function *f) override; - void visitOperationInst(OperationInst *opInst); + void visitInstruction(OperationInst *opInst); SmallVector, 8> affineApplyOps; @@ -68,7 +68,7 @@ static bool affineApplyOp(const Instruction &inst) { return opInst.isa(); } -void ComposeAffineMaps::visitOperationInst(OperationInst *opInst) { +void ComposeAffineMaps::visitInstruction(OperationInst *opInst) { if (auto afOp = opInst->dyn_cast()) { affineApplyOps.push_back(afOp); } diff --git a/mlir/lib/Transforms/ConstantFold.cpp b/mlir/lib/Transforms/ConstantFold.cpp index 9c20e79180a6..859d0012fac0 100644 --- a/mlir/lib/Transforms/ConstantFold.cpp +++ b/mlir/lib/Transforms/ConstantFold.cpp @@ -37,7 +37,7 @@ struct ConstantFold : public FunctionPass, InstWalker { bool foldOperation(OperationInst *op, SmallVectorImpl &existingConstants); - void visitOperationInst(OperationInst *inst); + void visitInstruction(OperationInst *op); PassResult runOnFunction(Function *f) override; static char passID; @@ -49,7 +49,7 @@ char ConstantFold::passID = 0; /// Attempt to fold the specified operation, updating the IR to match. If /// constants are found, we keep track of them in the existingConstants list. /// -void ConstantFold::visitOperationInst(OperationInst *op) { +void ConstantFold::visitInstruction(OperationInst *op) { // If this operation is an AffineForOp, then fold the bounds. if (auto forOp = op->dyn_cast()) { constantFoldBounds(forOp); diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 162e0e3b7f66..304331320ac9 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -118,7 +118,7 @@ public: SmallVector storeOpInsts; bool hasNonForRegion = false; - void visitOperationInst(OperationInst *opInst) { + void visitInstruction(OperationInst *opInst) { if (opInst->isa()) forOps.push_back(opInst->cast()); else if (opInst->getNumBlockLists() != 0) @@ -619,7 +619,7 @@ public: LoopNestStatsCollector(LoopNestStats *stats) : stats(stats) {} - void visitOperationInst(OperationInst *opInst) { + void visitInstruction(OperationInst *opInst) { auto forOp = opInst->dyn_cast(); if (!forOp) return; diff --git a/mlir/lib/Transforms/LoopUnroll.cpp b/mlir/lib/Transforms/LoopUnroll.cpp index 86e913bd71f0..9c9952d31ca3 100644 --- a/mlir/lib/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Transforms/LoopUnroll.cpp @@ -113,7 +113,7 @@ PassResult LoopUnroll::runOnFunction(Function *f) { return hasInnerLoops; } - bool walkOpInstPostOrder(OperationInst *opInst) { + bool walkPostOrder(OperationInst *opInst) { bool hasInnerLoops = false; for (auto &blockList : opInst->getBlockLists()) for (auto &block : blockList) @@ -140,7 +140,7 @@ PassResult LoopUnroll::runOnFunction(Function *f) { const unsigned minTripCount; ShortLoopGatherer(unsigned minTripCount) : minTripCount(minTripCount) {} - void visitOperationInst(OperationInst *opInst) { + void visitInstruction(OperationInst *opInst) { auto forOp = opInst->dyn_cast(); if (!forOp) return; diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp index 7327a37ee3ad..d87f9d5dc149 100644 --- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp @@ -196,7 +196,7 @@ bool mlir::loopUnrollJamByFactor(OpPointer forOp, // Gather all sub-blocks to jam upon the loop being unrolled. JamBlockGatherer jbg; - jbg.walkOpInst(forInst); + jbg.walk(forInst); auto &subBlocks = jbg.subBlocks; // Generate the cleanup loop if trip count isn't a multiple of diff --git a/mlir/lib/Transforms/LowerAffine.cpp b/mlir/lib/Transforms/LowerAffine.cpp index 24ca4e950822..08c8188fada9 100644 --- a/mlir/lib/Transforms/LowerAffine.cpp +++ b/mlir/lib/Transforms/LowerAffine.cpp @@ -615,7 +615,7 @@ PassResult LowerAffinePass::runOnFunction(Function *function) { // Collect all the For instructions as well as AffineIfOps and AffineApplyOps. // We do this as a prepass to avoid invalidating the walker with our rewrite. - function->walkInsts([&](Instruction *inst) { + function->walk([&](Instruction *inst) { auto op = cast(inst); if (op->isa() || op->isa() || op->isa()) diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp index e6ce273b5326..b9386c384dd8 100644 --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -75,7 +75,7 @@ struct MemRefDataFlowOpt : public FunctionPass, InstWalker { PassResult runOnFunction(Function *f) override; - void visitOperationInst(OperationInst *opInst); + void visitInstruction(OperationInst *opInst); // A list of memref's that are potentially dead / could be eliminated. SmallPtrSet memrefsToErase; @@ -100,7 +100,7 @@ FunctionPass *mlir::createMemRefDataFlowOptPass() { // This is a straightforward implementation not optimized for speed. Optimize // this in the future if needed. -void MemRefDataFlowOpt::visitOperationInst(OperationInst *opInst) { +void MemRefDataFlowOpt::visitInstruction(OperationInst *opInst) { OperationInst *lastWriteStoreOp = nullptr; auto loadOp = opInst->dyn_cast(); diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index 2e083bbfd79f..8d13800160d8 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -142,7 +142,7 @@ PassResult PipelineDataTransfer::runOnFunction(Function *f) { // deleted and replaced by a prologue, a new steady-state loop and an // epilogue). forOps.clear(); - f->walkOpsPostOrder([&](OperationInst *opInst) { + f->walkPostOrder([&](OperationInst *opInst) { if (auto forOp = opInst->dyn_cast()) forOps.push_back(forOp); }); diff --git a/mlir/lib/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Transforms/SimplifyAffineStructures.cpp index 80b2de130e73..a9fcfc5bd116 100644 --- a/mlir/lib/Transforms/SimplifyAffineStructures.cpp +++ b/mlir/lib/Transforms/SimplifyAffineStructures.cpp @@ -64,7 +64,7 @@ static IntegerSet simplifyIntegerSet(IntegerSet set) { } PassResult SimplifyAffineStructures::runOnFunction(Function *f) { - f->walkOps([&](OperationInst *opInst) { + f->walk([&](OperationInst *opInst) { for (auto attr : opInst->getAttrs()) { if (auto mapAttr = attr.second.dyn_cast()) { MutableAffineMap mMap(mapAttr.getValue()); diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp index 6e1d5ff2d112..c5e42b622ed4 100644 --- a/mlir/lib/Transforms/StripDebugInfo.cpp +++ b/mlir/lib/Transforms/StripDebugInfo.cpp @@ -39,7 +39,7 @@ PassResult StripDebugInfo::runOnFunction(Function *f) { // Strip the debug info from the function and its instructions. f->setLoc(unknownLoc); - f->walkInsts([&](Instruction *inst) { inst->setLoc(unknownLoc); }); + f->walk([&](Instruction *inst) { inst->setLoc(unknownLoc); }); return success(); } diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index 019cbbae0635..790f971bb58a 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -38,7 +38,7 @@ public: worklist.reserve(64); // Add all operations to the worklist. - fn->walkOps([&](OperationInst *inst) { addToWorklist(inst); }); + fn->walk([&](OperationInst *inst) { addToWorklist(inst); }); } /// Perform the rewrites. diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index 99079119dab7..153557de04a4 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -135,7 +135,7 @@ bool mlir::promoteIfSingleIteration(OpPointer forOp) { /// their body into the containing Block. void mlir::promoteSingleIterationLoops(Function *f) { // Gathers all innermost loops through a post order pruned walk. - f->walkOpsPostOrder([](OperationInst *inst) { + f->walkPostOrder([](OperationInst *inst) { if (auto forOp = inst->dyn_cast()) promoteIfSingleIteration(forOp); }); diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp index 732062a8b973..879a4f4b585f 100644 --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -362,8 +362,8 @@ void mlir::remapFunctionAttrs( Function &fn, const DenseMap &remappingTable) { // Look at all instructions in a Function. - fn.walkOps( - [&](OperationInst *inst) { remapFunctionAttrs(*inst, remappingTable); }); + fn.walk( + [&](Instruction *inst) { remapFunctionAttrs(*inst, remappingTable); }); } void mlir::remapFunctionAttrs(