@@ -283,7 +283,9 @@ class DeclareOpConversion : public mlir::OpRewritePattern<fir::DeclareOp> {
283
283
284
284
class CodeGenRewrite : public fir ::impl::CodeGenRewriteBase<CodeGenRewrite> {
285
285
public:
286
- void runOn (mlir::Operation *op) {
286
+ void runOnOperation () override final {
287
+ mlir::ModuleOp mod = getOperation ();
288
+
287
289
auto &context = getContext ();
288
290
mlir::ConversionTarget target (context);
289
291
target.addLegalDialect <mlir::arith::ArithDialect, fir::FIROpsDialect,
@@ -300,21 +302,15 @@ class CodeGenRewrite : public fir::impl::CodeGenRewriteBase<CodeGenRewrite> {
300
302
mlir::RewritePatternSet patterns (&context);
301
303
fir::populatePreCGRewritePatterns (patterns);
302
304
if (mlir::failed (
303
- mlir::applyPartialConversion (op , target, std::move (patterns)))) {
305
+ mlir::applyPartialConversion (mod , target, std::move (patterns)))) {
304
306
mlir::emitError (mlir::UnknownLoc::get (&context),
305
307
" error in running the pre-codegen conversions" );
306
308
signalPassFailure ();
307
309
return ;
308
310
}
309
311
// Erase any residual (fir.shape, fir.slice...).
310
312
mlir::IRRewriter rewriter (&context);
311
- (void )mlir::runRegionDCE (rewriter, op->getRegions ());
312
- }
313
-
314
- void runOnOperation () override final {
315
- // Call runOn on all top level regions that may contain emboxOp/arrayCoorOp.
316
- mlir::ModuleOp mod = getOperation ();
317
- runOn (mod);
313
+ (void )mlir::runRegionDCE (rewriter, mod->getRegions ());
318
314
}
319
315
};
320
316
0 commit comments