summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2019-02-04 16:24:44 -0800
committerjpienaar <jpienaar@google.com>2019-03-29 16:12:59 -0700
commitbf9c381d1dbf4381659597109422e543d62a49d7 (patch)
tree493aaa02d23039a9fcd31b9ff4b3a4f0af91df3a /mlir/lib/Transforms/MemRefDataFlowOpt.cpp
parentc9ad4621ce2d68cad547da360aedeee733b73f32 (diff)
downloadbcm5719-llvm-bf9c381d1dbf4381659597109422e543d62a49d7.tar.gz
bcm5719-llvm-bf9c381d1dbf4381659597109422e543d62a49d7.zip
Remove InstWalker and move all instruction walking to the api facilities on Function/Block/Instruction.
PiperOrigin-RevId: 232388113
Diffstat (limited to 'mlir/lib/Transforms/MemRefDataFlowOpt.cpp')
-rw-r--r--mlir/lib/Transforms/MemRefDataFlowOpt.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
index 2d06a327315..9c9db30d163 100644
--- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
+++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
@@ -25,7 +25,6 @@
#include "mlir/Analysis/AffineAnalysis.h"
#include "mlir/Analysis/Dominance.h"
#include "mlir/Analysis/Utils.h"
-#include "mlir/IR/InstVisitor.h"
#include "mlir/Pass.h"
#include "mlir/StandardOps/StandardOps.h"
#include "mlir/Transforms/Passes.h"
@@ -70,12 +69,12 @@ namespace {
// currently only eliminates the stores only if no other loads/uses (other
// than dealloc) remain.
//
-struct MemRefDataFlowOpt : public FunctionPass, InstWalker<MemRefDataFlowOpt> {
+struct MemRefDataFlowOpt : public FunctionPass {
explicit MemRefDataFlowOpt() : FunctionPass(&MemRefDataFlowOpt::passID) {}
PassResult runOnFunction(Function *f) override;
- void visitInstruction(Instruction *opInst);
+ void forwardStoreToLoad(OpPointer<LoadOp> loadOp);
// A list of memref's that are potentially dead / could be eliminated.
SmallPtrSet<Value *, 4> memrefsToErase;
@@ -100,14 +99,9 @@ FunctionPass *mlir::createMemRefDataFlowOptPass() {
// This is a straightforward implementation not optimized for speed. Optimize
// this in the future if needed.
-void MemRefDataFlowOpt::visitInstruction(Instruction *opInst) {
+void MemRefDataFlowOpt::forwardStoreToLoad(OpPointer<LoadOp> loadOp) {
Instruction *lastWriteStoreOp = nullptr;
-
- auto loadOp = opInst->dyn_cast<LoadOp>();
- if (!loadOp)
- return;
-
- Instruction *loadOpInst = opInst;
+ Instruction *loadOpInst = loadOp->getInstruction();
// First pass over the use list to get minimum number of surrounding
// loops common between the load op and the store op, with min taken across
@@ -235,7 +229,8 @@ PassResult MemRefDataFlowOpt::runOnFunction(Function *f) {
memrefsToErase.clear();
// Walk all load's and perform load/store forwarding.
- walk(f);
+ f->walk<LoadOp>(
+ [&](OpPointer<LoadOp> loadOp) { forwardStoreToLoad(loadOp); });
// Erase all load op's whose results were replaced with store fwd'ed ones.
for (auto *loadOp : loadOpsToErase) {
OpenPOWER on IntegriCloud