summaryrefslogtreecommitdiffstats
path: root/mlir/lib
diff options
context:
space:
mode:
authorUday Bondhugula <bondhugula@google.com>2019-03-05 15:05:34 -0800
committerjpienaar <jpienaar@google.com>2019-03-29 16:58:35 -0700
commit02af8c22df523d7cda4399058e0a0945d54f4972 (patch)
treeb49de902095777a37a8f109f3506147190134fc3 /mlir/lib
parent73e0297d36452555cb9552827c498c8bde1a5f74 (diff)
downloadbcm5719-llvm-02af8c22df523d7cda4399058e0a0945d54f4972.tar.gz
bcm5719-llvm-02af8c22df523d7cda4399058e0a0945d54f4972.zip
Change Pass:getFunction() to return pointer instead of ref - NFC
- change this for consistency - everything else similar takes/returns a Function pointer - the FuncBuilder ctor, Block/Value/Instruction::getFunction(), etc. - saves a whole bunch of &s everywhere PiperOrigin-RevId: 236928761
Diffstat (limited to 'mlir/lib')
-rw-r--r--mlir/lib/Analysis/MemRefBoundCheck.cpp2
-rw-r--r--mlir/lib/Analysis/MemRefDependenceCheck.cpp2
-rw-r--r--mlir/lib/Analysis/ParallelismDetection.cpp2
-rw-r--r--mlir/lib/EDSC/LowerEDSCTestPass.cpp2
-rw-r--r--mlir/lib/Pass/Pass.cpp2
-rw-r--r--mlir/lib/Transforms/CSE.cpp2
-rw-r--r--mlir/lib/Transforms/Canonicalizer.cpp6
-rw-r--r--mlir/lib/Transforms/ConstantFold.cpp2
-rw-r--r--mlir/lib/Transforms/DmaGeneration.cpp2
-rw-r--r--mlir/lib/Transforms/LoopFusion.cpp2
-rw-r--r--mlir/lib/Transforms/LoopTiling.cpp2
-rw-r--r--mlir/lib/Transforms/LoopUnroll.cpp14
-rw-r--r--mlir/lib/Transforms/LoopUnrollAndJam.cpp2
-rw-r--r--mlir/lib/Transforms/LowerAffine.cpp2
-rw-r--r--mlir/lib/Transforms/LowerVectorTransfers.cpp2
-rw-r--r--mlir/lib/Transforms/MaterializeVectors.cpp2
-rw-r--r--mlir/lib/Transforms/MemRefDataFlowOpt.cpp7
-rw-r--r--mlir/lib/Transforms/PipelineDataTransfer.cpp2
-rw-r--r--mlir/lib/Transforms/SimplifyAffineStructures.cpp2
-rw-r--r--mlir/lib/Transforms/StripDebugInfo.cpp8
-rw-r--r--mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp2
-rw-r--r--mlir/lib/Transforms/Vectorize.cpp2
-rw-r--r--mlir/lib/Transforms/ViewFunctionGraph.cpp2
23 files changed, 38 insertions, 35 deletions
diff --git a/mlir/lib/Analysis/MemRefBoundCheck.cpp b/mlir/lib/Analysis/MemRefBoundCheck.cpp
index 8edf79d6db3..b90a799b794 100644
--- a/mlir/lib/Analysis/MemRefBoundCheck.cpp
+++ b/mlir/lib/Analysis/MemRefBoundCheck.cpp
@@ -47,7 +47,7 @@ FunctionPassBase *mlir::createMemRefBoundCheckPass() {
}
void MemRefBoundCheck::runOnFunction() {
- getFunction().walk([](Instruction *opInst) {
+ getFunction()->walk([](Instruction *opInst) {
if (auto loadOp = opInst->dyn_cast<LoadOp>()) {
boundCheckLoadOrStoreOp(loadOp);
} else if (auto storeOp = opInst->dyn_cast<StoreOp>()) {
diff --git a/mlir/lib/Analysis/MemRefDependenceCheck.cpp b/mlir/lib/Analysis/MemRefDependenceCheck.cpp
index 0206765f880..0c2a5defe10 100644
--- a/mlir/lib/Analysis/MemRefDependenceCheck.cpp
+++ b/mlir/lib/Analysis/MemRefDependenceCheck.cpp
@@ -113,7 +113,7 @@ static void checkDependences(ArrayRef<Instruction *> loadsAndStores) {
void MemRefDependenceCheck::runOnFunction() {
// Collect the loads and stores within the function.
loadsAndStores.clear();
- getFunction().walk([&](Instruction *inst) {
+ getFunction()->walk([&](Instruction *inst) {
if (inst->isa<LoadOp>() || inst->isa<StoreOp>())
loadsAndStores.push_back(inst);
});
diff --git a/mlir/lib/Analysis/ParallelismDetection.cpp b/mlir/lib/Analysis/ParallelismDetection.cpp
index 4c86e0c41fd..920511e7887 100644
--- a/mlir/lib/Analysis/ParallelismDetection.cpp
+++ b/mlir/lib/Analysis/ParallelismDetection.cpp
@@ -42,7 +42,7 @@ FunctionPassBase *mlir::createLoopParallelismDetectionPass() {
// Walks the function and marks all parallel 'for' ops with an attribute.
void LoopParallelismDetection::runOnFunction() {
- Function *f = &getFunction();
+ Function *f = getFunction();
FuncBuilder b(f);
f->walk<AffineForOp>([&](OpPointer<AffineForOp> forOp) {
forOp->getInstruction()->setAttr("parallel",
diff --git a/mlir/lib/EDSC/LowerEDSCTestPass.cpp b/mlir/lib/EDSC/LowerEDSCTestPass.cpp
index f904536e71d..aaf1747cdda 100644
--- a/mlir/lib/EDSC/LowerEDSCTestPass.cpp
+++ b/mlir/lib/EDSC/LowerEDSCTestPass.cpp
@@ -40,7 +40,7 @@ struct LowerEDSCTestPass : public FunctionPass<LowerEDSCTestPass> {
#include "mlir/EDSC/reference-impl.inc"
void LowerEDSCTestPass::runOnFunction() {
- getFunction().walk([](Instruction *op) {
+ getFunction()->walk([](Instruction *op) {
if (op->getName().getStringRef() == "print") {
auto opName = op->getAttrOfType<StringAttr>("op");
if (!opName) {
diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp
index 45a3970a274..598e4c83e55 100644
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -221,7 +221,7 @@ namespace {
/// Pass to verify a function and signal failure if necessary.
class FunctionVerifier : public FunctionPass<FunctionVerifier> {
void runOnFunction() {
- if (getFunction().verify())
+ if (getFunction()->verify())
signalPassFailure();
markAllAnalysesPreserved();
}
diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp
index 9812decbfbf..f4818961ca6 100644
--- a/mlir/lib/Transforms/CSE.cpp
+++ b/mlir/lib/Transforms/CSE.cpp
@@ -218,7 +218,7 @@ void CSE::simplifyBlockList(DominanceInfo &domInfo, BlockList &blockList) {
void CSE::runOnFunction() {
simplifyBlockList(getAnalysisResult<DominanceInfo>(),
- getFunction().getBlockList());
+ getFunction()->getBlockList());
// If no operations were erased, then we mark all analyses as preserved.
if (opsToErase.empty()) {
diff --git a/mlir/lib/Transforms/Canonicalizer.cpp b/mlir/lib/Transforms/Canonicalizer.cpp
index 17259bb19da..77244264cda 100644
--- a/mlir/lib/Transforms/Canonicalizer.cpp
+++ b/mlir/lib/Transforms/Canonicalizer.cpp
@@ -40,16 +40,16 @@ struct Canonicalizer : public FunctionPass<Canonicalizer> {
void Canonicalizer::runOnFunction() {
OwningRewritePatternList patterns;
- auto &func = getFunction();
+ auto *func = getFunction();
// TODO: Instead of adding all known patterns from the whole system lazily add
// and cache the canonicalization patterns for ops we see in practice when
// building the worklist. For now, we just grab everything.
- auto *context = func.getContext();
+ auto *context = func->getContext();
for (auto *op : context->getRegisteredOperations())
op->getCanonicalizationPatterns(patterns, context);
- applyPatternsGreedily(&func, std::move(patterns));
+ applyPatternsGreedily(func, std::move(patterns));
}
/// Create a Canonicalizer pass.
diff --git a/mlir/lib/Transforms/ConstantFold.cpp b/mlir/lib/Transforms/ConstantFold.cpp
index d3da8c17580..6bdb1bffab3 100644
--- a/mlir/lib/Transforms/ConstantFold.cpp
+++ b/mlir/lib/Transforms/ConstantFold.cpp
@@ -97,7 +97,7 @@ void ConstantFold::runOnFunction() {
existingConstants.clear();
opInstsToErase.clear();
- getFunction().walk([&](Instruction *inst) { foldInstruction(inst); });
+ getFunction()->walk([&](Instruction *inst) { foldInstruction(inst); });
// At this point, these operations are dead, remove them.
// TODO: This is assuming that all constant foldable operations have no
diff --git a/mlir/lib/Transforms/DmaGeneration.cpp b/mlir/lib/Transforms/DmaGeneration.cpp
index 91d53528870..44b4d9528e9 100644
--- a/mlir/lib/Transforms/DmaGeneration.cpp
+++ b/mlir/lib/Transforms/DmaGeneration.cpp
@@ -754,7 +754,7 @@ uint64_t DmaGeneration::runOnBlock(Block::iterator begin, Block::iterator end) {
}
void DmaGeneration::runOnFunction() {
- Function *f = &getFunction();
+ Function *f = getFunction();
FuncBuilder topBuilder(f);
zeroIndex = topBuilder.create<ConstantIndexOp>(f->getLoc(), 0);
diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp
index 1e4e020b435..7466e4968a6 100644
--- a/mlir/lib/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Transforms/LoopFusion.cpp
@@ -2202,7 +2202,7 @@ void LoopFusion::runOnFunction() {
}
MemRefDependenceGraph g;
- if (g.init(&getFunction()))
+ if (g.init(getFunction()))
GreedyFusion(&g, localBufSizeThreshold, fastMemorySpace).run();
}
diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp
index 4aebbc2e856..e58de3bc136 100644
--- a/mlir/lib/Transforms/LoopTiling.cpp
+++ b/mlir/lib/Transforms/LoopTiling.cpp
@@ -255,7 +255,7 @@ getTileableBands(Function *f,
void LoopTiling::runOnFunction() {
std::vector<SmallVector<OpPointer<AffineForOp>, 6>> bands;
- getTileableBands(&getFunction(), &bands);
+ getTileableBands(getFunction(), &bands);
for (auto &band : bands) {
// Set up tile sizes; fill missing tile sizes at the end with default tile
diff --git a/mlir/lib/Transforms/LoopUnroll.cpp b/mlir/lib/Transforms/LoopUnroll.cpp
index 4cf65b4dc83..40da2f63f62 100644
--- a/mlir/lib/Transforms/LoopUnroll.cpp
+++ b/mlir/lib/Transforms/LoopUnroll.cpp
@@ -129,11 +129,13 @@ void LoopUnroll::runOnFunction() {
// Gathers all loops with trip count <= minTripCount. Do a post order walk
// so that loops are gathered from innermost to outermost (or else unrolling
// an outer one may delete gathered inner ones).
- getFunction().walkPostOrder<AffineForOp>([&](OpPointer<AffineForOp> forOp) {
- Optional<uint64_t> tripCount = getConstantTripCount(forOp);
- if (tripCount.hasValue() && tripCount.getValue() <= clUnrollFullThreshold)
- loops.push_back(forOp);
- });
+ getFunction()->walkPostOrder<AffineForOp>(
+ [&](OpPointer<AffineForOp> forOp) {
+ Optional<uint64_t> tripCount = getConstantTripCount(forOp);
+ if (tripCount.hasValue() &&
+ tripCount.getValue() <= clUnrollFullThreshold)
+ loops.push_back(forOp);
+ });
for (auto forOp : loops)
loopUnrollFull(forOp);
return;
@@ -143,7 +145,7 @@ void LoopUnroll::runOnFunction() {
? clUnrollNumRepetitions
: 1;
// If the call back is provided, we will recurse until no loops are found.
- Function *func = &getFunction();
+ Function *func = getFunction();
for (unsigned i = 0; i < numRepetitions || getUnrollFactor; i++) {
InnermostLoopGatherer ilg;
ilg.walkPostOrder(func);
diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp
index 6d04b8492ea..63fc451287b 100644
--- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp
+++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp
@@ -91,7 +91,7 @@ void LoopUnrollAndJam::runOnFunction() {
// Currently, just the outermost loop from the first loop nest is
// unroll-and-jammed by this pass. However, runOnAffineForOp can be called on
// any for operation.
- auto &entryBlock = getFunction().front();
+ auto &entryBlock = getFunction()->front();
if (auto forOp = entryBlock.front().dyn_cast<AffineForOp>())
runOnAffineForOp(forOp);
}
diff --git a/mlir/lib/Transforms/LowerAffine.cpp b/mlir/lib/Transforms/LowerAffine.cpp
index 3776403a931..31232ce7fe4 100644
--- a/mlir/lib/Transforms/LowerAffine.cpp
+++ b/mlir/lib/Transforms/LowerAffine.cpp
@@ -608,7 +608,7 @@ void LowerAffinePass::runOnFunction() {
// 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.
- getFunction().walk([&](Instruction *inst) {
+ getFunction()->walk([&](Instruction *inst) {
if (inst->isa<AffineApplyOp>() || inst->isa<AffineForOp>() ||
inst->isa<AffineIfOp>())
instsToRewrite.push_back(inst);
diff --git a/mlir/lib/Transforms/LowerVectorTransfers.cpp b/mlir/lib/Transforms/LowerVectorTransfers.cpp
index e3ad4297ace..9ac8583bc78 100644
--- a/mlir/lib/Transforms/LowerVectorTransfers.cpp
+++ b/mlir/lib/Transforms/LowerVectorTransfers.cpp
@@ -426,7 +426,7 @@ public:
struct LowerVectorTransfersPass
: public FunctionPass<LowerVectorTransfersPass> {
void runOnFunction() {
- Function *f = &getFunction();
+ Function *f = getFunction();
applyMLPatternsGreedily<VectorTransferExpander<VectorTransferReadOp>,
VectorTransferExpander<VectorTransferWriteOp>>(f);
}
diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp
index 9f4027ea4fc..0d54ead424e 100644
--- a/mlir/lib/Transforms/MaterializeVectors.cpp
+++ b/mlir/lib/Transforms/MaterializeVectors.cpp
@@ -733,7 +733,7 @@ void MaterializeVectorsPass::runOnFunction() {
NestedPatternContext mlContext;
// TODO(ntv): Check to see if this supports arbitrary top-level code.
- Function *f = &getFunction();
+ Function *f = getFunction();
if (f->getBlocks().size() != 1)
return;
diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
index 4fc544074c0..f48f90923ce 100644
--- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
+++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
@@ -211,8 +211,8 @@ void MemRefDataFlowOpt::forwardStoreToLoad(OpPointer<LoadOp> loadOp) {
void MemRefDataFlowOpt::runOnFunction() {
// Only supports single block functions at the moment.
- Function &f = getFunction();
- if (f.getBlocks().size() != 1) {
+ Function *f = getFunction();
+ if (f->getBlocks().size() != 1) {
markAllAnalysesPreserved();
return;
}
@@ -224,7 +224,8 @@ void MemRefDataFlowOpt::runOnFunction() {
memrefsToErase.clear();
// Walk all load's and perform load/store forwarding.
- f.walk<LoadOp>([&](OpPointer<LoadOp> loadOp) { forwardStoreToLoad(loadOp); });
+ 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) {
diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp
index cdce5230ba6..08115eddbe7 100644
--- a/mlir/lib/Transforms/PipelineDataTransfer.cpp
+++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp
@@ -146,7 +146,7 @@ void PipelineDataTransfer::runOnFunction() {
// deleted and replaced by a prologue, a new steady-state loop and an
// epilogue).
forOps.clear();
- getFunction().walkPostOrder<AffineForOp>(
+ getFunction()->walkPostOrder<AffineForOp>(
[&](OpPointer<AffineForOp> forOp) { forOps.push_back(forOp); });
for (auto forOp : forOps)
runOnAffineForOp(forOp);
diff --git a/mlir/lib/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Transforms/SimplifyAffineStructures.cpp
index 3adcbe038ea..8a8e7af1089 100644
--- a/mlir/lib/Transforms/SimplifyAffineStructures.cpp
+++ b/mlir/lib/Transforms/SimplifyAffineStructures.cpp
@@ -58,7 +58,7 @@ static IntegerSet simplifyIntegerSet(IntegerSet set) {
}
void SimplifyAffineStructures::runOnFunction() {
- getFunction().walk([&](Instruction *opInst) {
+ getFunction()->walk([&](Instruction *opInst) {
for (auto attr : opInst->getAttrs()) {
if (auto mapAttr = attr.second.dyn_cast<AffineMapAttr>()) {
MutableAffineMap mMap(mapAttr.getValue());
diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp
index 47244f94ac9..f8f90c0cdb1 100644
--- a/mlir/lib/Transforms/StripDebugInfo.cpp
+++ b/mlir/lib/Transforms/StripDebugInfo.cpp
@@ -29,12 +29,12 @@ struct StripDebugInfo : public FunctionPass<StripDebugInfo> {
} // end anonymous namespace
void StripDebugInfo::runOnFunction() {
- Function &func = getFunction();
- UnknownLoc unknownLoc = UnknownLoc::get(func.getContext());
+ Function *func = getFunction();
+ UnknownLoc unknownLoc = UnknownLoc::get(func->getContext());
// Strip the debug info from the function and its instructions.
- func.setLoc(unknownLoc);
- func.walk([&](Instruction *inst) { inst->setLoc(unknownLoc); });
+ func->setLoc(unknownLoc);
+ func->walk([&](Instruction *inst) { inst->setLoc(unknownLoc); });
}
/// Creates a pass to strip debug information from a function.
diff --git a/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp b/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp
index fa9c4bc7e7d..8fd1cac201c 100644
--- a/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp
+++ b/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp
@@ -264,7 +264,7 @@ void VectorizerTestPass::runOnFunction() {
NestedPatternContext mlContext;
// Only support single block functions at this point.
- Function *f = &getFunction();
+ Function *f = getFunction();
if (f->getBlocks().size() != 1)
return;
diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp
index d8e5714962e..b084b016be3 100644
--- a/mlir/lib/Transforms/Vectorize.cpp
+++ b/mlir/lib/Transforms/Vectorize.cpp
@@ -1262,7 +1262,7 @@ void Vectorize::runOnFunction() {
// Thread-safe RAII local context, BumpPtrAllocator freed on exit.
NestedPatternContext mlContext;
- Function *f = &getFunction();
+ Function *f = getFunction();
for (auto &pat : makePatterns()) {
LLVM_DEBUG(dbgs() << "\n******************************************");
LLVM_DEBUG(dbgs() << "\n******************************************");
diff --git a/mlir/lib/Transforms/ViewFunctionGraph.cpp b/mlir/lib/Transforms/ViewFunctionGraph.cpp
index b2dfe6795b6..d77e96a99d7 100644
--- a/mlir/lib/Transforms/ViewFunctionGraph.cpp
+++ b/mlir/lib/Transforms/ViewFunctionGraph.cpp
@@ -78,7 +78,7 @@ struct PrintCFGPass : public FunctionPass<PrintCFGPass> {
const llvm::Twine &title = "")
: os(os), shortNames(shortNames), title(title) {}
void runOnFunction() {
- mlir::writeGraph(os, &getFunction(), shortNames, title);
+ mlir::writeGraph(os, getFunction(), shortNames, title);
}
private:
OpenPOWER on IntegriCloud