[mlir][LLVM] Convert `noalias` parameters into alias scopes during inlining
authorMarkus Böck <markus.bock+llvm@nextsilicon.com>
Wed, 19 Jul 2023 14:35:54 +0000 (16:35 +0200)
committerMarkus Böck <markus.bock+llvm@nextsilicon.com>
Thu, 20 Jul 2023 13:05:28 +0000 (15:05 +0200)
commitf9173c2958bf6cb9bf23cb00184ce91dfba6acbc
tree72850932ae2a9815fb83c9c39f112809373f15a1
parente1aa4e7b383e37442df6bb49f4f3db2069487765
[mlir][LLVM] Convert `noalias` parameters into alias scopes during inlining

Currently, inlining a function with a `noalias` parameter leads to a large loss of optimization potential as the `noalias` parameter, an important hint for alias analysis, is lost completely.

This patch fixes this with the same approach as LLVM by annotating all users of the `noalias` parameter with appropriate alias and noalias scope lists.
The implementation done here is not as sophisticated as LLVMs, which has more infrastructure related to escaping and captured pointers, but should work in the majority of important cases.
Any deficiency can be addressed in future patches.

Related LLVM code: https://github.com/llvm/llvm-project/blob/27ade4b554774187d2c0afcf64cd16fa6d5f619d/llvm/lib/Transforms/Utils/InlineFunction.cpp#L1090

Differential Revision: https://reviews.llvm.org/D155712
mlir/include/mlir/Dialect/LLVMIR/LLVMInterfaces.td
mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMInterfaces.cpp
mlir/test/Dialect/LLVMIR/inlining-alias-scopes.mlir
mlir/test/Dialect/LLVMIR/inlining.mlir