Only perform the null-initialization of an aggregate result of a message
send if the receiver is null.  Normally it's not worthwhile to check this,
but avoiding the null-initialization is nice, and this also avoids nasty
problems where the null-initialization is visible within the call because
we use an aliased result buffer.  rdar://problem/9402992



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131366 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGenObjC/messages-2.m b/test/CodeGenObjC/messages-2.m
index 5ef2261..e4e8cfb 100644
--- a/test/CodeGenObjC/messages-2.m
+++ b/test/CodeGenObjC/messages-2.m
@@ -147,17 +147,29 @@
 // rdar://problem/7854674
 // CHECK:    define void @test0([[A:%.*]]*
 // CHECK-NF: define void @test0([[A:%.*]]*
-void test0(A *a) {
-  // CHECK:         alloca [[A]]*
+void test0(A *x) {
+  // CHECK:         [[X:%.*]] = alloca [[A]]*
   // CHECK-NEXT:    [[POINT:%.*]] = alloca [[POINT_T:%.*]],
-  // CHECK-NF:      alloca [[A]]*
-  // CHECK-NF-NEXT: [[POINT:%.*]] = alloca [[POINT_T:%.*]],
-
+  // CHECK:         [[T0:%.*]] = load [[A]]** [[X]]
+  // CHECK:         [[T1:%.*]] = bitcast [[A]]* [[T0]] to i8*
+  // CHECK-NEXT:    icmp eq i8* [[T1]], null
+  // CHECK-NEXT:    br i1
+  // CHECK:         call {{.*}} @objc_msgSend_stret to
+  // CHECK-NEXT:    br label
   // CHECK:         [[T0:%.*]] = bitcast [[POINT_T]]* [[POINT]] to i8*
   // CHECK-NEXT:    call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 48, i32 4, i1 false)
-  // CHECK-NEXT:    call {{.*}} @objc_msgSend_stret to
+  // CHECK-NEXT:    br label
+
+  // CHECK-NF:      [[X:%.*]] = alloca [[A]]*
+  // CHECK-NF-NEXT: [[POINT:%.*]] = alloca [[POINT_T:%.*]],
+  // CHECK-NF:      [[T0:%.*]] = load [[A]]** [[X]]
+  // CHECK-NF:      [[T1:%.*]] = bitcast [[A]]* [[T0]] to i8*
+  // CHECK-NF-NEXT: icmp eq i8* [[T1]], null
+  // CHECK-NF-NEXT: br i1
+  // CHECK-NF:      call {{.*}} @objc_msgSend_stret to
+  // CHECK-NF-NEXT: br label
   // CHECK-NF:      [[T0:%.*]] = bitcast [[POINT_T]]* [[POINT]] to i8*
   // CHECK-NF-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 48, i32 4, i1 false)
-  // CHECK-NF-NEXT: call {{.*}} @objc_msgSend_stret to
-  MyPoint point = [a returnAPoint];
+  // CHECK-NF-NEXT: br label
+  MyPoint point = [x returnAPoint];
 }