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

Renaud Kauffmann via flang-commits flang-commits at lists.llvm.org
Sat Jan 18 16:51:55 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:

> I have been assuming that !fir.ref<!fir.ptr<T>> is the address of a pointer (that is, pointer non-data) but just missing the box. Do you agree?
I don't want to introduce data vs non-data for scalars if we do not have to. I do not think in those terms. I try to rely on the original concepts and see if they can be leveraged. They can be leveraged. We have 2 different allocas, they are not `POINTER`s or `TARGET`s, they cannot alias. Period. There is not need to introduce new concepts to solve this problem.

My timeline: ideally shortly after you commit this patch, while the iron is still hot. 

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


More information about the flang-commits mailing list