summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-01-30 00:16:39 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-01-30 00:16:39 +0000
commit13b4304937baf3e74a33cfd81a0494a01f8f1b01 (patch)
tree8a99e387121482279d141b93c819bc388dcba6d2
parent1ba73059744e514188d49e52c00804dbd47d20a1 (diff)
downloadbcm5719-llvm-13b4304937baf3e74a33cfd81a0494a01f8f1b01.tar.gz
bcm5719-llvm-13b4304937baf3e74a33cfd81a0494a01f8f1b01.zip
Objective-C [IRGen]. Generator a tail call to objc_getProperty() in
synthesized getters for performance improvement. // rdar://15884113 llvm-svn: 200430
-rw-r--r--clang/lib/CodeGen/CGObjC.cpp6
-rw-r--r--clang/test/CodeGenObjC/arc-property.m2
-rw-r--r--clang/test/CodeGenObjC/arc.m4
-rw-r--r--clang/test/CodeGenObjC/getter-property-mismatch.m2
4 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 9c23ba4b1ee..ae1349fbd8a 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -892,10 +892,14 @@ CodeGenFunction::generateObjCGetterBody(const ObjCImplementationDecl *classImpl,
// 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
diff --git a/clang/test/CodeGenObjC/arc-property.m b/clang/test/CodeGenObjC/arc-property.m
index c3c7e2bc11e..8398a1b60f0 100644
--- a/clang/test/CodeGenObjC/arc-property.m
+++ b/clang/test/CodeGenObjC/arc-property.m
@@ -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:]"(
diff --git a/clang/test/CodeGenObjC/arc.m b/clang/test/CodeGenObjC/arc.m
index f98aa32d12a..06628b9ff0f 100644
--- a/clang/test/CodeGenObjC/arc.m
+++ b/clang/test/CodeGenObjC/arc.m
@@ -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
diff --git a/clang/test/CodeGenObjC/getter-property-mismatch.m b/clang/test/CodeGenObjC/getter-property-mismatch.m
index 21ed6eea68e..fe415d5358d 100644
--- a/clang/test/CodeGenObjC/getter-property-mismatch.m
+++ b/clang/test/CodeGenObjC/getter-property-mismatch.m
@@ -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]]
OpenPOWER on IntegriCloud