This is an archive of the discontinued LLVM Phabricator instance.

[mlir][LLVM] Perform deep clone of alias scopes during inlining
ClosedPublic

Authored by zero9178 on Jul 17 2023, 9:03 AM.

Details

Summary

This is the first and most basic and important step for inlining memory operations with alias scopes.

For correctness, it is required that any alias scopes of inlined operations are replaced with deep copies. This is necessary as otherwise the same function could be inlined twice in one function, and suddenly the alias scopes extended.
A simple example would be foo(a, b); foo(a2, b2). a and a2 may alias. If foo is inlined in both instances, the store and load operations from foo may suddenly claim that a and a2 do not alias if we were to keep the original alias scopes.

This is analogous to the following class/code in LLVM: https://github.com/llvm/llvm-project/blob/4eef2e30d6f89328a16d4f1d6b37f1c79afe850c/llvm/lib/Transforms/Utils/InlineFunction.cpp#L985

Diff Detail

Event Timeline

zero9178 created this revision.Jul 17 2023, 9:03 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
zero9178 requested review of this revision.Jul 17 2023, 9:03 AM
gysit accepted this revision.Jul 18 2023, 12:25 AM

LGTM module nit suggestion.

mlir/test/Dialect/LLVMIR/inlining.mlir
588

Would it make sense to have a separate inlining-aliascopes.mlir since I assume there will be quite a few additional tests.

This revision is now accepted and ready to land.Jul 18 2023, 12:25 AM
definelicht accepted this revision.Jul 18 2023, 12:49 AM

LGTM modulo ultra-nits!

mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
135

This is the convention used throughout the file 🙂

138–152

It's very non-obvious where the actual cloning/copying happens, please add a comment for the uninitiated 🤠

This revision was automatically updated to reflect the committed changes.
zero9178 marked 3 inline comments as done.