)]}'
{
  "commit": "e48e351f7d6b3ef4211611f92b9390efa0856031",
  "tree": "10c984b6374f08c7f795644f5ff8df3ec39bb417",
  "parents": [
    "127582c8624f7cacfaca5cc7c51df5b5269e046f"
  ],
  "author": {
    "name": "Vineet Kumar",
    "email": "173554+vntkmr@users.noreply.github.com",
    "time": "Tue Nov 17 17:28:32 2026 -0500"
  },
  "committer": {
    "name": "Copybara-Service",
    "email": "copybara-worker@google.com",
    "time": "Tue Nov 17 14:34:56 2026 -0800"
  },
  "message": "[flang][Evaluate] Analyze contiguity and copies per consequent-arg (#238055)\n\nThe contiguity and copy-in/copy-out analysis that semantics and lowering\nuse treated a conditional argument (F2023 R1526) as a single expression.\nIt answered from the condition or from the first consequent-arg. The\nactual argument is the consequent-arg chosen at run time (F2023 15.5.2.3\np2), so the analysis has to account for every consequent-arg. This is\nalso the base for lowering conditional arguments. Without it, an array\nconditional argument passed to a CONTIGUOUS dummy argument wouldn\u0027t get\nthe copy-in it needs.\n\nContiguity:\n- IsContiguous() had an overload for ActualArgument that no caller\n  reached, because the header declared only the function template. The\ntemplate traversed the whole argument; it saw the scalar condition first\n  and reported every conditional argument as contiguous. Declare the\n  overload in check-expression.h with default arguments and remove the\n  template\u0027s explicit instantiation for ActualArgument. Other actual\n  arguments get the same answers as before.\n- A conditional argument is simply contiguous if and only if all its\nconsequent-args are (F2023 15.5.2.3 p4). The overload returns true when\nevery consequent-arg is known to be contiguous, false when every one is\n  known not to be, and std::nullopt otherwise. A .NIL. consequent takes\n  no part.\n- IS_CONTIGUOUS folds through the same overload, so it now folds a\n  conditional argument whose consequent-args are all contiguous or all\ndiscontiguous. The check that stops intrinsic folding for a conditional\n  argument lets IS_CONTIGUOUS through for this reason. Such a reference\n  can then appear in a constant expression; docs/Extensions.md now lists\n  this extension.\n\nActualArgNeedsCopy():\n- Apply the rules for a plain actual argument to each consequent-arg.\n  IsVariable() of the whole argument visited the condition first, so a\n  condition such as `n \u003e 0` made it an expression that never needed\n  copy-out, and a logical variable condition made it a variable, which\n  could miss the copy-in of an expression consequent-arg. Now a\n  conditional argument needs copy-in if any consequent-arg is an\n  expression other than a named constant, and it can need copy-out only\n  if a consequent-arg is a variable.\n- A conditional argument is polymorphic if any consequent-arg is (F2023\n  15.5.2.3 p4). Add ActualArgument::ConditionalArg::IsPolymorphic() and\n  use it in place of the type of the first consequent-arg.\n- Treat a conditional argument as coindexed when any consequent-arg is.\n\nSemantics:\n- CheckExplicitDataArg() runs once for each consequent-arg, but it took\n  the copy-out decision from the whole argument. A contiguous VOLATILE\n  consequent-arg next to a discontiguous one got a false warning that a\n  temporary copy is required. When the whole argument needs copy-out,\ndecide again for the consequent-arg being checked. ActualArgNeedsCopy()\n  keeps the whole-argument answer at least as conservative as the answer\n  for each consequent-arg, so a consequent-arg never needs copy-out when\n  the whole argument doesn\u0027t.\n\nAs a result, semantics reports F2023 C1547 and C1548 for conditional\narguments, and IS_CONTIGUOUS folds when the answer doesn\u0027t depend on the\ncondition.\n\nKnown limitations:\n- The copy-out suppression for subobjects of an INTENT(IN) dummy\nargument\n  doesn\u0027t look into the consequent-args yet; a TODO marks it. Only\n  lowering can observe this, and lowering doesn\u0027t support conditional\n  arguments yet.\n- When every consequent-arg violates C1548, flang reports the error\nonce,\n  because a conditional argument has no source location of its own\n  (#227805).\n\nTests: Semantics/conditional-arg-contiguity.f90 (new) covers C1547,\nC1548,\nand the warnings about a temporary copy. Its cases include a condition\nthat is an expression, an ASYNCHRONOUS dummy argument, polymorphic,\ncoindexed, and assumed-type consequent-args, and a consequent-arg that\nis\na subobject of an INTENT(IN) dummy argument.\nSemantics/conditional-arg-portability.f90 (new) checks that each\nconsequent-arg gets the portability or temporary-copy warning that it\nwould get on its own. Evaluate/fold-conditional-arg.f90 covers the\nIS_CONTIGUOUS folding. Semantics/conditional-arg-inquiry.f90 checks\nthat IS_CONTIGUOUS doesn\u0027t fold when the consequent-args disagree or\nwhen one of them is an assumed-shape array, whose contiguity is known\nonly at run time. No test covers the copy-in answer, because semantics\nasks only about copy-out and lowering doesn\u0027t support conditional\narguments yet.\n\nThese changes were generated with the assistance of AI tooling and have\nbeen\napproved by the author.\n\nPR description generated with AI assistance.\n\nPart of llvm/llvm-project#180592\n\nGitOrigin-RevId: b9526f6a68332b3f6d4cb64696c4f1a1789e2ce8\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "6225dbe5e5989728d03ece405ccb611035a355bc",
      "old_mode": 33188,
      "old_path": "docs/Extensions.md",
      "new_id": "df1d70b6373cc7827ace233e90e31d1d84f96693",
      "new_mode": 33188,
      "new_path": "docs/Extensions.md"
    },
    {
      "type": "modify",
      "old_id": "2cb44f61ba66b86d1cd7ba03adb2969cea260d65",
      "old_mode": 33188,
      "old_path": "include/flang/Evaluate/call.h",
      "new_id": "b8d1d575555a9ec6a963e430b582d24891ef2986",
      "new_mode": 33188,
      "new_path": "include/flang/Evaluate/call.h"
    },
    {
      "type": "modify",
      "old_id": "93914788fc655ae7779e12ec24fce436f1b0117b",
      "old_mode": 33188,
      "old_path": "include/flang/Evaluate/check-expression.h",
      "new_id": "6d113f7a71d6453c64093b87cdffd5cda563c356",
      "new_mode": 33188,
      "new_path": "include/flang/Evaluate/check-expression.h"
    },
    {
      "type": "modify",
      "old_id": "c6530d5e17ef4bb0763130cb1b285006e0ae9585",
      "old_mode": 33188,
      "old_path": "lib/Evaluate/call.cpp",
      "new_id": "e9b8a92de2edb8b4b8bb26c34d31f0f242c1f10a",
      "new_mode": 33188,
      "new_path": "lib/Evaluate/call.cpp"
    },
    {
      "type": "modify",
      "old_id": "46ded248559d6b8fd8a05159be5b405282bf8065",
      "old_mode": 33188,
      "old_path": "lib/Evaluate/check-expression.cpp",
      "new_id": "a1a1e4600a8722e542fd0766fff8e7c3a7c1f904",
      "new_mode": 33188,
      "new_path": "lib/Evaluate/check-expression.cpp"
    },
    {
      "type": "modify",
      "old_id": "de0dc05f7694a637b998fbf0c8bc0265108ae03c",
      "old_mode": 33188,
      "old_path": "lib/Evaluate/fold-implementation.h",
      "new_id": "42a7c2a073fdd609c33d7cef3cc22534c0b34cf4",
      "new_mode": 33188,
      "new_path": "lib/Evaluate/fold-implementation.h"
    },
    {
      "type": "modify",
      "old_id": "151295336d5e5894cc311ff2e96a2a64769d09e2",
      "old_mode": 33188,
      "old_path": "lib/Evaluate/fold-logical.cpp",
      "new_id": "f0994b2a53fa65bc7ef69f420930f9134c140ff1",
      "new_mode": 33188,
      "new_path": "lib/Evaluate/fold-logical.cpp"
    },
    {
      "type": "modify",
      "old_id": "3c385a6601cbf6ac7e9c256338a905ae533aae91",
      "old_mode": 33188,
      "old_path": "lib/Semantics/check-call.cpp",
      "new_id": "865273729e44b71aaa0a39ad0e0b6c63babc615c",
      "new_mode": 33188,
      "new_path": "lib/Semantics/check-call.cpp"
    },
    {
      "type": "modify",
      "old_id": "9ce8d77f29d13e044ef96539be92b87cf4dbc807",
      "old_mode": 33188,
      "old_path": "test/Evaluate/fold-conditional-arg.f90",
      "new_id": "dfc9bc3060de5156a7c26b72b3090e5966733017",
      "new_mode": 33188,
      "new_path": "test/Evaluate/fold-conditional-arg.f90"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "ce83965576c71eeea55724cf8b9830def78c608d",
      "new_mode": 33188,
      "new_path": "test/Semantics/conditional-arg-contiguity.f90"
    },
    {
      "type": "modify",
      "old_id": "be8bedffeb9ef875defd9c643776e3c4510b98c9",
      "old_mode": 33188,
      "old_path": "test/Semantics/conditional-arg-inquiry.f90",
      "new_id": "6e86a82ca6a21bb33fd6a5d95fa34b011444f007",
      "new_mode": 33188,
      "new_path": "test/Semantics/conditional-arg-inquiry.f90"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "adca24f78ba85a00e288d92d4a370040f027285e",
      "new_mode": 33188,
      "new_path": "test/Semantics/conditional-arg-portability.f90"
    }
  ]
}
