summaryrefslogtreecommitdiff
path: root/mlir/test/lib/Analysis/DataFlow/TestDeadCodeAnalysis.cpp
AgeCommit message (Collapse)Author
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
2022-08-29[mlir][dataflow] Consolidate ↵Zhixun Tan
AbstractSparseLattice::markPessimisticFixpoint() and AbstractDenseLattice::reset() into Abstract{Sparse,Dense}DataFlowAnalysis::setToEntryState(). ### Rationale For a program point where we cannot reason about incoming dataflow (e.g. an argument of an entry block), the framework needs to initialize the state. Currently, `AbstractSparseDataFlowAnalysis` initializes such state to the "pessimistic fixpoint", and `AbstractDenseDataFlowAnalysis` calls the state's `reset()` function. However, entry states aren't necessarily the pessimistic fixpoint. Example: in reaching definition, the pessimistic fixpoint is `{all definitions}`, but the entry state is `{}`. This awkwardness might be why the dense analysis API currently uses `reset()` instead of `markPessimisticFixpoint()`. This patch consolidates entry point initialization into a single function `setToEntryState()`. ### API Location Note that `setToEntryState()` is defined in the analysis rather than the lattice, so that we allow different analyses to use the same lattice but different entry states. ### Removal of the concept of optimistic/known value The concept of optimistic/known value is too specific to SCCP. Furthermore, the known value is not really used: In the current SCCP implementation, the known value (pessimistic fixpoint) is always `Attribute{}` (non-constant). This means there's no point storing a `knownValue` in each state. If we do need to re-introduce optimistic/known value, we should put it in the SCCP analysis, not the sparse analysis API. ### Terminology Please let me know if "entry state" is a good terminology. I chose "entry" from Wikipedia (https://en.wikipedia.org/wiki/Data-flow_analysis#Basic_principles). Another term I can think of is "boundary" (https://suif.stanford.edu/~courses/cs243/lectures/L3-DFA2-revised.pdf) which might be better since it also makes sense for backward analysis. Reviewed By: Mogball Differential Revision: https://reviews.llvm.org/D132086
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-30[mlir] Add Dead Code AnalysisMogball
This patch implements the analysis state classes needed for sparse data-flow analysis and implements a dead-code analysis using those states to determine liveness of blocks, control-flow edges, region predecessors, and function callsites. Depends on D126751 Reviewed By: rriddle, phisiart Differential Revision: https://reviews.llvm.org/D127064