summaryrefslogtreecommitdiffstats
path: root/test/CodeGen
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2018-07-31 23:35:09 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2018-07-31 23:35:09 +0000
commit0f097ac04fc21e27a382b6b896f52a12e0c02b97 (patch)
tree28b9d60890f48a5b68bbe3bb5fafd72546339a25 /test/CodeGen
parent13ac9b27be07334eac62b132de08677fa50b44e1 (diff)
[constexpr] Support for constant evaluation of __builtin_memcpy and
__builtin_memmove (in non-type-punning cases). This is intended to permit libc++ to make std::copy etc constexpr without sacrificing the optimization that uses memcpy on trivially-copyable types. __builtin_strcpy and __builtin_wcscpy are not handled by this change. They'd be straightforward to add, but we haven't encountered a need for them just yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338455 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen')
-rw-r--r--test/CodeGen/builtin-memfns.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/CodeGen/builtin-memfns.c b/test/CodeGen/builtin-memfns.c
index d93a5aadae..4862677453 100644
--- a/test/CodeGen/builtin-memfns.c
+++ b/test/CodeGen/builtin-memfns.c
@@ -1,5 +1,8 @@
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm < %s| FileCheck %s
+typedef __WCHAR_TYPE__ wchar_t;
+typedef __SIZE_TYPE__ size_t;
+
// CHECK: @test1
// CHECK: call void @llvm.memset.p0i8.i32
// CHECK: call void @llvm.memset.p0i8.i32
@@ -83,3 +86,17 @@ void test9() {
// CHECK: call void @llvm.memcpy{{.*}} align 16 {{.*}} align 16 {{.*}} 16, i1 false)
__builtin_memcpy(x, y, sizeof(y));
}
+
+wchar_t dest;
+wchar_t src;
+
+// CHECK-LABEL: @test10
+// FIXME: Consider lowering these to llvm.memcpy / llvm.memmove.
+void test10() {
+ // CHECK: call i32* @wmemcpy(i32* @dest, i32* @src, i32 4)
+ __builtin_wmemcpy(&dest, &src, 4);
+
+ // CHECK: call i32* @wmemmove(i32* @dest, i32* @src, i32 4)
+ __builtin_wmemmove(&dest, &src, 4);
+}
+