[Mlir-commits] [mlir] b7858f8 - [mlir][bufferization][NFC] Simplify func bufferization state
Matthias Springer
llvmlistbot at llvm.org
Mon Jan 30 01:19:01 PST 2023
Author: Matthias Springer
Date: 2023-01-30T10:14:10+01:00
New Revision: b7858f85f54c92ea6db2cd94247dea41c0e64026
URL: https://github.com/llvm/llvm-project/commit/b7858f85f54c92ea6db2cd94247dea41c0e64026
DIFF: https://github.com/llvm/llvm-project/commit/b7858f85f54c92ea6db2cd94247dea41c0e64026.diff
LOG: [mlir][bufferization][NFC] Simplify func bufferization state
The analysis previous kept track of OpOperand -> OpResult and OpResult -> OpOperand aliasing mappings. Only one mapping is needed, the other one can be inferred.
Differential Revision: https://reviews.llvm.org/D142128
Added:
Modified:
mlir/include/mlir/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.h
mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.h b/mlir/include/mlir/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.h
index 8d9caf30a6881..0b91d3d675b7c 100644
--- a/mlir/include/mlir/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.h
+++ b/mlir/include/mlir/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.h
@@ -52,9 +52,6 @@ struct FuncAnalysisState : public OneShotAnalysisState::Extension {
/// indices.
DenseMap<FuncOp, IndexMapping> equivalentFuncArgs;
- /// A mapping of ReturnOp OpOperand indices to aliasing FuncOp BBArg indices.
- DenseMap<FuncOp, IndexToIndexListMapping> aliasingFuncArgs;
-
/// A mapping of FuncOp BBArg indices to aliasing ReturnOp OpOperand indices.
DenseMap<FuncOp, IndexToIndexListMapping> aliasingReturnVals;
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
index 2a6c6af89654f..d25dd41c0ab4d 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
@@ -23,20 +23,16 @@ namespace func_ext {
void FuncAnalysisState::startFunctionAnalysis(FuncOp funcOp) {
analyzedFuncOps[funcOp] = FuncOpAnalysisState::InProgress;
auto createdEquiv = equivalentFuncArgs.try_emplace(funcOp, IndexMapping());
- auto createdAliasingOperands =
- aliasingFuncArgs.try_emplace(funcOp, IndexToIndexListMapping());
auto createdAliasingResults =
aliasingReturnVals.try_emplace(funcOp, IndexToIndexListMapping());
auto createdRead = readBbArgs.try_emplace(funcOp, BbArgIndexSet());
auto createdWritten = writtenBbArgs.try_emplace(funcOp, BbArgIndexSet());
(void)createdEquiv;
- (void)createdAliasingOperands;
(void)createdAliasingResults;
(void)createdRead;
(void)createdWritten;
#ifndef NDEBUG
assert(createdEquiv.second && "equivalence info exists already");
- assert(createdAliasingOperands.second && "aliasing info exists already");
assert(createdAliasingResults.second && "aliasing info exists already");
assert(createdRead.second && "bbarg access info exists already");
assert(createdWritten.second && "bbarg access info exists already");
@@ -196,26 +192,6 @@ struct CallOpInterface
return result;
}
- SmallVector<OpOperand *>
- getAliasingOpOperand(Operation *op, OpResult opResult,
- const AnalysisState &state) const {
- func::CallOp callOp = cast<func::CallOp>(op);
- FuncOp funcOp = getCalledFunction(callOp);
- assert(funcOp && "expected CallOp to a FuncOp");
- if (getFuncOpAnalysisState(state, funcOp) != FuncOpAnalysisState::Analyzed)
- // FuncOp not analyzed yet. Any OpOperand may be aliasing.
- return detail::unknownGetAliasingOpOperand(opResult);
-
- // Get aliasing bbArgs from state.
- const FuncAnalysisState &funcState = getFuncAnalysisState(state);
- auto aliasingFuncArgs = funcState.aliasingFuncArgs.lookup(funcOp).lookup(
- opResult.getResultNumber());
- SmallVector<OpOperand *> result;
- for (int64_t bbArgIdx : aliasingFuncArgs)
- result.push_back(&callOp->getOpOperand(bbArgIdx));
- return result;
- }
-
BufferRelation bufferRelation(Operation *op, OpResult opResult,
const AnalysisState &state) const {
func::CallOp callOp = cast<func::CallOp>(op);
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp
index 6584dfda4eb7c..f1211bb878f2b 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp
@@ -139,7 +139,6 @@ aliasingFuncOpBBArgsAnalysis(FuncOp funcOp, OneShotAnalysisState &state,
continue;
int64_t returnIdx = resultIt.index();
int64_t bbArgIdx = inputIt.index();
- funcState.aliasingFuncArgs[funcOp][returnIdx].push_back(bbArgIdx);
funcState.aliasingReturnVals[funcOp][bbArgIdx].push_back(returnIdx);
}
}
@@ -161,10 +160,8 @@ aliasingFuncOpBBArgsAnalysis(FuncOp funcOp, OneShotAnalysisState &state,
if (state.getOptions().testAnalysisOnly)
annotateEquivalentReturnBbArg(returnVal, bbArg);
}
- if (state.areAliasingBufferizedValues(returnVal.get(), bbArg)) {
- funcState.aliasingFuncArgs[funcOp][returnIdx].push_back(bbArgIdx);
+ if (state.areAliasingBufferizedValues(returnVal.get(), bbArg))
funcState.aliasingReturnVals[funcOp][bbArgIdx].push_back(returnIdx);
- }
}
return success();
More information about the Mlir-commits
mailing list