[cfe-commits] r69762 - /cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Chris Lattner
sabre at nondot.org
Tue Apr 21 19:15:24 PDT 2009
Author: lattner
Date: Tue Apr 21 21:15:23 2009
New Revision: 69762
URL: http://llvm.org/viewvc/llvm-project?rev=69762&view=rev
Log:
make try/catch objc runtime functions be lazily generated.
rdar://6809612
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=69762&r1=69761&r2=69762&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Apr 21 21:15:23 2009
@@ -317,7 +317,29 @@
return llvm::ConstantExpr::getBitCast(Personality, Int8PtrTy);
}
- llvm::Constant *UnwindResumeOrRethrowFn, *ObjCBeginCatchFn, *ObjCEndCatchFn;
+ llvm::Constant *getUnwindResumeOrRethrowFn() {
+ std::vector<const llvm::Type*> Params;
+ Params.push_back(Int8PtrTy);
+ return CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::VoidTy,
+ Params, false),
+ "_Unwind_Resume_or_Rethrow");
+ }
+
+ llvm::Constant *getObjCEndCatchFn() {
+ std::vector<const llvm::Type*> Params;
+ return CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::VoidTy,
+ Params, false),
+ "objc_end_catch");
+
+ }
+
+ llvm::Constant *getObjCBeginCatchFn() {
+ std::vector<const llvm::Type*> Params;
+ Params.push_back(Int8PtrTy);
+ return CGM.CreateRuntimeFunction(llvm::FunctionType::get(Int8PtrTy,
+ Params, false),
+ "objc_begin_catch");
+ }
const llvm::StructType *EHTypeTy;
const llvm::Type *EHTypePtrTy;
@@ -3915,24 +3937,6 @@
"objc_msgSendSuper2_stret_fixup");
Params.clear();
- Params.push_back(Int8PtrTy);
- UnwindResumeOrRethrowFn =
- CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::VoidTy,
- Params,
- false),
- "_Unwind_Resume_or_Rethrow");
- ObjCBeginCatchFn =
- CGM.CreateRuntimeFunction(llvm::FunctionType::get(Int8PtrTy,
- Params,
- false),
- "objc_begin_catch");
-
- Params.clear();
- ObjCEndCatchFn =
- CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::VoidTy,
- Params,
- false),
- "objc_end_catch");
// struct objc_typeinfo {
// const void** vtable; // objc_ehtype_vtable + 2
@@ -5469,7 +5473,7 @@
CGF.setInvokeDest(MatchHandler);
llvm::Value *ExcObject =
- CGF.Builder.CreateCall(ObjCTypes.ObjCBeginCatchFn, Exc);
+ CGF.Builder.CreateCall(ObjCTypes.getObjCBeginCatchFn(), Exc);
// Bind the catch parameter if it exists.
if (CatchParam) {
@@ -5512,7 +5516,7 @@
llvm::BasicBlock *MatchEndHandler =
CGF.createBasicBlock("match.end.handler");
llvm::BasicBlock *Cont = CGF.createBasicBlock("invoke.cont");
- CGF.Builder.CreateInvoke(ObjCTypes.ObjCEndCatchFn,
+ CGF.Builder.CreateInvoke(ObjCTypes.getObjCEndCatchFn(),
Cont, MatchEndHandler,
Args.begin(), Args.begin());
@@ -5571,7 +5575,7 @@
CGF.EmitBranch(FinallyEnd);
CGF.EmitBlock(FinallyRethrow);
- CGF.Builder.CreateCall(ObjCTypes.UnwindResumeOrRethrowFn,
+ CGF.Builder.CreateCall(ObjCTypes.getUnwindResumeOrRethrowFn(),
CGF.Builder.CreateLoad(RethrowPtr));
CGF.Builder.CreateUnreachable();
More information about the cfe-commits
mailing list