From: Fariborz Jahanian Date: Thu, 30 Apr 2009 16:31:11 +0000 (+0000) Subject: API for message dispatch of methods returning floats X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b2bad017b5f86c83aeb80d186696a4c8d59f68f;p=clang API for message dispatch of methods returning floats to match gcc's closely. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70493 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index af06f34682..1dfa9cd411 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -5002,11 +5002,18 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend( Name += "objc_msgSend_stret_fixup"; } } - else if (ResultType->isFloatingType() && - // Selection of frret API only happens in 32bit nonfragile ABI. - CGM.getTargetData().getTypePaddedSize(ObjCTypes.LongTy) == 4) { - Fn = ObjCTypes.getMessageSendFpretFixupFn(); - Name += "objc_msgSend_fpret_fixup"; + else if (!IsSuper && ResultType->isFloatingType()) { + if (const BuiltinType *BT = ResultType->getAsBuiltinType()) { + BuiltinType::Kind k = BT->getKind(); + if (k == BuiltinType::LongDouble) { + Fn = ObjCTypes.getMessageSendFpretFixupFn(); + Name += "objc_msgSend_fpret_fixup"; + } + else { + Fn = ObjCTypes.getMessageSendFixupFn(); + Name += "objc_msgSend_fixup"; + } + } } else { #if 0 diff --git a/test/CodeGenObjC/metadata-symbols-64.m b/test/CodeGenObjC/metadata-symbols-64.m index 0cd4dacf12..4f3691022f 100644 --- a/test/CodeGenObjC/metadata-symbols-64.m +++ b/test/CodeGenObjC/metadata-symbols-64.m @@ -34,6 +34,8 @@ // RUN: grep '@"\\01l_objc_msgSend_fixup_alloc" = weak hidden global .* section "__DATA, __objc_msgrefs, coalesced", align 16' %t && // RUN: grep '@_objc_empty_cache = external global' %t && // RUN: grep '@_objc_empty_vtable = external global' %t && +// RUN: grep '@objc_msgSend_fixup(' %t && +// RUN: grep '@objc_msgSend_fpret_fixup(' %t && // RUN: true @@ -94,7 +96,36 @@ llvm-gcc -m64 -emit-llvm -S -o - metadata-symbols-64.m | \ } @end +// Test for FP dispatch method APIs +@interface Example +@end + +float FLOAT; +double DOUBLE; +long double LONGDOUBLE; +id ID; + +@implementation Example + - (double) RET_DOUBLE + { + return DOUBLE; + } + - (float) RET_FLOAT + { + return FLOAT; + } + - (long double) RET_LONGDOUBLE + { + return LONGDOUBLE; + } +@end + void *f0(id x) { + Example* pe; + double dd = [pe RET_DOUBLE]; + dd = [pe RET_FLOAT]; + dd = [pe RET_LONGDOUBLE]; + [B im0]; [C im1]; [D alloc];