[Clang, builtins] Added aligned_alloc, memalign support

This commit is contained in:
Dávid Bolvanský 2021-04-21 00:10:52 +02:00
parent 5a654bfeab
commit 9f1e2ee462
3 changed files with 28 additions and 0 deletions

View File

@ -980,6 +980,8 @@ LIBBUILTIN(strtol, "LicC*c**i", "f", "stdlib.h", ALL_LANGUAGES)
LIBBUILTIN(strtoll, "LLicC*c**i", "f", "stdlib.h", ALL_LANGUAGES)
LIBBUILTIN(strtoul, "ULicC*c**i", "f", "stdlib.h", ALL_LANGUAGES)
LIBBUILTIN(strtoull, "ULLicC*c**i", "f", "stdlib.h", ALL_LANGUAGES)
// C11 stdlib.h
LIBBUILTIN(aligned_alloc, "v*zz", "f", "stdlib.h", ALL_LANGUAGES)
// C99 string.h
LIBBUILTIN(memcpy, "v*v*vC*z", "f", "string.h", ALL_LANGUAGES)
LIBBUILTIN(memcmp, "ivC*vC*z", "f", "string.h", ALL_LANGUAGES)
@ -1061,6 +1063,8 @@ LIBBUILTIN(longjmp, "vJi", "frT", "setjmp.h", ALL_LANGUAGES)
// all languages, because losing this attribute would result in miscompilation
// when these functions are used in non-GNU mode. PR16138.
LIBBUILTIN(alloca, "v*z", "f", "stdlib.h", ALL_GNU_LANGUAGES)
// POSIX malloc.h
LIBBUILTIN(memalign, "v*zz", "f", "malloc.h", ALL_GNU_LANGUAGES)
// POSIX string.h
LIBBUILTIN(memccpy, "v*v*vC*iz", "f", "string.h", ALL_GNU_LANGUAGES)
LIBBUILTIN(mempcpy, "v*v*vC*z", "f", "string.h", ALL_GNU_LANGUAGES)

View File

@ -0,0 +1,12 @@
// RUN: %clang_cc1 -fno-builtin-aligned_alloc -emit-llvm < %s | FileCheck %s
typedef __SIZE_TYPE__ size_t;
void *aligned_alloc(size_t, size_t);
void *test(size_t alignment, size_t size) {
// CHECK: call i8* @aligned_alloc{{.*}} #2
return aligned_alloc(alignment, size);
}
// CHECK: attributes #2 = { nobuiltin "no-builtin-aligned_alloc" }

View File

@ -0,0 +1,12 @@
// RUN: %clang_cc1 -fno-builtin-memalign -emit-llvm < %s | FileCheck %s
typedef __SIZE_TYPE__ size_t;
void *memalign(size_t, size_t);
void *test(size_t alignment, size_t size) {
// CHECK: call i8* @memalign{{.*}} #2
return memalign(alignment, size);
}
// CHECK: attributes #2 = { nobuiltin "no-builtin-memalign" }