This is an archive of the discontinued LLVM Phabricator instance.

[mlir][mem2reg] Expose algorithm internals.
ClosedPublic

Authored by Moxinilian on May 4 2023, 1:48 AM.

Details

Summary

This patch refactors the Mem2Reg infrastructure. It decouples
analysis from promotion, allowing for more control over the execution of
the logic. It also adjusts the interfaces to be less coupled to mem2reg
and more general. This will be useful for an upcoming revision
introducing generic SROA.

Diff Detail

Event Timeline

Moxinilian created this revision.May 4 2023, 1:48 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Moxinilian requested review of this revision.May 4 2023, 1:48 AM
Moxinilian updated this revision to Diff 519766.May 5 2023, 1:38 AM

Rebase to latest main.

gysit added inline comments.May 5 2023, 4:49 AM
mlir/include/mlir/Transforms/Mem2Reg.h
25

nit: Can you put a comma after the first must eliminate or reformulate a bit to simplify the sentence?

40

Optional is deprecated and should be replaced by std::optional AFAIK.

mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
20

Are you sure all this additional includes are needed? I have the feeling some of them can be eliminated?

mlir/lib/Transforms/Mem2Reg.cpp
298

nit: I would go for return info;. I would expect the compiler can do copy elision here (even if you use std::optional). The main argument is that it is more readable though.

441

nit: Once you use std::optional please do not use has_value() and value(). Instead just use the optional directly in the condition and use * to get its value.

Moxinilian updated this revision to Diff 519814.May 5 2023, 5:18 AM
Moxinilian marked 4 inline comments as done.

Address review comments.

Moxinilian marked an inline comment as done.May 5 2023, 5:18 AM
Moxinilian added inline comments.
mlir/include/mlir/Transforms/Mem2Reg.h
25

I reformulated using words that require less context so it should be clearer.

gysit accepted this revision.May 7 2023, 11:56 PM

LGTM

This revision is now accepted and ready to land.May 7 2023, 11:56 PM
Dinistro added inline comments.May 8 2023, 12:38 AM
mlir/include/mlir/Interfaces/CMakeLists.txt
19

What's the reason to make a hand-rolled tablegen target here?

Moxinilian added inline comments.May 8 2023, 1:07 AM
mlir/include/mlir/Interfaces/CMakeLists.txt
19

This is because it was easier for me to extract this change out of my SROA cchange, and I forgot to manually revert it. The quickly upcoming SROA revision will make use of this by generating type interfaces, so I can also just leave it as-is as it will be used shortly. Please tell me what you prefer.

Dinistro added inline comments.May 8 2023, 1:16 AM
mlir/include/mlir/Interfaces/CMakeLists.txt
19

Technically, this change is not necessary. On the other hand, this will change anyway soonish, so don't bother with reverting this part.

Moxinilian updated this revision to Diff 520297.May 8 2023, 1:19 AM

Rebased to latest main.

This revision was automatically updated to reflect the committed changes.
Moxinilian reopened this revision.May 8 2023, 6:46 AM

Reopen due to accidental revert.

This revision is now accepted and ready to land.May 8 2023, 6:46 AM
Moxinilian updated this revision to Diff 520357.May 8 2023, 6:56 AM

Regenerate commit.

This revision was automatically updated to reflect the committed changes.