[PATCH] D77528: [MLIR] Add support to use aligned_alloc to lower AllocOp from std to llvm

Uday Bondhugula via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 01:03:46 PDT 2020


bondhugula created this revision.
Herald added subscribers: llvm-commits, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a project: LLVM.
bondhugula edited the summary of this revision.
bondhugula added reviewers: nicolasvasilache, ftynse, dcaballe.

Support to recognize and deal with aligned_alloc was recently added to
LLVM's TLI/MemoryBuiltins and its various optimization passes. This
revision adds support for generation of aligned_alloc's when lowering
AllocOp from std to LLVM. Use aligned_alloc whenever (1) an element type
of a memref is larger than 16 bytes (since glibc malloc will not align
to element type boundaries in such cases) and no alignment attribute is
specified, and (2) when the cmd line flag -aligned-alloc is specified and an
alignment attribute exists on the alloc op. malloc is still used
whenever elt type size is <= 16 bytes.

Using aligned_alloc is preferable to "using malloc and adjusting the
allocated pointer to align for indexing" because the pointer access
arithmetic done for the latter only makes it harder for LLVM passes to
deal with for analysis, optimization, attribute deduction, and rewrites.

Depends on D76602 <https://reviews.llvm.org/D76602>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77528

Files:
  mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
  mlir/test/Conversion/StandardToLLVM/convert-dynamic-memref-ops.mlir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77528.255244.patch
Type: text/x-patch
Size: 10050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200406/4d51bab5/attachment.bin>


More information about the llvm-commits mailing list