It turns out that the Objective-C message lookup functions can throw exceptions after all...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143205 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Chisnall 2011-10-28 17:55:06 +00:00
Родитель c49bd11f96
Коммит 6f3887ec36
1 изменённых файлов: 14 добавлений и 11 удалений

Просмотреть файл

@ -538,11 +538,12 @@ protected:
llvm::Value *cmd, llvm::Value *cmd,
llvm::MDNode *node) { llvm::MDNode *node) {
CGBuilderTy &Builder = CGF.Builder; CGBuilderTy &Builder = CGF.Builder;
llvm::Value *imp = Builder.CreateCall2(MsgLookupFn, llvm::Value *args[] = {
EnforceType(Builder, Receiver, IdTy), EnforceType(Builder, Receiver, IdTy),
EnforceType(Builder, cmd, SelectorTy)); EnforceType(Builder, cmd, SelectorTy) };
cast<llvm::CallInst>(imp)->setMetadata(msgSendMDKind, node); llvm::CallSite imp = CGF.EmitCallOrInvoke(MsgLookupFn, args);
return imp; imp->setMetadata(msgSendMDKind, node);
return imp.getInstruction();
} }
virtual llvm::Value *LookupIMPSuper(CodeGenFunction &CGF, virtual llvm::Value *LookupIMPSuper(CodeGenFunction &CGF,
llvm::Value *ObjCSuper, llvm::Value *ObjCSuper,
@ -597,16 +598,17 @@ class CGObjCGNUstep : public CGObjCGNU {
// The lookup function is guaranteed not to capture the receiver pointer. // The lookup function is guaranteed not to capture the receiver pointer.
LookupFn->setDoesNotCapture(1); LookupFn->setDoesNotCapture(1);
llvm::CallInst *slot = llvm::Value *args[] = {
Builder.CreateCall3(LookupFn,
EnforceType(Builder, ReceiverPtr, PtrToIdTy), EnforceType(Builder, ReceiverPtr, PtrToIdTy),
EnforceType(Builder, cmd, SelectorTy), EnforceType(Builder, cmd, SelectorTy),
EnforceType(Builder, self, IdTy)); EnforceType(Builder, self, IdTy) };
slot->setOnlyReadsMemory(); llvm::CallSite slot = CGF.EmitCallOrInvoke(LookupFn, args);
slot.setOnlyReadsMemory();
slot->setMetadata(msgSendMDKind, node); slot->setMetadata(msgSendMDKind, node);
// Load the imp from the slot // Load the imp from the slot
llvm::Value *imp = Builder.CreateLoad(Builder.CreateStructGEP(slot, 4)); llvm::Value *imp =
Builder.CreateLoad(Builder.CreateStructGEP(slot.getInstruction(), 4));
// The lookup function may have changed the receiver, so make sure we use // The lookup function may have changed the receiver, so make sure we use
// the new one. // the new one.
@ -1180,8 +1182,9 @@ CGObjCGNU::GenerateMessageSend(CodeGenFunction &CGF,
break; break;
case CodeGenOptions::Mixed: case CodeGenOptions::Mixed:
case CodeGenOptions::NonLegacy: case CodeGenOptions::NonLegacy:
if (CGM.ReturnTypeUsesFPRet(ResultType) || (Method && Method->isVariadic())) { if (CGM.ReturnTypeUsesFPRet(ResultType)) {
imp = LookupIMP(CGF, Receiver, cmd, node); imp = CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy, IdTy, true),
"objc_msgSend_fpret");
} else if (CGM.ReturnTypeUsesSRet(FnInfo)) { } else if (CGM.ReturnTypeUsesSRet(FnInfo)) {
// The actual types here don't matter - we're going to bitcast the // The actual types here don't matter - we're going to bitcast the
// function anyway // function anyway