objc IRGen for Next runtime message API.

The prototype for objc_msgSend() is technically variadic - 
`id objc_msgSend(id, SEL, ...)`. 
But all method calls should use a prototype that matches the method, 
not the prototype for objc_msgSend itself().
// rdar://9048030

llvm-svn: 126754
This commit is contained in:
Fariborz Jahanian 2011-03-01 17:28:13 +00:00
parent b3a58b08e0
commit cf7f66f16f
5 changed files with 31 additions and 9 deletions

View File

@ -1275,7 +1275,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
if (CE->getOpcode() == llvm::Instruction::BitCast &&
ActualFT->getReturnType() == CurFT->getReturnType() &&
ActualFT->getNumParams() == CurFT->getNumParams() &&
ActualFT->getNumParams() == Args.size()) {
ActualFT->getNumParams() == Args.size() &&
(CurFT->isVarArg() || !ActualFT->isVarArg())) {
bool ArgsMatch = true;
for (unsigned i = 0, e = ActualFT->getNumParams(); i != e; ++i)
if (ActualFT->getParamType(i) != CurFT->getParamType(i)) {

View File

@ -1294,7 +1294,8 @@ private:
llvm::Value *Receiver,
QualType Arg0Ty,
bool IsSuper,
const CallArgList &CallArgs);
const CallArgList &CallArgs,
const ObjCMethodDecl *Method);
/// GetClassGlobal - Return the global variable for the Objective-C
/// class of the given name.
@ -5622,7 +5623,8 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend(
llvm::Value *Receiver,
QualType Arg0Ty,
bool IsSuper,
const CallArgList &CallArgs) {
const CallArgList &CallArgs,
const ObjCMethodDecl *Method) {
// FIXME. Even though IsSuper is passes. This function doese not handle calls
// to 'super' receivers.
CodeGenTypes &Types = CGM.getTypes();
@ -5693,7 +5695,8 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend(
FunctionType::ExtInfo());
llvm::Value *Callee = CGF.Builder.CreateStructGEP(Arg1, 0);
Callee = CGF.Builder.CreateLoad(Callee);
const llvm::FunctionType *FTy = Types.GetFunctionType(FnInfo1, true);
const llvm::FunctionType *FTy =
Types.GetFunctionType(FnInfo1, Method ? Method->isVariadic() : false);
Callee = CGF.Builder.CreateBitCast(Callee,
llvm::PointerType::getUnqual(FTy));
return CGF.EmitCall(FnInfo1, Callee, Return, ActualArgs);
@ -5716,7 +5719,7 @@ CGObjCNonFragileABIMac::GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
false, CallArgs, Method, ObjCTypes)
: EmitMessageSend(CGF, Return, ResultType, Sel,
Receiver, CGF.getContext().getObjCIdType(),
false, CallArgs);
false, CallArgs, Method);
}
llvm::GlobalVariable *
@ -5870,7 +5873,7 @@ CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
true, CallArgs, Method, ObjCTypes)
: EmitMessageSend(CGF, Return, ResultType, Sel,
ObjCSuper, ObjCTypes.SuperPtrCTy,
true, CallArgs);
true, CallArgs, Method);
}
llvm::Value *CGObjCNonFragileABIMac::EmitSelector(CGBuilderTy &Builder,

View File

@ -16,7 +16,7 @@
// CHECK-X86_32: define void @t0()
// CHECK-X86_32: call float bitcast {{.*}} @objc_msgSend_fpret to
// CHECK-X86_32: call double {{.*}} @objc_msgSend_fpret(
// CHECK-X86_32: call double bitcast {{.*}} @objc_msgSend_fpret to
// CHECK-X86_32: call x86_fp80 bitcast {{.*}} @objc_msgSend_fpret to
// CHECK-X86_32: }
//

View File

@ -13,8 +13,8 @@ void f0(id a) {
int i;
MyPoint pt = { 1, 2};
// CHECK-MAC: call {{.*}} @objc_msgSend(
// CHECK-MAC-NF: call {{.*}} @objc_msgSend(
// CHECK-MAC: call {{.*}} @objc_msgSend to
// CHECK-MAC-NF: call {{.*}} @objc_msgSend to
// CHECK-GNU: call {{.*}} @objc_msg_lookup(
// CHECK-GNU-NF: call {{.*}} @objc_msg_lookup_sender(
[a print0];

View File

@ -0,0 +1,18 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -S -o - %s | FileCheck %s
// rdar://9048030
@interface Foo
+(id)alloc;
-(id)init;
-(id)self;
-(id)retain;
-(void)release;
-(id)autorelease;
@end
void test(void)
{
[[[[[[Foo alloc] init] retain] autorelease] self] release];
}
// CHECK-NOT: xorb