summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenObjC/strong-in-c-struct.m
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2018-10-02 01:00:44 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2018-10-02 01:00:44 +0000
commit9d34307788056d8be15863697e1b7ec7ec3f204e (patch)
tree75a0ef7efc185a4cc36aa58cd5474b7cc1d2e54a /clang/test/CodeGenObjC/strong-in-c-struct.m
parent31fddbac8fa7ca0f18b6781a05346b447a607c4f (diff)
downloadbcm5719-llvm-9d34307788056d8be15863697e1b7ec7ec3f204e.tar.gz
bcm5719-llvm-9d34307788056d8be15863697e1b7ec7ec3f204e.zip
[CodeGen] Before entering the loop that copies a non-trivial array field
of a non-trivial C struct, copy the preceding trivial fields that haven't been copied. This commit fixes a bug where the instructions used to copy the preceding trivial fields were emitted inside the loop body. rdar://problem/44185064 llvm-svn: 343556
Diffstat (limited to 'clang/test/CodeGenObjC/strong-in-c-struct.m')
-rw-r--r--clang/test/CodeGenObjC/strong-in-c-struct.m31
1 files changed, 31 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjC/strong-in-c-struct.m b/clang/test/CodeGenObjC/strong-in-c-struct.m
index 9c284049b55..494b3b26fbd 100644
--- a/clang/test/CodeGenObjC/strong-in-c-struct.m
+++ b/clang/test/CodeGenObjC/strong-in-c-struct.m
@@ -485,8 +485,39 @@ void test_constructor_destructor_StructArray(void) {
StructArray t;
}
+// Test that StructArray's field 'd' is copied before entering the loop.
+
+// CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_t0w8_AB8s24n4_t8w16_s24_AE(i8** %[[DST:.*]], i8** %[[SRC:.*]])
+// CHECK: entry:
+// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
+// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
+// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
+// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
+// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
+// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
+// CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i64*
+// CHECK: %[[V3:.*]] = bitcast i8** %[[V1]] to i64*
+// CHECK: %[[V4:.*]] = load i64, i64* %[[V3]], align 8
+// CHECK: store i64 %[[V4]], i64* %[[V2]], align 8
+
+// CHECK: phi i8**
+// CHECK: phi i8**
+
+// CHECK: phi i8**
+// CHECK: phi i8**
+
+// CHECK-NOT: load i64, i64* %
+// CHECK-NOT: store i64 %
+// CHECK: call void @__copy_constructor_8_8_t0w16_s16(
+
+void test_copy_constructor_StructArray(StructArray a) {
+ StructArray t = a;
+}
+
// Check that IRGen copies the 9-bit bitfield emitting i16 load and store.
+// CHECK: define void @test_copy_constructor_Bitfield0(
+
// CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_s0_t8w2(
// CHECK: %[[V4:.*]] = bitcast i8** %{{.*}} to i8*
// CHECK: %[[V5:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 8
OpenPOWER on IntegriCloud