[Mlir-commits] [mlir] [mlir][memref][llvm] Infer llvm alias scopes attrs from `memref.distinct_objects` (PR #160512)
Krzysztof Drewniak
llvmlistbot at llvm.org
Wed Sep 24 10:35:53 PDT 2025
================
@@ -0,0 +1,112 @@
+//===- InferAliasScopeAttrs.cpp - Infer LLVM alias scope attributes -------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/LLVMIR/Transforms/InferAliasScopeAttrs.h"
+
+#include "mlir/Analysis/AliasAnalysis.h"
+#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
+#include "mlir/Dialect/MemRef/IR/MemRef.h"
+#include "mlir/Pass/Pass.h"
+
+namespace mlir {
+namespace LLVM {
+#define GEN_PASS_DEF_LLVMINFERALIASSCOPEATTRIBUTES
+#include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc"
+} // namespace LLVM
+} // namespace mlir
+
+using namespace mlir;
+
+static Value getBasePtr(Operation *op) {
+ // TODO: we need a common interface to get the base ptr.
+ if (auto loadOp = dyn_cast<memref::LoadOp>(op))
+ return loadOp.getMemRef();
+
+ if (auto storeOp = dyn_cast<memref::StoreOp>(op))
+ return storeOp.getMemRef();
+
+ return nullptr;
+}
+
+namespace {
+
+struct LLVMInferAliasScopeAttrs
+ : public LLVM::impl::LLVMInferAliasScopeAttributesBase<
+ LLVMInferAliasScopeAttrs> {
+ void runOnOperation() override {
----------------
krzysz00 wrote:
Does this end up working because alias analysis knows about separate_storage now?
And re quadratic ... union-find, maybe? (LLVM calls it EquivalenceClasses - you could sort the pointers by whether they alias existing representatives?)
Also, why's this in the LLVM directory when it's doing a lot of work with memrefs?
https://github.com/llvm/llvm-project/pull/160512
More information about the Mlir-commits
mailing list