[flang-commits] [flang] [flang] Characterize allocation based on MemAlloc effect instead of pattern matching (PR #166806)
via flang-commits
flang-commits at lists.llvm.org
Thu Nov 6 09:18:28 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- flang/lib/Optimizer/Analysis/AliasAnalysis.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 94f9ec589..17c7e5fbb 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -19,10 +19,10 @@
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Value.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
+#include "mlir/Interfaces/ViewLikeInterface.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
-#include "mlir/Interfaces/ViewLikeInterface.h"
using namespace mlir;
@@ -32,10 +32,11 @@ using namespace mlir;
// 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) {
+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;
@@ -58,8 +59,8 @@ static bool tryClassifyAllocateFromEffects(mlir::Operation *op,
if (!allowOpScoped)
return false;
- bool hasOpScopedAlloc = llvm::any_of(
- effects, [](const mlir::MemoryEffects::EffectInstance &e) {
+ bool hasOpScopedAlloc =
+ llvm::any_of(effects, [](const mlir::MemoryEffects::EffectInstance &e) {
return !e.getValue() &&
mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect());
});
@@ -618,8 +619,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
// Effect-based detection (op-scoped heuristic only at this level).
if (tryClassifyAllocateFromEffects(defOp, v,
/*allowValueScoped=*/false,
- /*allowOpScoped=*/true,
- v, defOp, type))
+ /*allowOpScoped=*/true, v, defOp, type))
break;
llvm::TypeSwitch<Operation *>(defOp)
@@ -711,9 +711,10 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
if (auto defDefOp = def.getDefiningOp())
classified = tryClassifyAllocateFromEffects(
defDefOp, def,
- /*allowValueScoped=*/true, /*allowOpScoped=*/true,
- v, defOp, type);
- if (!classified) classifyFallbackFrom(def);
+ /*allowValueScoped=*/true, /*allowOpScoped=*/true, v, defOp,
+ type);
+ if (!classified)
+ classifyFallbackFrom(def);
}
breakFromLoop = true;
return;
``````````
</details>
https://github.com/llvm/llvm-project/pull/166806
More information about the flang-commits
mailing list