[flang-commits] [flang] [flang] Propagate INTENT(IN) dummy arguments as readonly (PR #207732)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Wed Jul 8 09:10:11 PDT 2026


================
@@ -187,6 +187,30 @@ asImplicitArg(Fortran::evaluate::characteristics::DummyDataObject &&dummy) {
                                                        std::move(shape)));
 }
 
+/// An INTENT(IN) data object passed by reference is not modified by the callee,
----------------
vzakhari wrote:

> Some duplication already exists - FIR AliasAnalysis explicitly notes that TARGET is represented both on the declaration and the entry-block argument.

This is true, but I believe they remain there for historical reasons, and will be removed eventually. @jeanPerier may correct me if I am wrong.

> but a generic solution needs additional care:

This is also true, but properly propagating attributes on the function arguments from the lowering to the late pipeline stages seems to be a bigger challenge to me (again, I agree that we already rely on being lucky to do that).

I would rather have the "declare" attributes propagated all the way to the late pipeline (i.e., if needed, propagate it to `fircg.ext_declare`, etc.), and then use them to backtrack the information to the function arguments.

With all that said, I do not want to push back too hard because you are adding a valuable feature. If @jeanPerier is okay with the lowering changes, I will support this PR.

https://github.com/llvm/llvm-project/pull/207732


More information about the flang-commits mailing list