[PATCH] D117091: [Clang] Add attributes alloc_size and alloc_align to mm_malloc
Dávid Bolvanský via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 22 05:28:01 PST 2022
xbolva00 updated this revision to Diff 402206.
xbolva00 added a comment.
Added testcase
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117091/new/
https://reviews.llvm.org/D117091
Files:
clang/lib/Headers/mm_malloc.h
clang/test/Headers/mm_malloc.c
Index: clang/test/Headers/mm_malloc.c
===================================================================
--- /dev/null
+++ clang/test/Headers/mm_malloc.c
@@ -0,0 +1,11 @@
+// RUN: %clang -emit-llvm -std=c11 -x c %s -O1 --target=x86_64-linux-gnu -S -o - | FileCheck %s
+#include <mm_malloc.h>
+
+_Bool align_test(void) {
+// CHECK-LABEL: @align_test(
+// CHECK: ret i1 true
+ void *p = _mm_malloc(2014, 16);
+ _Bool ret = ((__UINTPTR_TYPE__)p % 16) == 0;
+ _mm_free(p);
+ return ret;
+}
Index: clang/lib/Headers/mm_malloc.h
===================================================================
--- clang/lib/Headers/mm_malloc.h
+++ clang/lib/Headers/mm_malloc.h
@@ -28,9 +28,9 @@
#if !(defined(_WIN32) && defined(_mm_malloc))
static __inline__ void *__attribute__((__always_inline__, __nodebug__,
- __malloc__))
-_mm_malloc(size_t __size, size_t __align)
-{
+ __malloc__, alloc_size(1),
+ alloc_align(2)))
+_mm_malloc(size_t __size, size_t __align) {
if (__align == 1) {
return malloc(__size);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117091.402206.patch
Type: text/x-patch
Size: 1139 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220122/749f5153/attachment.bin>
More information about the cfe-commits
mailing list