[flang-commits] [flang] [flang] Propagate INTENT(IN) dummy arguments as readonly (PR #207732)
via flang-commits
flang-commits at lists.llvm.org
Mon Jul 6 06:56:08 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- flang/include/flang/Optimizer/Dialect/FIROpsSupport.h flang/lib/Lower/CallInterface.cpp flang/lib/Optimizer/Passes/Pipelines.cpp flang/lib/Optimizer/Transforms/FunctionAttr.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp
index 282e9c1c2..c29e12fa3 100644
--- a/flang/lib/Lower/CallInterface.cpp
+++ b/flang/lib/Lower/CallInterface.cpp
@@ -196,11 +196,11 @@ asImplicitArg(Fortran::evaluate::characteristics::DummyDataObject &&dummy) {
/// - ASYNCHRONOUS memory may change underneath the callee;
/// - VOLATILE+INTENT(IN) is prohibited by the standard (C870); kept here
/// defensively.
-/// TARGET and derived types are intentionally allowed: any write that INTENT(IN)
-/// still permits (e.g. writing the target of a POINTER component) goes through a
-/// pointer loaded from the object, not through the argument pointer, and hence
-/// does not violate LLVM `readonly` (which only constrains the argument and
-/// pointers based on it).
+/// TARGET and derived types are intentionally allowed: any write that
+/// INTENT(IN) still permits (e.g. writing the target of a POINTER component)
+/// goes through a pointer loaded from the object, not through the argument
+/// pointer, and hence does not violate LLVM `readonly` (which only constrains
+/// the argument and pointers based on it).
static bool dummyArgIsReadOnly(
const Fortran::evaluate::characteristics::DummyDataObject &obj) {
using Attrs = Fortran::evaluate::characteristics::DummyDataObject::Attr;
diff --git a/flang/lib/Optimizer/Transforms/FunctionAttr.cpp b/flang/lib/Optimizer/Transforms/FunctionAttr.cpp
index 69c940a9a..45b32d13a 100644
--- a/flang/lib/Optimizer/Transforms/FunctionAttr.cpp
+++ b/flang/lib/Optimizer/Transforms/FunctionAttr.cpp
@@ -71,8 +71,8 @@ void FunctionAttrPass::runOnOperation() {
// is guaranteed not to write through (see CallInterface). Unlike
// noalias/nocapture, it is valid even for TARGET arguments, so it is
// computed independently of the target/asynchronous/volatile gating.
- isReadOnly =
- static_cast<bool>(func.getArgAttr(index, fir::getReadOnlyAttrName()));
+ isReadOnly = static_cast<bool>(
+ func.getArgAttr(index, fir::getReadOnlyAttrName()));
if (!func.getArgAttr(index, fir::getTargetAttrName()) &&
!func.getArgAttr(index, fir::getAsynchronousAttrName()) &&
!func.getArgAttr(index, fir::getVolatileAttrName())) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/207732
More information about the flang-commits
mailing list