r200430 - Objective-C [IRGen]. Generator a tail call to objc_getProperty() in
Fariborz Jahanian
fjahanian at apple.com
Wed Jan 29 16:16:40 PST 2014
Author: fjahanian
Date: Wed Jan 29 18:16:39 2014
New Revision: 200430
URL: http://llvm.org/viewvc/llvm-project?rev=200430&view=rev
Log:
Objective-C [IRGen]. Generator a tail call to objc_getProperty() in
synthesized getters for performance improvement.
// rdar://15884113
Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/arc-property.m
cfe/trunk/test/CodeGenObjC/arc.m
cfe/trunk/test/CodeGenObjC/getter-property-mismatch.m
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=200430&r1=200429&r2=200430&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed Jan 29 18:16:39 2014
@@ -892,10 +892,14 @@ CodeGenFunction::generateObjCGetterBody(
// FIXME: We shouldn't need to get the function info here, the
// runtime already should have computed it to build the function.
+ llvm::Instruction *CallInstruction;
RValue RV = EmitCall(getTypes().arrangeFreeFunctionCall(propType, args,
FunctionType::ExtInfo(),
RequiredArgs::All),
- getPropertyFn, ReturnValueSlot(), args);
+ getPropertyFn, ReturnValueSlot(), args, 0,
+ &CallInstruction);
+ if (llvm::CallInst *call = dyn_cast<llvm::CallInst>(CallInstruction))
+ call->setTailCall();
// We need to fix the type here. Ivars with copy & retain are
// always objects so we don't need to worry about complex or
Modified: cfe/trunk/test/CodeGenObjC/arc-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-property.m?rev=200430&r1=200429&r2=200430&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc-property.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-property.m Wed Jan 29 18:16:39 2014
@@ -67,7 +67,7 @@ static Class theGlobalClass;
// CHECK: define internal i8* @"\01-[Test2 theClass]"(
// CHECK: [[OFFSET:%.*]] = load i64* @"OBJC_IVAR_$_Test2._theClass"
-// CHECK-NEXT: [[T0:%.*]] = call i8* @objc_getProperty(i8* {{.*}}, i8* {{.*}}, i64 [[OFFSET]], i1 zeroext true)
+// CHECK-NEXT: [[T0:%.*]] = tail call i8* @objc_getProperty(i8* {{.*}}, i8* {{.*}}, i64 [[OFFSET]], i1 zeroext true)
// CHECK-NEXT: ret i8* [[T0]]
// CHECK: define internal void @"\01-[Test2 setTheClass:]"(
Modified: cfe/trunk/test/CodeGenObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc.m?rev=200430&r1=200429&r2=200430&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc.m Wed Jan 29 18:16:39 2014
@@ -1004,7 +1004,7 @@ void test37(void) {
@synthesize x;
@end
// CHECK: define internal i8* @"\01-[Test45 x]"(
-// CHECK: [[CALL:%.*]] = call i8* @objc_getProperty(
+// CHECK: [[CALL:%.*]] = tail call i8* @objc_getProperty(
// CHECK-NEXT: ret i8* [[CALL]]
// rdar://problem/9315552
@@ -1352,7 +1352,7 @@ void test62(void) {
@implementation Person
@synthesize address;
@end
-// CHECK: call i8* @objc_getProperty
+// CHECK: tail call i8* @objc_getProperty
// CHECK: call void @objc_setProperty
// Verify that we successfully parse and preserve this attribute in
Modified: cfe/trunk/test/CodeGenObjC/getter-property-mismatch.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/getter-property-mismatch.m?rev=200430&r1=200429&r2=200430&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/getter-property-mismatch.m (original)
+++ cfe/trunk/test/CodeGenObjC/getter-property-mismatch.m Wed Jan 29 18:16:39 2014
@@ -13,7 +13,7 @@
@synthesize filenamesToServerLocation=_filenamesToServerLocation;
@end
-// CHECK: [[CALL:%.*]] = call i8* @objc_getProperty
+// CHECK: [[CALL:%.*]] = tail call i8* @objc_getProperty
// CHECK: [[ONE:%.*]] = bitcast i8* [[CALL:%.*]] to [[T1:%.*]]*
// CHECK: [[TWO:%.*]] = bitcast [[T1]]* [[ONE]] to [[T2:%.*]]*
// CHECK: ret [[T2]]* [[TWO]]
More information about the cfe-commits
mailing list