16
16
#include " mlir/Dialect/Bufferization/Transforms/Transforms.h"
17
17
#include " mlir/Dialect/Func/IR/FuncOps.h"
18
18
#include " mlir/Dialect/MemRef/IR/MemRef.h"
19
+ #include " mlir/IR/Diagnostics.h"
19
20
#include " mlir/IR/Operation.h"
20
21
#include " mlir/Interfaces/SideEffectInterfaces.h"
21
22
#include " mlir/Pass/PassManager.h"
@@ -221,6 +222,12 @@ struct OneShotBufferizePass
221
222
// Configure type converter.
222
223
LayoutMapOption unknownTypeConversionOption =
223
224
parseLayoutMapOption (unknownTypeConversion);
225
+ if (unknownTypeConversionOption == LayoutMapOption::InferLayoutMap) {
226
+ emitError (UnknownLoc::get (&getContext ()),
227
+ " Invalid option: 'infer-layout-map' is not a valid value for "
228
+ " 'unknown-type-conversion'" );
229
+ return signalPassFailure ();
230
+ }
224
231
opt.unknownTypeConverterFn = [=](Value value, Attribute memorySpace,
225
232
const BufferizationOptions &options) {
226
233
auto tensorType = cast<TensorType>(value.getType ());
@@ -248,6 +255,31 @@ struct OneShotBufferizePass
248
255
opt = *options;
249
256
}
250
257
258
+ if (opt.copyBeforeWrite && opt.testAnalysisOnly ) {
259
+ // These two flags do not make sense together: "copy-before-write"
260
+ // indicates that copies should be inserted before every memory write,
261
+ // but "test-analysis-only" indicates that only the analysis should be
262
+ // tested. (I.e., no IR is bufferized.)
263
+ emitError (UnknownLoc::get (&getContext ()),
264
+ " Invalid option: 'copy-before-write' cannot be used with "
265
+ " 'test-analysis-only'" );
266
+ return signalPassFailure ();
267
+ }
268
+
269
+ if (opt.printConflicts && !opt.testAnalysisOnly ) {
270
+ emitError (
271
+ UnknownLoc::get (&getContext ()),
272
+ " Invalid option: 'print-conflicts' requires 'test-analysis-only'" );
273
+ return signalPassFailure ();
274
+ }
275
+
276
+ if (opt.dumpAliasSets && !opt.testAnalysisOnly ) {
277
+ emitError (
278
+ UnknownLoc::get (&getContext ()),
279
+ " Invalid option: 'dump-alias-sets' requires 'test-analysis-only'" );
280
+ return signalPassFailure ();
281
+ }
282
+
251
283
BufferizationStatistics statistics;
252
284
ModuleOp moduleOp = getOperation ();
253
285
if (opt.bufferizeFunctionBoundaries ) {
@@ -256,8 +288,12 @@ struct OneShotBufferizePass
256
288
return ;
257
289
}
258
290
} else {
259
- assert (opt.noAnalysisFuncFilter .empty () &&
260
- " invalid combination of bufferization flags" );
291
+ if (!opt.noAnalysisFuncFilter .empty ()) {
292
+ emitError (UnknownLoc::get (&getContext ()),
293
+ " Invalid option: 'no-analysis-func-filter' requires "
294
+ " 'bufferize-function-boundaries'" );
295
+ return signalPassFailure ();
296
+ }
261
297
if (failed (runOneShotBufferize (moduleOp, opt, &statistics))) {
262
298
signalPassFailure ();
263
299
return ;
0 commit comments