Skip to content

Commit 72a8893

Browse files
authored
Revert "[MLIR] Add bufferization state class to OneShotBufferization pass" (#141012)
Reverts #138143 The PR for the BufferizationState is temporarily reverted due to API incompatibilities that have been initially missed during the update and were not catched by PR checks.
1 parent 11953c6 commit 72a8893

27 files changed

+86
-214
lines changed

mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -578,20 +578,6 @@ class AnalysisState {
578578
insideMutuallyExclusiveRegionsCache;
579579
};
580580

581-
/// BufferizationState provides information about the state of the IR during the
582-
/// bufferization process.
583-
class BufferizationState {
584-
public:
585-
/// Get a reference to the collection of cached symbol tables.
586-
SymbolTableCollection &getSymbolTables();
587-
588-
private:
589-
/// The cached symbol tables.
590-
/// The user is expected to update / invalidate the cached symbol tables if
591-
/// the bufferized operation has the Symbol or SymbolTable traits.
592-
SymbolTableCollection symbolTables;
593-
};
594-
595581
/// Create an AllocTensorOp for the given shaped value (memref or tensor).
596582
/// If `copy` is set, the shaped value is copied. Otherwise, a tensor with
597583
/// undefined contents is allocated.

mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,7 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
426426
/*retType=*/"::llvm::LogicalResult",
427427
/*methodName=*/"bufferize",
428428
/*args=*/(ins "::mlir::RewriterBase &":$rewriter,
429-
"const ::mlir::bufferization::BufferizationOptions &":$options,
430-
"::mlir::bufferization::BufferizationState &":$state),
429+
"const ::mlir::bufferization::BufferizationOptions &":$options),
431430
/*methodBody=*/"",
432431
/*defaultImplementation=*/[{
433432
llvm_unreachable("bufferize not implemented");

mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ def Bufferization_AllocTensorOp : Bufferization_Op<"alloc_tensor",
9393

9494
let extraClassDeclaration = [{
9595
LogicalResult bufferize(RewriterBase &rewriter,
96-
const BufferizationOptions &options,
97-
BufferizationState &state);
96+
const BufferizationOptions &options);
9897

9998
bool resultBufferizesToMemoryWrite(OpResult opResult,
10099
const AnalysisState &state);
@@ -283,8 +282,7 @@ def Bufferization_MaterializeInDestinationOp
283282

284283
let extraClassDeclaration = [{
285284
LogicalResult bufferize(RewriterBase &rewriter,
286-
const BufferizationOptions &options,
287-
BufferizationState &state);
285+
const BufferizationOptions &options);
288286

289287
bool bufferizesToMemoryRead(OpOperand &opOperand,
290288
const AnalysisState &state);
@@ -377,8 +375,7 @@ def Bufferization_DeallocTensorOp : Bufferization_Op<"dealloc_tensor",
377375
}
378376

379377
LogicalResult bufferize(RewriterBase &rewriter,
380-
const BufferizationOptions &options,
381-
BufferizationState &state);
378+
const BufferizationOptions &options);
382379
}];
383380
}
384381

@@ -461,8 +458,7 @@ def Bufferization_ToTensorOp : Bufferization_Op<"to_tensor", [
461458
//===------------------------------------------------------------------===//
462459

463460
LogicalResult bufferize(RewriterBase &rewriter,
464-
const BufferizationOptions &options,
465-
BufferizationState &state) const {
461+
const BufferizationOptions &options) const {
466462
// to_tensor/to_buffer pairs fold away after bufferization.
467463
return success();
468464
}
@@ -554,8 +550,7 @@ def Bufferization_ToBufferOp : Bufferization_Op<"to_buffer", [
554550
}
555551

556552
LogicalResult bufferize(RewriterBase &rewriter,
557-
const BufferizationOptions &options,
558-
BufferizationState &state);
553+
const BufferizationOptions &options);
559554
}];
560555

561556
let assemblyFormat = [{

mlir/include/mlir/Dialect/Bufferization/Transforms/BufferUtils.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class GlobalOp;
2929
} // namespace memref
3030

3131
namespace bufferization {
32-
class BufferizationState;
3332

3433
/// A simple analysis that detects allocation operations.
3534
class BufferPlacementAllocs {
@@ -123,14 +122,9 @@ class BufferPlacementTransformationBase {
123122
// Globals are created lazily at the top of the enclosing ModuleOp with pretty
124123
// names. Duplicates are avoided.
125124
FailureOr<memref::GlobalOp> getGlobalFor(arith::ConstantOp constantOp,
126-
SymbolTableCollection &symbolTables,
127125
uint64_t alignment,
128126
Attribute memorySpace = {});
129127

130-
void removeSymbol(Operation *op, BufferizationState &state);
131-
132-
void insertSymbol(Operation *op, BufferizationState &state);
133-
134128
} // namespace bufferization
135129
} // namespace mlir
136130

mlir/include/mlir/Dialect/Bufferization/Transforms/Bufferize.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ struct BufferizationStatistics {
4545
/// additional buffer copies or set "options.copyBeforeWrite = true". The
4646
/// general bufferization entry point is `runOneShotBufferize`.
4747
LogicalResult bufferizeOp(Operation *op, const BufferizationOptions &options,
48-
BufferizationState &bufferizationState,
4948
BufferizationStatistics *statistics = nullptr);
5049

5150
/// Bufferize the signature of `block` and its callers (i.e., ops that have the

mlir/include/mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ LogicalResult analyzeOp(Operation *op, OneShotAnalysisState &state,
270270
/// Run One-Shot Bufferize on the given op: Analysis + Bufferization
271271
LogicalResult
272272
runOneShotBufferize(Operation *op, const OneShotBufferizationOptions &options,
273-
BufferizationState &state,
274273
BufferizationStatistics *statistics = nullptr);
275274

276275
} // namespace bufferization

mlir/include/mlir/Dialect/Bufferization/Transforms/OneShotModuleBufferize.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace bufferization {
2020
struct BufferizationStatistics;
2121
class OneShotAnalysisState;
2222
struct OneShotBufferizationOptions;
23-
class BufferizationState;
2423

2524
/// Analyze `moduleOp` and its nested ops. Bufferization decisions are stored in
2625
/// `state`.
@@ -39,7 +38,6 @@ analyzeModuleOp(ModuleOp moduleOp, OneShotAnalysisState &state,
3938
/// will be inserted only to these FuncOps.
4039
llvm::LogicalResult
4140
bufferizeModuleOp(ModuleOp moduleOp, const OneShotBufferizationOptions &options,
42-
BufferizationState &state,
4341
BufferizationStatistics *statistics = nullptr);
4442

4543
/// Remove bufferization attributes on every FuncOp arguments in the ModuleOp.
@@ -52,7 +50,7 @@ void removeBufferizationAttributesInModule(ModuleOp moduleOp);
5250
llvm::LogicalResult runOneShotModuleBufferize(
5351
ModuleOp moduleOp,
5452
const bufferization::OneShotBufferizationOptions &options,
55-
BufferizationState &state, BufferizationStatistics *statistics = nullptr);
53+
BufferizationStatistics *statistics = nullptr);
5654

5755
} // namespace bufferization
5856
} // namespace mlir

mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace mlir {
3030
namespace bufferization {
3131
class AllocTensorOp;
3232
class OneShotAnalysisState;
33-
class BufferizationState;
3433
} // namespace bufferization
3534

3635
namespace linalg {

mlir/lib/Dialect/Arith/Transforms/BufferizableOpInterfaceImpl.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ struct ConstantOpInterface
2424
: public BufferizableOpInterface::ExternalModel<ConstantOpInterface,
2525
arith::ConstantOp> {
2626
LogicalResult bufferize(Operation *op, RewriterBase &rewriter,
27-
const BufferizationOptions &options,
28-
BufferizationState &state) const {
27+
const BufferizationOptions &options) const {
2928
auto constantOp = cast<arith::ConstantOp>(op);
3029
auto type = dyn_cast<RankedTensorType>(constantOp.getType());
3130

@@ -47,8 +46,7 @@ struct ConstantOpInterface
4746
// Create global memory segment and replace tensor with memref pointing to
4847
// that memory segment.
4948
FailureOr<memref::GlobalOp> globalOp =
50-
getGlobalFor(constantOp, state.getSymbolTables(),
51-
options.bufferAlignment, memorySpace);
49+
getGlobalFor(constantOp, options.bufferAlignment, memorySpace);
5250
if (failed(globalOp))
5351
return failure();
5452
memref::GlobalOp globalMemref = *globalOp;
@@ -85,8 +83,7 @@ struct IndexCastOpInterface
8583
}
8684

8785
LogicalResult bufferize(Operation *op, RewriterBase &rewriter,
88-
const BufferizationOptions &options,
89-
BufferizationState &state) const {
86+
const BufferizationOptions &options) const {
9087
auto castOp = cast<arith::IndexCastOp>(op);
9188
auto resultTensorType = cast<TensorType>(castOp.getType());
9289

@@ -134,8 +131,7 @@ struct SelectOpInterface
134131
}
135132

136133
LogicalResult bufferize(Operation *op, RewriterBase &rewriter,
137-
const BufferizationOptions &options,
138-
BufferizationState &state) const {
134+
const BufferizationOptions &options) const {
139135
auto selectOp = cast<arith::SelectOp>(op);
140136
Location loc = selectOp.getLoc();
141137

mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ void AnalysisState::resetCache() {
125125
insideMutuallyExclusiveRegionsCache.clear();
126126
}
127127

128-
SymbolTableCollection &BufferizationState::getSymbolTables() {
129-
return symbolTables;
130-
}
131-
132128
Region *bufferization::getNextEnclosingRepetitiveRegion(
133129
Region *region, const BufferizationOptions &options) {
134130
assert(isRepetitiveRegion(region, options) && "expected repetitive region");

0 commit comments

Comments
 (0)