Introduce support for lib function aligned_alloc in TLI / memory builtins
authorUday Bondhugula <uday@polymagelabs.com>
Sat, 28 Mar 2020 05:59:52 +0000 (11:29 +0530)
committerUday Bondhugula <uday@polymagelabs.com>
Sun, 29 Mar 2020 18:06:24 +0000 (23:36 +0530)
commitc0955edfd6ec51e9a3720f9bfc90bac2e511c06d
tree0c4af63de7b7618c80745ed87641db1c2b2c8caa
parentcce3d96bcc6585e5f134fc093ec50813659c5c5e
Introduce support for lib function aligned_alloc in TLI / memory builtins

Aligned_alloc is a standard lib function and has been in glibc since
2.16 and in the C11 standard. It has semantics similar to malloc/calloc
for several analyses/transforms. This patch introduces aligned_alloc
in target library info and memory builtins. Subsequent ones will
make other passes aware and fix https://bugs.llvm.org/show_bug.cgi?id=44062

This change will also be useful to LLVM generators that need to allocate
buffers of vector elements larger than 16 bytes (for eg. 256-bit ones),
element boundary alignment for which is not typically provided by glibc malloc.

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Differential Revision: https://reviews.llvm.org/D76970
llvm/include/llvm/Analysis/MemoryBuiltins.h
llvm/include/llvm/Analysis/TargetLibraryInfo.def
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/lib/Analysis/TargetLibraryInfo.cpp
llvm/lib/Transforms/Utils/BuildLibCalls.cpp
llvm/test/Transforms/DeadStoreElimination/simple.ll
llvm/unittests/Analysis/TargetLibraryInfoTest.cpp