[flang-commits] [flang] [Flang] add support for collapsed io calls for implicit do loops (PR #212646)
Jason Van Beusekom via flang-commits
flang-commits at lists.llvm.org
Wed Jul 29 13:50:58 PDT 2026
================
@@ -701,6 +701,244 @@ static mlir::func::FuncOp getOutputFunc(mlir::Location loc,
builder);
}
+/// Return the evaluate expression of a non-implied-do io item, or nullptr if
+/// the item is itself an io-implied-do.
+static const Fortran::lower::SomeExpr *
+getIoItemLeafExpr(const Fortran::parser::OutputItem &item) {
+ if (const auto *parserExpr = std::get_if<Fortran::parser::Expr>(&item.u))
+ return Fortran::semantics::GetExpr(*parserExpr);
+ return nullptr;
+}
+static const Fortran::lower::SomeExpr *
+getIoItemLeafExpr(const Fortran::parser::InputItem &item) {
+ if (const auto *var = std::get_if<Fortran::parser::Variable>(&item.u))
+ return Fortran::semantics::GetExpr(*var);
+ return nullptr;
+}
+
+template <typename A>
+static bool ioExprReferencesSymbol(const A &expr,
+ const Fortran::semantics::Symbol &sym) {
+ const Fortran::semantics::Symbol &ultimate = sym.GetUltimate();
+ for (const Fortran::semantics::SymbolRef &ref :
+ Fortran::evaluate::CollectSymbols(expr)) {
+ if (&ref->GetUltimate() == &ultimate)
+ return true;
+ }
+ return false;
+}
----------------
Jason-Van-Beusekom wrote:
In https://github.com/llvm/llvm-project/pull/212646/commits/7d7669f1398a9d2eb4ae5afa7ae784895fc2bbde I added guards to fallback on the provided cases, are there any other cases that concern you?
https://github.com/llvm/llvm-project/pull/212646
More information about the flang-commits
mailing list