[flang-commits] [flang] [flang] Add initial support for RegionBranchOpInterface to AA (PR #196132)

Razvan Lupusoru via flang-commits flang-commits at lists.llvm.org
Wed May 6 14:01:58 PDT 2026


================
@@ -1225,10 +1377,41 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
               followingData, attributes);
           breakFromLoop = true;
         })
+        .Case([&](mlir::RegionBranchOpInterface branch) {
+          llvm::SmallVector<mlir::Value, 4> predecessors;
+          getRegionBranchPredecessorValuesForParentResult(branch, opResult,
+                                                          predecessors);
+          if (predecessors.empty() ||
+              llvm::all_of(predecessors,
+                           [&](mlir::Value pred) { return pred == v; })) {
+            regionBranchReturn = {{{v, instantiationPoint, followingData},
+                                   SourceKind::Unknown,
+                                   ty,
+                                   attributes,
+                                   /*approximateSource=*/true,
+                                   /*accessPath=*/{},
+                                   isCapturedInInternalProcedure}};
+            breakFromLoop = true;
+            return;
+          }
+          llvm::SmallVector<AliasAnalysis::Source, 4> predSources;
+          predSources.reserve(predecessors.size());
+          for (mlir::Value pred : predecessors)
+            predSources.push_back(getSource(pred, getLastInstantiationPoint));
----------------
razvanlupusoru wrote:

I just uploaded a test that hopefully exercises what you had in mind - if something else - please let me know and I can check if it works. Thank you!

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


More information about the flang-commits mailing list