[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 13:56:34 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 do not expect it to be possible to have an infinite loop here. Because:
- We start from the region's results. Since those are new definitions, there cannot be ssa cycles from predecessors.
- getSource does not look through BlockArguments in Loops AFAICT.

Do you have a specific scenario in mind?

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


More information about the flang-commits mailing list