[cfe-commits] r68043 - /cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
Fariborz Jahanian
fjahanian at apple.com
Mon Mar 30 11:02:14 PDT 2009
Author: fjahanian
Date: Mon Mar 30 13:02:14 2009
New Revision: 68043
URL: http://llvm.org/viewvc/llvm-project?rev=68043&view=rev
Log:
Use CodeGenModule API for ObjC runtime function references.
Patch by David Chisnall.
Modified:
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=68043&r1=68042&r2=68043&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Mon Mar 30 13:02:14 2009
@@ -204,9 +204,12 @@
llvm::Value *ClassName = CGM.GetAddrOfConstantCString(OID->getNameAsString());
ClassName = Builder.CreateStructGEP(ClassName, 0);
+ std::vector<const llvm::Type*> Params(1, PtrToInt8Ty);
llvm::Constant *ClassLookupFn =
- TheModule.getOrInsertFunction("objc_lookup_class", IdTy, PtrToInt8Ty,
- NULL);
+ CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy,
+ Params,
+ true),
+ "objc_lookup_class");
return Builder.CreateCall(ClassLookupFn, ClassName);
}
@@ -304,11 +307,14 @@
CGF.Builder.CreateStore(ReceiverClass, CGF.Builder.CreateStructGEP(ObjCSuper, 1));
// Get the IMP
+ std::vector<const llvm::Type*> Params;
+ Params.push_back(llvm::PointerType::getUnqual(ObjCSuperTy));
+ Params.push_back(SelectorTy);
llvm::Constant *lookupFunction =
- TheModule.getOrInsertFunction("objc_msg_lookup_super",
- llvm::PointerType::getUnqual(impType),
- llvm::PointerType::getUnqual(ObjCSuperTy),
- SelectorTy, NULL);
+ CGM.CreateRuntimeFunction(llvm::FunctionType::get(
+ llvm::PointerType::getUnqual(impType), Params, true),
+ "objc_msg_lookup_super");
+
llvm::Value *lookupArgs[] = {ObjCSuper, cmd};
llvm::Value *imp = CGF.Builder.CreateCall(lookupFunction, lookupArgs,
lookupArgs+2);
@@ -338,10 +344,14 @@
const CGFunctionInfo &FnInfo = Types.getFunctionInfo(ResultType, ActualArgs);
const llvm::FunctionType *impType = Types.GetFunctionType(FnInfo, false);
+ std::vector<const llvm::Type*> Params;
+ Params.push_back(Receiver->getType());
+ Params.push_back(SelectorTy);
llvm::Constant *lookupFunction =
- TheModule.getOrInsertFunction("objc_msg_lookup",
- llvm::PointerType::getUnqual(impType),
- Receiver->getType(), SelectorTy, NULL);
+ CGM.CreateRuntimeFunction(llvm::FunctionType::get(
+ llvm::PointerType::getUnqual(impType), Params, true),
+ "objc_msg_lookup");
+
llvm::Value *imp = CGF.Builder.CreateCall2(lookupFunction, Receiver, cmd);
return CGF.EmitCall(FnInfo, imp, ActualArgs);
@@ -939,8 +949,11 @@
llvm::BasicBlock *EntryBB = llvm::BasicBlock::Create("entry", LoadFunction);
CGBuilderTy Builder;
Builder.SetInsertPoint(EntryBB);
- llvm::Value *Register = TheModule.getOrInsertFunction("__objc_exec_class",
- llvm::Type::VoidTy, llvm::PointerType::getUnqual(ModuleTy), NULL);
+
+ std::vector<const llvm::Type*> Params(1,
+ llvm::PointerType::getUnqual(ModuleTy));
+ llvm::Value *Register = CGM.CreateRuntimeFunction(llvm::FunctionType::get(
+ llvm::Type::VoidTy, Params, true), "__objc_exec_class");
Builder.CreateCall(Register, Module);
Builder.CreateRetVoid();
return LoadFunction;
@@ -977,9 +990,10 @@
}
llvm::Function *CGObjCGNU::EnumerationMutationFunction() {
-return
- (llvm::Function*)TheModule.getOrInsertFunction(
- "objc_enumerationMutation", llvm::Type::VoidTy, IdTy, NULL);
+ std::vector<const llvm::Type*> Params(1, IdTy);
+ return cast<llvm::Function>(CGM.CreateRuntimeFunction(
+ llvm::FunctionType::get(llvm::Type::VoidTy, Params, true),
+ "objc_enumerationMutation"));
}
void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
More information about the cfe-commits
mailing list