summaryrefslogtreecommitdiff
path: root/mlir/lib/Analysis/DataFlowFramework.cpp
AgeCommit message (Collapse)Author
2025-09-12[MLIR] Avoid resolving callable outside the analysis scope in ↵Mehdi Amini
DeadCodeAnalysis (#155088) We are using the symbol table machinery to lookup for a callable, but when the analysis scope if a function, such lookup will resolve outside of the scope. This can lead to race-condition issues since other passes may operate in parallel on the sibling functions. The callable would be discarded right after the lookup (we check the analysis scope), so avoiding the lookup is NFC. For the DataFlow solver, we're looking at the top-level operation, and if it isn't a SymbolTable we disable the interprocedural optimization in the solver config directly. This strategy isn't NFC but seems reasonnable and does not encounter any change in behavior in practice in tree. Fix #154948
2025-08-23[MLIR] Fixup the LDBG() logging in dataflow/deadcodeanalysis (NFC) (#155085)Mehdi Amini
This is improving the debug output: - avoid printing pointers, print ops without regions in general. - skip extra new-lines in the output - minor other consistency aspects.
2025-08-22Support nice logging for `ProgramPoint*` in dataflow log (#154839)Peng Chen
There're places where a pointer instead of `ProgramPoint` object is passed to stream print `<<`, and they'll be printed as pointer value. This PR converts them to object before passing to stream printers. The address isn't much helpful in the debug and does not help when diffing before/after debug traces.
2025-08-22[MLIR] Apply clang-tidy fixes for readability-identifier-naming in ↵Mehdi Amini
DataFlowFramework.cpp (NFC)
2025-07-27Migrate more of DataFlow framework to LDBG (NFC) (#150752)Mehdi Amini
2025-04-15[mlir] [dataflow] : Improve the time and space footprint of data flow. (#135325)donald chen
MLIR's data flow analysis (especially dense data flow analysis) constructs a lattice at every lattice anchor (which, for dense data flow, means every program point). As the program grows larger, the time and space complexity can become unmanageable. However, in many programs, the lattice values at numerous lattice anchors are actually identical. We can leverage this observation to improve the complexity of data flow analysis. This patch introducing equivalence lattice anchor to group lattice anchors that must contains identical lattice on certain state to improve the time and space footprint of data flow.
2025-02-21[mlir] Remove unused outer loop (NFC) (#127998)laichunfeng
The program will exit the outer loop directly if inner loop ends, so the outer do {} while() is redundant.
2025-01-28[mlir][dataflow] disallow outside use of propagateIfChanged for ↵Hongren Zheng
DataFlowSolver (#120885) Detailed writeup is in https://github.com/google/heir/issues/1153. See also https://github.com/llvm/llvm-project/pull/120881. In short, `propagateIfChanged` is used outside of the `DataFlowAnalysis` scope, because it is public, but it does not propagate as expected as the `DataFlowSolver` has stopped running. To solve such misuse, `propagateIfChanged` should be made protected/private. For downstream users affected by this, to correctly propagate the change, the Analysis should be re-run (check #120881) instead of just a `propagateIfChanged` The change to `IntegerRangeAnalysis` is just a expansion of the `solver->propagateIfChanged`. The `Lattice` has already been updated by the `join`. Propagation is done by `onUpdate`. Cc @Mogball for review
2025-01-11[mlir] Migrate away from PointerUnion::{is,get} (NFC) (#122591)Kazu Hirata
Note that PointerUnion::{is,get} have been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> I'm not touching PointerUnion::dyn_cast for now because it's a bit complicated; we could blindly migrate it to dyn_cast_if_present, but we should probably use dyn_cast when the operand is known to be non-null.
2024-10-11[mlir] [dataflow] unify semantics of program point (#110344)donald chen
The concept of a 'program point' in the original data flow framework is ambiguous. It can refer to either an operation or a block itself. This representation has different interpretations in forward and backward data-flow analysis. In forward data-flow analysis, the program point of an operation represents the state after the operation, while in backward data flow analysis, it represents the state before the operation. When using forward or backward data-flow analysis, it is crucial to carefully handle this distinction to ensure correctness. This patch refactors the definition of program point, unifying the interpretation of program points in both forward and backward data-flow analysis. How to integrate this patch? For dense forward data-flow analysis and other analysis (except dense backward data-flow analysis), the program point corresponding to the original operation can be obtained by `getProgramPointAfter(op)`, and the program point corresponding to the original block can be obtained by `getProgramPointBefore(block)`. For dense backward data-flow analysis, the program point corresponding to the original operation can be obtained by `getProgramPointBefore(op)`, and the program point corresponding to the original block can be obtained by `getProgramPointAfter(block)`. NOTE: If you need to get the lattice of other data-flow analyses in dense backward data-flow analysis, you should still use the dense forward data-flow approach. For example, to get the Executable state of a block in dense backward data-flow analysis and add the dependency of the current operation, you should write: ``getOrCreateFor<Executable>(getProgramPointBefore(op), getProgramPointBefore(block))`` In case above, we use getProgramPointBefore(op) because the analysis we rely on is dense backward data-flow, and we use getProgramPointBefore(block) because the lattice we query is the result of a non-dense backward data flow computation. related dsscussion: https://discourse.llvm.org/t/rfc-unify-the-semantics-of-program-points/80671/8 corresponding PSA: https://discourse.llvm.org/t/psa-program-point-semantics-change/81479
2024-08-25[mlir] [dataflow] Refactoring the definition of program points in data flow ↵donald chen
analysis (#105656) This patch distinguishes between program points and lattice anchors in data flow analysis, where lattice anchors represent locations where a lattice can be attached, while program points denote points in program execution. Related discussions: https://discourse.llvm.org/t/rfc-unify-the-semantics-of-program-points/80671/8
2024-07-02mlir/LogicalResult: move into llvm (#97309)Ramkumar Ramachandra
This patch is part of a project to move the Presburger library into LLVM.
2023-10-28Apply clang-tidy fixes for misc-include-cleaner in DataFlowFramework.cpp (NFC)Mehdi Amini
2023-07-11[mlir] add backward dense dataflow analysisAlex Zinenko
This is the counterpart to the forward dense dataflow analysis and integrates into the dataflow framework. The implementation follows the structure of existing dataflow analyses. Reviewed By: Mogball, phisiart Differential Revision: https://reviews.llvm.org/D154713
2023-07-03[mlir][dataflow] Unify dependency management in AnalysisState.Zhixun Tan
In the MLIR dataflow analysis framework, when an `AnalysisState` is updated, it's dependents are enqueued to be visited. Currently, there are two ways dependents are managed: * `AnalysisState::dependents` stores a list of dependents. `DataFlowSolver::propagateIfChanged()` reads this list and enqueues them to the worklist. * `AnalysisState::onUpdate()` allows custom logic to enqueue more to the worklist. This is called by `DataFlowSolver::propagateIfChanged()`. This cleanup diff consolidates the two into `AnalysisState::onUpdate()`. This way, `DataFlowSolver` does not need to know the detail about `AnalysisState::dependents`, and the logic of dependency management is entirely handled by `AnalysisState`. Reviewed By: Mogball Differential Revision: https://reviews.llvm.org/D154170
2023-05-26[mlir] Move casting calls from methods to function callsTres Popp
The MLIR classes Type/Attribute/Operation/Op/Value support cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast functionality in addition to defining methods with the same name. This change begins the migration of uses of the method to the corresponding function call as has been decided as more consistent. Note that there still exist classes that only define methods directly, such as AffineExpr, and this does not include work currently to support a functional cast/isa call. Context: - https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…" - Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443 Implementation: This patch updates all remaining uses of the deprecated functionality in mlir/. This was done with clang-tidy as described below and further modifications to GPUBase.td and OpenMPOpsInterfaces.td. Steps are described per line, as comments are removed by git: 0. Retrieve the change from the following to build clang-tidy with an additional check: main...tpopp:llvm-project:tidy-cast-check 1. Build clang-tidy 2. Run clang-tidy over your entire codebase while disabling all checks and enabling the one relevant one. Run on all header files also. 3. Delete .inc files that were also modified, so the next build rebuilds them to a pure state. ``` ninja -C $BUILD_DIR clang-tidy run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\ -header-filter=mlir/ mlir/* -fix rm -rf $BUILD_DIR/tools/mlir/**/*.inc ``` Differential Revision: https://reviews.llvm.org/D151542
2022-08-09[mlir] Use C++17 structured bindings instead of std::tie where applicable. NFCIBenjamin Kramer
2022-07-07[mlir] Swap integer range inference to the new frameworkMogball
Integer range inference has been swapped to the new framework. The integer value range lattices automatically updates the corresponding constant value on update. Depends on D127173 Reviewed By: krzysz00, rriddle Differential Revision: https://reviews.llvm.org/D128866
2022-06-14(Reland)[mlir] Add a generic data-flow analysis frameworkMogball
Removes one element of the pointer union to make it work on 32-bit systems. This patch introduces a generic data-flow analysis framework to MLIR. The framework implements a fixed-point iteration algorithm and a dependency graph between lattice states and analysis. Lattice states and points are fully extensible to support highly-customizable analyses. Reviewed By: phisiart, rriddle Differential Revision: https://reviews.llvm.org/D126751
2022-06-14Revert "[mlir] Add a generic data-flow analysis framework"Frederik Gossen
This reverts commit 9dea11728340e54e1fde76320b61a559148c8a3e. The PointerUnion assumes 3 available bits, which is not the case on 32-bit machines.
2022-06-14[mlir] Add a generic data-flow analysis frameworkMogball
This patch introduces a generic data-flow analysis framework to MLIR. The framework implements a fixed-point iteration algorithm and a dependency graph between lattice states and analysis. Lattice states and points are fully extensible to support highly-customizable analyses. Reviewed By: phisiart, rriddle Differential Revision: https://reviews.llvm.org/D126751