summaryrefslogtreecommitdiff
path: root/test/CodeGen/struct-copy.c
diff options
context:
space:
mode:
authorDavid Bolvansky <david.bolvansky@gmail.com>2019-08-14 08:32:31 +0000
committerDavid Bolvansky <david.bolvansky@gmail.com>2019-08-14 08:32:31 +0000
commitda40d804aa30b1e526bb715898ce1a2d4eebf29a (patch)
tree3b65d43e3d6f18d19269826eacf6d6c45b980c56 /test/CodeGen/struct-copy.c
parent9958a1776c35f3316f01fddd474e664add499c64 (diff)
downloadclang-da40d804aa30b1e526bb715898ce1a2d4eebf29a.tar.gz
[Codegen] Updated test for D66158
Reviewers: jdoerfert Reviewed By: jdoerfert Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66173 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368809 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/struct-copy.c')
-rw-r--r--test/CodeGen/struct-copy.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/test/CodeGen/struct-copy.c b/test/CodeGen/struct-copy.c
index 6f3b6643f0..a03bb7d658 100644
--- a/test/CodeGen/struct-copy.c
+++ b/test/CodeGen/struct-copy.c
@@ -1,7 +1,39 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | grep 'call.*llvm.memcpy'
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
struct x { int a[100]; };
-
+// CHECK-LABEL: @foo(
+// CHECK-NEXT: entry:
+// CHECK-NEXT: [[P_ADDR:%.*]] = alloca %struct.x*, align 8
+// CHECK-NEXT: [[Q_ADDR:%.*]] = alloca %struct.x*, align 8
+// CHECK-NEXT: store %struct.x* [[P:%.*]], %struct.x** [[P_ADDR]], align 8
+// CHECK-NEXT: store %struct.x* [[Q:%.*]], %struct.x** [[Q_ADDR]], align 8
+// CHECK-NEXT: [[TMP0:%.*]] = load %struct.x*, %struct.x** [[P_ADDR]], align 8
+// CHECK-NEXT: [[TMP1:%.*]] = load %struct.x*, %struct.x** [[Q_ADDR]], align 8
+// CHECK-NEXT: [[TMP2:%.*]] = bitcast %struct.x* [[TMP0]] to i8*
+// CHECK-NEXT: [[TMP3:%.*]] = bitcast %struct.x* [[TMP1]] to i8*
+// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[TMP2]], i8* align 4 [[TMP3]], i64 400, i1 false)
+// CHECK-NEXT: ret void
+//
void foo(struct x *P, struct x *Q) {
*P = *Q;
}
+
+// CHECK: declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg)
+
+// CHECK-LABEL: @bar(
+// CHECK-NEXT: entry:
+// CHECK-NEXT: [[P_ADDR:%.*]] = alloca %struct.x*, align 8
+// CHECK-NEXT: [[Q_ADDR:%.*]] = alloca %struct.x*, align 8
+// CHECK-NEXT: store %struct.x* [[P:%.*]], %struct.x** [[P_ADDR]], align 8
+// CHECK-NEXT: store %struct.x* [[Q:%.*]], %struct.x** [[Q_ADDR]], align 8
+// CHECK-NEXT: [[TMP0:%.*]] = load %struct.x*, %struct.x** [[P_ADDR]], align 8
+// CHECK-NEXT: [[TMP1:%.*]] = bitcast %struct.x* [[TMP0]] to i8*
+// CHECK-NEXT: [[TMP2:%.*]] = load %struct.x*, %struct.x** [[Q_ADDR]], align 8
+// CHECK-NEXT: [[TMP3:%.*]] = bitcast %struct.x* [[TMP2]] to i8*
+// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[TMP1]], i8* align 4 [[TMP3]], i64 400, i1 false)
+// CHECK-NEXT: ret void
+//
+void bar(struct x *P, struct x *Q) {
+ __builtin_memcpy(P, Q, sizeof(struct x));
+}