@@ -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,
@@ -301,21 +303,15 @@ class CodeGenRewrite : public fir::impl::CodeGenRewriteBase<CodeGenRewrite> {
301
303
patterns.insert <EmboxConversion, ArrayCoorConversion, ReboxConversion,
302
304
DeclareOpConversion>(&context);
303
305
if (mlir::failed (
304
- mlir::applyPartialConversion (op , target, std::move (patterns)))) {
306
+ mlir::applyPartialConversion (mod , target, std::move (patterns)))) {
305
307
mlir::emitError (mlir::UnknownLoc::get (&context),
306
308
" error in running the pre-codegen conversions" );
307
309
signalPassFailure ();
308
310
return ;
309
311
}
310
312
// Erase any residual (fir.shape, fir.slice...).
311
313
mlir::IRRewriter rewriter (&context);
312
- (void )mlir::runRegionDCE (rewriter, op->getRegions ());
313
- }
314
-
315
- void runOnOperation () override final {
316
- // Call runOn on all top level regions that may contain emboxOp/arrayCoorOp.
317
- mlir::ModuleOp mod = getOperation ();
318
- runOn (mod);
314
+ (void )mlir::runRegionDCE (rewriter, mod->getRegions ());
319
315
}
320
316
};
321
317
0 commit comments