forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlir] Introduce bare ptr calling convention for MemRefs in LLVM dialect
Summary: 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] tensorflow/mlir#309 [2] tensorflow/mlir#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. Reviewers: ftynse, bondhugula, nicolasvasilache Subscribers: jholewinski, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, csigg, arpith-jacob, mgester, lucyrfox, herhut, aartbik, liufengdb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72802
- Loading branch information
Showing
7 changed files
with
221 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// RUN: mlir-opt -convert-std-to-llvm -split-input-file -convert-std-to-llvm-use-bare-ptr-memref-call-conv=1 %s | FileCheck %s --check-prefix=BAREPTR | ||
|
||
// BAREPTR-LABEL: func @check_noalias | ||
// BAREPTR-SAME: [[ARG:%.*]]: !llvm<"float*"> {llvm.noalias = true} | ||
func @check_noalias(%static : memref<2xf32> {llvm.noalias = true}) { | ||
return | ||
} | ||
|
||
// WIP: Move tests with static shapes from convert-memref-ops.mlir here. |