[flang-commits] [flang] [flang] AliasAnalysis: Handle fir.load on fir.alloca (PR #117785)

Renaud Kauffmann via flang-commits flang-commits at lists.llvm.org
Mon Jan 6 15:33:39 PST 2025


================
@@ -522,6 +546,12 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
         .Case<fir::AllocaOp, fir::AllocMemOp>([&](auto op) {
           // Unique memory allocation.
           type = SourceKind::Allocate;
+          // If there's no DeclareOp, then we need to get the pointer attribute
+          // from the type.  TODO: That case occurs in our test suite
+          // (alias-analysis-2.fir), but does flang currently generate such
+          // code?
+          if (isPointerReference(ty))
+            attributes.set(Attribute::Pointer);
----------------
Renaud-K wrote:

1. We introduced data vs non-data, to lift ambiguity when following a box and to distinguish between the box's address or the address it wraps. There is no such ambiguity for scalars, so the classical way of distinguishing between 2 sources should work. I downloaded this patch to try it out myself which is how I found out that all that was needed to fix alias-analysis-2, was to propagate pointer information when crossing fir::BoxAddrOp
2.  After discussing with Jean, all the pointers are boxed since HLFIR, but to optimize the code some may be reverted back to just allocas. It is best to keep options open.
3. You may keep the change at the lines 553,554 (where this discussion is anchored), it is not harmful and consistent with the global case, as you point out. 


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


More information about the flang-commits mailing list