[all-commits] [llvm/llvm-project] ead8e9: [mlir] [mem2reg] Adapt to be pattern-friendly.

Théo Degioanni via All-commits all-commits at lists.llvm.org
Tue May 16 01:40:00 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ead8e9d7953e817c52fdfaf7196dfeb2199dab26
      https://github.com/llvm/llvm-project/commit/ead8e9d7953e817c52fdfaf7196dfeb2199dab26
  Author: Théo Degioanni <theo.degioanni at nextsilicon.com>
  Date:   2023-05-16 (Tue, 16 May 2023)

  Changed paths:
    M mlir/include/mlir/Interfaces/MemorySlotInterfaces.h
    M mlir/include/mlir/Interfaces/MemorySlotInterfaces.td
    M mlir/include/mlir/Transforms/Mem2Reg.h
    M mlir/include/mlir/Transforms/Passes.td
    M mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
    M mlir/lib/Dialect/MemRef/IR/MemRefMem2Reg.cpp
    M mlir/lib/Transforms/Mem2Reg.cpp
    M mlir/test/Dialect/LLVMIR/mem2reg-dbginfo.mlir
    M mlir/test/Dialect/LLVMIR/mem2reg.mlir
    A mlir/test/Dialect/MemRef/mem2reg-statistics.mlir
    M mlir/test/Dialect/MemRef/mem2reg.mlir

  Log Message:
  -----------
  [mlir] [mem2reg] Adapt to be pattern-friendly.

This revision modifies the mem2reg interfaces and algorithm to be more
omfortable to use as a pattern. The motivation behind this is that
currently the pattern needs to be applied to the scope op of the region
in which allocators should be promoted. However, a more natural way to
apply the pattern would be to apply it on the allocator directly. This
is not only clearer but easier to parallelize.

This revision changes the mem2reg pattern to operate this way. This
required restraining the interfaces to only mutate IR using
RewriterBase, as the previously used escape hatch is not granular enough
to match on the region that is modified only. This has the unfortunate
cost of preventing batching allocator promotion and making the block
argument adding logic more complex. Because batching no longer made any
sense, I made the internal analyzer/promoter decoupling private again.

This also adds statistics to the mem2reg infrastructure.

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D150432




More information about the All-commits mailing list