[PATCH] D68377: [Builtins] Teach Clang about memccpy
Dávid Bolvanský via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 27 08:00:19 PDT 2019
xbolva00 updated this revision to Diff 226571.
xbolva00 added a comment.
Added new testcase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68377/new/
https://reviews.llvm.org/D68377
Files:
clang/include/clang/Basic/Builtins.def
clang/test/CodeGen/builtin-memfns.c
clang/test/CodeGen/memccpy-libcall.c
Index: clang/test/CodeGen/memccpy-libcall.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/memccpy-libcall.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fno-builtin-memccpy -emit-llvm < %s| FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+
+void *memccpy(void *, void const *, int, size_t);
+
+void test13(char *d, char *s, int c, size_t n) {
+ // CHECK: call i8* @memccpy{{.*}} #2
+ memccpy(d, s, c, n);
+}
+
+// CHECK: attributes #2 = { nobuiltin }
\ No newline at end of file
Index: clang/test/CodeGen/builtin-memfns.c
===================================================================
--- clang/test/CodeGen/builtin-memfns.c
+++ clang/test/CodeGen/builtin-memfns.c
@@ -4,6 +4,7 @@
typedef __SIZE_TYPE__ size_t;
void *memcpy(void *, void const *, size_t);
+void *memccpy(void *, void const *, int, size_t);
// CHECK: @test1
// CHECK: call void @llvm.memset.p0i8.i32
@@ -118,3 +119,9 @@
// CHECK: call void @llvm.memcpy{{.*}}(
memcpy(&dest_array, &dest_array, 2);
}
+
+// CHECK-LABEL: @test13
+void test13(char *d, char *s, int c, size_t n) {
+ // CHECK: call i8* @memccpy
+ memccpy(d, s, c, n);
+}
Index: clang/include/clang/Basic/Builtins.def
===================================================================
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -979,6 +979,7 @@
// when these functions are used in non-GNU mode. PR16138.
LIBBUILTIN(alloca, "v*z", "f", "stdlib.h", ALL_GNU_LANGUAGES)
// POSIX string.h
+LIBBUILTIN(memccpy, "v*v*vC*iz", "f", "string.h", ALL_GNU_LANGUAGES)
LIBBUILTIN(stpcpy, "c*c*cC*", "f", "string.h", ALL_GNU_LANGUAGES)
LIBBUILTIN(stpncpy, "c*c*cC*z", "f", "string.h", ALL_GNU_LANGUAGES)
LIBBUILTIN(strdup, "c*cC*", "f", "string.h", ALL_GNU_LANGUAGES)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68377.226571.patch
Type: text/x-patch
Size: 1845 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191027/8f51fe48/attachment-0001.bin>
More information about the cfe-commits
mailing list