[flang-commits] [flang] [flang] Erase `fir.local` ops before lowering `fir` to `llvm` (PR #143687)
via flang-commits
flang-commits at lists.llvm.org
Wed Jun 11 05:06:58 PDT 2025
================
@@ -3294,6 +3294,29 @@ struct LoadOpConversion : public fir::FIROpConversion<fir::LoadOp> {
}
};
+struct LocalitySpecifierOpConversion
+ : public fir::FIROpConversion<fir::LocalitySpecifierOp> {
+ using FIROpConversion::FIROpConversion;
+ llvm::LogicalResult
+ matchAndRewrite(fir::LocalitySpecifierOp localizer, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const override {
+ auto uses = mlir::SymbolTable::getSymbolUses(
----------------
jeanPerier wrote:
I am afraid this may be a bit expensive on big programs. I think this will walk the whole IR to check for usages. So, this is likely introducing a `number_of_fir_local * number_of_operation_in_module` behavior, and `number_of_operation_in_module` can be quite big in some apps (>1million).
I would unconditionally erase it at that point in the pipeline (and let any bogus later usage complain if it fails to find the symbol), maybe leaving this check as an assert under `#ifdef EXPENSIVE_CHECKS`.
If at some point we do need the flexibility of this pass to actually leave fir.local in place when still used for some reason, we should use a SymbolUserMap created once and maintained.
https://github.com/llvm/llvm-project/pull/143687
More information about the flang-commits
mailing list