]> granicus.if.org Git - clang/commitdiff
Don't nil check non-nil class receiver of AArch64 stret calls.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Fri, 2 Oct 2015 22:41:59 +0000 (22:41 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Fri, 2 Oct 2015 22:41:59 +0000 (22:41 +0000)
I randomly came across this difference between AArch64 and other targets:
on the latter, we don't emit nil checks for known non-nil class method
calls thanks to r247350, but we still do for AArch64 stret calls.

They use different code paths, because those are special, as they go
through the regular msgSend, not the msgSend*_stret variants.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249205 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCMac.cpp
test/CodeGenObjC/stret-1.m

index 8c62eb9dde9688a823fdda56b3f6ac4d1891595a..5435d4a61c88176b32a0c1f6c02c0343765aaa0e 100644 (file)
@@ -1931,7 +1931,7 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF,
   } else {
     // arm64 uses objc_msgSend for stret methods and yet null receiver check
     // must be made for it.
-    if (!IsSuper && CGM.ReturnTypeUsesSRet(MSI.CallInfo))
+    if (ReceiverCanBeNull && CGM.ReturnTypeUsesSRet(MSI.CallInfo))
       nullReturn.init(CGF, Arg0);
     Fn = (ObjCABI == 2) ? ObjCTypes.getSendFn2(IsSuper)
       : ObjCTypes.getSendFn(IsSuper);
index f45d1219da65905d086cedefab6c88f15bf4b717..a7bcdda48b14c16d2603259134f9e1c50094237c 100644 (file)
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -fblocks -triple arm64-apple-darwin %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-ARM64
+// RUN: %clang_cc1 -fblocks -triple arm64-apple-darwin %s -emit-llvm -o - | FileCheck %s
 // rdar://12416433
 
 struct stret { int x[100]; };
-struct stret zero;
 struct stret one = {{1}};
 
 @interface Test  @end
@@ -13,8 +12,12 @@ struct stret one = {{1}};
 
 int main(int argc, const char **argv)
 {
-    struct stret st2 = one;
-    if (argc) st2 = [(id)(argc&~255) method];
-}
+    [(id)(argc&~255) method];
+    // CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (%struct.stret*, i8*, i8*)*)(%struct.stret* sret [[T0:%[^,]+]]
+    // CHECK: [[T0P:%.*]] = bitcast %struct.stret* [[T0]] to i8*
+    // CHECK: call void @llvm.memset.p0i8.i64(i8* [[T0P]], i8 0, i64 400, i32 4, i1 false)
 
-// CHECK-ARM64: call void @llvm.memset.p0i8.i64(i8* [[T0:%.*]], i8 0, i64 400, i32 4, i1 false)
+    [Test method];
+    // CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (%struct.stret*, i8*, i8*)*)(%struct.stret* sret [[T1:%[^,]+]]
+    // CHECK-NOT: call void @llvm.memset.p0i8.i64(
+}