summaryrefslogtreecommitdiff
path: root/mlir/lib/Transforms/SymbolDCE.cpp
AgeCommit message (Collapse)Author
2025-08-23[MLIR] Adopt LDBG() macro debugging in SymbolDCE.cpp (NFC) (#155090)Mehdi Amini
2025-06-24[mlir] Walk nested non-symbol table ops in symbol dce (#143353)Jacques Pienaar
The previous code was effectively that a symbol is dead if was not nested in sequence of SymbolTables. But one can have operations that one cannot delete/DCE that refers to symbols which one could delete which resulted in symbol-dce deleting symbols that are still referenced and the resulting IR being invalid. This changes it so that all operations inside non SymbolTable op are considered to find nested SymbolTable ops. --------- Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
2022-12-20mlir/{SPIRV,Bufferization}: use std::optional in .td files (NFC)Ramkumar Ramachandra
This is part of an effort to migrate from llvm::Optional to std::optional. 22426110c5ef changed the way mlir-tblgen generates .inc files, emitting std::optional when an Optional attribute is specified in a .td file. It also changed several .td files hard-coding llvm::Optional to use std::optional. However, the patch excluded a few .td files in SPIRV and Bufferization hard-coding llvm::Optional. This patch fixes that defect, and after this patch, references to llvm::Optional in .cpp and .h files can be replaced mechanically. See also: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 Signed-off-by: Ramkumar Ramachandra <r@artagnon.com> Differential Revision: https://reviews.llvm.org/D140329
2022-08-31[MLIR] Update pass declarations to new autogenerated filesMichele Scuttari
The patch introduces the required changes to update the pass declarations and definitions to use the new autogenerated files and allow dropping the old infrastructure. Reviewed By: mehdi_amini, rriddle Differential Review: https://reviews.llvm.org/D132838
2022-08-30Revert "[MLIR] Update pass declarations to new autogenerated files"Michele Scuttari
This reverts commit 2be8af8f0e0780901213b6fd3013a5268ddc3359.
2022-08-30[MLIR] Update pass declarations to new autogenerated filesMichele Scuttari
The patch introduces the required changes to update the pass declarations and definitions to use the new autogenerated files and allow dropping the old infrastructure. Reviewed By: mehdi_amini, rriddle Differential Review: https://reviews.llvm.org/D132838
2022-04-07[mlir][NFC] Drop a few unnecessary includes from Pass.hRiver Riddle
2022-03-18[mlir][SymbolDCE] Track the number of symbols DCE'dNandor Licker
Added a statistic counting the number of erased symbols. Differential Revision: https://reviews.llvm.org/D121930
2022-01-05[mlir] Symbol DCE ignores unknown symbolsMogball
Instead of failing when it encounters a reference to an unknown symbol, Symbol DCE should ignore them. References to unknown symbols do not affect the overall function of Symbol DCE, so it should not need to fail when it encounters one. In general, requiring that symbol references always be valid rather than only when necessary can be overly conservative. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D116047
2021-12-08Adjust "end namespace" comment in MLIR to match new agree'd coding styleMehdi Amini
See D115115 and this mailing list discussion: https://lists.llvm.org/pipermail/llvm-dev/2021-December/154199.html Differential Revision: https://reviews.llvm.org/D115309
2021-03-25Define a `NoTerminator` traits that allows operations with a single block ↵Mehdi Amini
region to not provide a terminator In particular for Graph Regions, the terminator needs is just a historical artifact of the generalization of MLIR from CFG region. Operations like Module don't need a terminator, and before Module migrated to be an operation with region there wasn't any needed. To validate the feature, the ModuleOp is migrated to use this trait and the ModuleTerminator operation is deleted. This patch is likely to break clients, if you're in this case: - you may iterate on a ModuleOp with `getBody()->without_terminator()`, the solution is simple: just remove the ->without_terminator! - you created a builder with `Builder::atBlockTerminator(module_body)`, just use `Builder::atBlockEnd(module_body)` instead. - you were handling ModuleTerminator: it isn't needed anymore. - for generic code, a `Block::mayNotHaveTerminator()` may be used. Differential Revision: https://reviews.llvm.org/D98468
2020-10-16[mlir] Optimize symbol related checks in SymbolDCERiver Riddle
This revision contains two optimizations related to symbol checking: * Optimize SymbolOpInterface to only check for a name attribute if the operation is an optional symbol. This removes an otherwise unnecessary attribute lookup from a majority of symbols. * Add a new SymbolTableCollection class to represent a collection of SymbolTables. This allows for perfoming non-flat symbol lookups in O(1) time by caching SymbolTables for symbol table operations. This class is very useful for algorithms that operate on multiple symbol tables, either recursively or not. Differential Revision: https://reviews.llvm.org/D89505
2020-04-27[mlir][Symbol] Change Symbol from a Trait into an OpInterface.River Riddle
This provides a much cleaner interface into Symbols, and allows for users to start injecting op-specific information. For example, derived op can now inject when a symbol can be discarded if use_empty. This would let us drop unused external functions, which generally have public visibility. This revision also adds a new `extraTraitClassDeclaration` field to ODS OpInterface to allow for injecting declarations into the trait class that gets attached to the operations. Differential Revision: https://reviews.llvm.org/D78522
2020-04-07[mlir][Pass] Update the PassGen to generate base classes instead of utilitiesRiver Riddle
Summary: This is much cleaner, and fits the same structure as many other tablegen backends. This was not done originally as the CRTP in the pass classes made it overly verbose/complex. Differential Revision: https://reviews.llvm.org/D77367
2020-04-07[mlir][Pass] Remove the use of CRTP from the Pass classesRiver Riddle
This revision removes all of the CRTP from the pass hierarchy in preparation for using the tablegen backend instead. This creates a much cleaner interface in the C++ code, and naturally fits with the rest of the infrastructure. A new utility class, PassWrapper, is added to replicate the existing behavior for passes not suitable for using the tablegen backend. Differential Revision: https://reviews.llvm.org/D77350
2020-04-01[mlir][Pass] Add support for generating pass utilities via tablegenRiver Riddle
This revision adds support for generating utilities for passes such as options/statistics/etc. that can be inferred from the tablegen definition. This removes additional boilerplate from the pass, and also makes it easier to remove the reliance on the pass registry to provide certain things(e.g. the pass argument). Differential Revision: https://reviews.llvm.org/D76659
2020-04-01[mlir][Pass] Add a tablegen backend for defining Pass informationRiver Riddle
This will greatly simplify a number of things related to passes: * Enables generation of pass registration * Enables generation of boiler plate pass utilities * Enables generation of pass documentation This revision focuses on adding the basic structure and adds support for generating the registration for passes in the Transforms/ directory. Future revisions will add more support and move more passes over. Differential Revision: https://reviews.llvm.org/D76656
2020-01-27[mlir] Add a DCE pass for dead symbols.River Riddle
Summary: This pass deletes all symbols that are found to be unreachable. This is done by computing the set of operations that are known to be live, propagating that liveness to other symbols, and then deleting all symbols that are not within this live set. Differential Revision: https://reviews.llvm.org/D72482