[mlir][LLVM] Perform deep clone of alias scopes during inlining
authorMarkus Böck <markus.bock+llvm@nextsilicon.com>
Mon, 17 Jul 2023 16:01:17 +0000 (18:01 +0200)
committerMarkus Böck <markus.bock+llvm@nextsilicon.com>
Tue, 18 Jul 2023 11:23:40 +0000 (13:23 +0200)
commitdd28cc707c49e90c3a10ac724f6f5f46a21031c3
treee143f01bbf48c42e73cd1bf63fa0419a8ae92683
parentbe861b64d94198230d8f9889b17280e3cd215a0a
[mlir][LLVM] Perform deep clone of alias scopes during inlining

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

Differential Revision: https://reviews.llvm.org/D155479
mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
mlir/test/Dialect/LLVMIR/inlining-alias-scopes.mlir [new file with mode: 0644]