[flang-commits] [flang] [flang] Characterize allocation based on MemAlloc effect instead of pattern matching (PR #166806)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Thu Nov 6 11:23:17 PST 2025
================
@@ -22,11 +22,73 @@
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
+#include "mlir/Interfaces/ViewLikeInterface.h"
using namespace mlir;
#define DEBUG_TYPE "fir-alias-analysis"
+//===----------------------------------------------------------------------===//
+// AliasAnalysis: alias helpers
+//===----------------------------------------------------------------------===//
+
+static bool tryClassifyAllocateFromEffects(mlir::Operation *op,
+ mlir::Value candidate, bool allowValueScoped, bool allowOpScoped,
+ mlir::Value &v, mlir::Operation *&defOp,
+ fir::AliasAnalysis::SourceKind &type) {
+ auto iface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(op);
+ if (!iface)
+ return false;
+
+ llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> effects;
+ iface.getEffects(effects);
+
+ if (allowValueScoped) {
+ for (mlir::MemoryEffects::EffectInstance &e : effects) {
+ if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
+ e.getValue() && e.getValue() == candidate) {
+ v = candidate;
+ defOp = op;
+ type = fir::AliasAnalysis::SourceKind::Allocate;
+ return true;
+ }
+ }
+ }
+
+ if (!allowOpScoped)
+ return false;
+
----------------
clementval wrote:
Yeah it's ok to modify the op. Just make it in a separate PR maybe.
https://github.com/llvm/llvm-project/pull/166806
More information about the flang-commits
mailing list