[PATCH] D72802: [mlir] Introduce bare ptr calling convention for MemRefs in LLVM dialect
Diego Caballero via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 13:00:39 PST 2020
dcaballe created this revision.
dcaballe added reviewers: ftynse, bondhugula, nicolasvasilache.
Herald added subscribers: llvm-commits, liufengdb, aartbik, herhut, lucyrfox, mgester, arpith-jacob, csigg, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini, jholewinski.
Herald added a project: LLVM.
This patch introduces an alternative calling convention for
MemRef function arguments in LLVM dialect. It converts MemRef
function arguments to LLVM bare pointers to the MemRef element
type instead of creating a MemRef descriptor. Bare pointers are
then promoted to a MemRef descriptors at the beginning of the
function. This calling convention is only enabled with a flag.
This is a stepping stone towards having an alternative and simpler
lowering for MemRefs when dynamic shapes are not needed. It can
also be used to temporarily overcome the issue with passing 'noalias'
attribute for MemRef arguments, discussed in [1, 2], since we can
now convert:
func @check_noalias(%static : memref<2xf32> {llvm.noalias = true}) {
return
}
into:
llvm.func @check_noalias(%arg0: !llvm<"float*"> {llvm.noalias = true}) {
%0 = llvm.mlir.undef ...
%1 = llvm.insertvalue %arg0, %0[0] ...
%2 = llvm.insertvalue %arg0, %1[1] ...
...
llvm.return
}
Related discussion:
[1] https://github.com/tensorflow/mlir/issues/309
[2] https://github.com/tensorflow/mlir/pull/337
WIP: I plan to move all the tests with only static shapes from
convert-memref-ops.mlir to an independent file so that
we can also have coverage for those tests with this
alternative calling convention.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72802
Files:
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h
mlir/include/mlir/Transforms/DialectConversion.h
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
mlir/lib/Transforms/DialectConversion.cpp
mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72802.238340.patch
Type: text/x-patch
Size: 16623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200115/91a98661/attachment-0001.bin>
More information about the llvm-commits
mailing list