[PATCH] D72482: [mlir] Add a DCE pass for dead symbols.

River Riddle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 19:03:59 PST 2020


rriddle added a comment.

In D72482#1843629 <https://reviews.llvm.org/D72482#1843629>, @echristo wrote:

> Do we need a full separate pass structure for mlir or is there some sharing we can do here as this (at the IR level) is encompassed by GlobalDCE.


We do need our own pass in MLIR for a couple of reasons:

1. There are many targets of MLIR that don't directly lower to LLVM(e.g. some non programming language front-ends).
2. `Symbols` are used at many different abstraction levels, and having the ability to DCE at each is important and powerful.

Note that even if these abstractions do eventually lower to LLVM, sometimes the 'symbol' does not have a direct representation in LLVM. For example, a Dialect in MLIR may have a 'global variable' like operation that is eventually transformed into a buffer when compiling for a specific device. In situations like those, the resultant code wouldn't contain a global in the traditional sense.

3. MLIR supports nested references. A "module" isn't constrained to be a module like in the LLVM sense. Modules(and module like operations) can be arbitrarily nested within each other.

I've looked a bit at GlobalDCE, but at this time I'm not sure how much sharing we can do. This pass is meant to be generic, i.e. agnostic to the specific design choices of a given dialect, and the LLVM definition of globals/linkage/visibility does not generalize across all of the different users.

Did you have any specific ideas in mind for how/what things could be shared?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72482/new/

https://reviews.llvm.org/D72482





More information about the llvm-commits mailing list