[MLIR] Add support to use aligned_alloc to lower AllocOp from std to llvm
authorUday Bondhugula <uday@polymagelabs.com>
Mon, 6 Apr 2020 07:40:20 +0000 (13:10 +0530)
committerUday Bondhugula <uday@polymagelabs.com>
Wed, 8 Apr 2020 09:40:19 +0000 (15:10 +0530)
commit01d97a35493a8a306bfaa3ceb3e6fa49b05dea89
tree7d31ce6e459a419df359d0b8b2c5694845843498
parent11bd3e5c6549a4983be454ccfbeb16e88c9532db
[MLIR] Add support to use aligned_alloc to lower AllocOp from std to llvm

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. Setting 'use-aligned_alloc=1' will lead to
aligned_alloc being used for all heap allocations. An alignment and size
that works with the constraints of aligned_alloc is chosen.

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.

Differential Revision: https://reviews.llvm.org/D77528
mlir/include/mlir/Conversion/Passes.td
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h
mlir/lib/Analysis/Utils.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/test/Conversion/StandardToLLVM/convert-dynamic-memref-ops.mlir