Don't nil check non-nil class receiver of AArch64 stret calls.

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.

llvm-svn: 249205
This commit is contained in:
Ahmed Bougacha 2015-10-02 22:41:59 +00:00
parent 7744d9a201
commit a3df87b5a9
2 changed files with 10 additions and 7 deletions

View 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);

View 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(
}