[cfe-commits] r103938 - /cfe/trunk/lib/CodeGen/CGException.cpp
Fariborz Jahanian
fjahanian at apple.com
Mon May 17 08:11:39 PDT 2010
On May 17, 2010, at 6:49 AM, David Chisnall wrote:
> Author: theraven
> Date: Mon May 17 08:49:20 2010
> New Revision: 103938
>
> URL: http://llvm.org/viewvc/llvm-project?rev=103938&view=rev
> Log:
> Pick the correct personality function based on the language. This
> prevents link failures when C/ObjC code uses __attribute__((cleanup
> ())) (previously this was inserting references to two libstc++
> symbols; the personality function and the __terminate() function).
>
> This is still probably wrong for Objective-C++ and adds a couple of
> lines in CGException that should probably be in the CGObjCRuntime
> subclass. The personality function is now only looked up in one
> place in CGException though, so this should be easier to fix in the
> future.
>
>
> Modified:
> cfe/trunk/lib/CodeGen/CGException.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGException.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=103938&r1=103937&r2=103938&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/CodeGen/CGException.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGException.cpp Mon May 17 08:49:20 2010
> @@ -119,7 +119,28 @@
> const llvm::FunctionType *FTy =
> llvm::FunctionType::get(llvm::Type::getVoidTy(CGF.getLLVMContext
> ()), false);
>
> - return CGF.CGM.CreateRuntimeFunction(FTy, "_ZSt9terminatev");
> + return CGF.CGM.CreateRuntimeFunction(FTy,
> + CGF.CGM.getLangOptions().CPlusPlus ? "_ZSt9terminatev" :
> "abort");
> +}
> +
> +static llvm::Constant *getPersonalityFn(CodeGenModule &CGM) {
> + const char *PersonalityFnName = "__gcc_personality_v0";
> + LangOptions Opts = CGM.getLangOptions();
> + if (Opts.CPlusPlus)
> + PersonalityFnName = "__gxx_personality_v0";
> + else if (Opts.ObjC1)
> + if (Opts.NeXTRuntime) {
> + if (Opts.ObjCNonFragileABI)
> + PersonalityFnName = "__gcc_personality_v0";
All can say:
if (!Opts.NeXTRuntime)
PersonalityFnName = "__gnu_objc_personality_v0";
- Fariborz
> + } else
> + PersonalityFnName = "__gnu_objc_personality_v0";
> +
> + llvm::Constant *Personality =
> + CGM.CreateRuntimeFunction(llvm::FunctionType::get
> (llvm::Type::getInt32Ty(
> +
> CGM.getLLVMContext()),
> + true),
> + PersonalityFnName);
> + return llvm::ConstantExpr::getBitCast(Personality,
> CGM.PtrToInt8Ty);
> }
>
> // Emits an exception expression into the given location. This
> @@ -324,12 +345,7 @@
> if (!Proto->hasExceptionSpec())
> return;
>
> - llvm::Constant *Personality =
> - CGM.CreateRuntimeFunction(llvm::FunctionType::get
> (llvm::Type::getInt32Ty
> - (VMContext),
> - true),
> - "__gxx_personality_v0");
> - Personality = llvm::ConstantExpr::getBitCast(Personality,
> PtrToInt8Ty);
> + llvm::Constant *Personality = getPersonalityFn(CGM);
> llvm::Value *llvm_eh_exception =
> CGM.getIntrinsic(llvm::Intrinsic::eh_exception);
> llvm::Value *llvm_eh_selector =
> @@ -444,12 +460,7 @@
> void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S,
> CXXTryStmtInfo TryInfo) {
> // Pointer to the personality function
> - llvm::Constant *Personality =
> - CGM.CreateRuntimeFunction(llvm::FunctionType::get
> (llvm::Type::getInt32Ty
> - (VMContext),
> - true),
> - "__gxx_personality_v0");
> - Personality = llvm::ConstantExpr::getBitCast(Personality,
> PtrToInt8Ty);
> + llvm::Constant *Personality = getPersonalityFn(CGM);
> llvm::Value *llvm_eh_exception =
> CGM.getIntrinsic(llvm::Intrinsic::eh_exception);
> llvm::Value *llvm_eh_selector =
> @@ -654,12 +665,7 @@
>
> // The libstdc++ personality function.
> // TODO: generalize to work with other libraries.
> - llvm::Constant *Personality =
> - CGF.CGM.CreateRuntimeFunction(llvm::FunctionType::get
> (llvm::Type::getInt32Ty
> -
> (CGF.VMContext),
> - true),
> - "__gxx_personality_v0");
> - Personality = llvm::ConstantExpr::getBitCast(Personality,
> CGF.PtrToInt8Ty);
> + llvm::Constant *Personality = getPersonalityFn(CGF.CGM);
>
> // %exception = call i8* @llvm.eh.exception()
> // Magic intrinsic which tells gives us a handle to the caught
> @@ -715,12 +721,7 @@
> llvm::BasicBlock::iterator SavedInsertPoint =
> Builder.GetInsertPoint();
> Builder.ClearInsertionPoint();
>
> - llvm::Constant *Personality =
> - CGM.CreateRuntimeFunction(llvm::FunctionType::get
> (llvm::Type::getInt32Ty
> - (VMContext),
> - true),
> - "__gxx_personality_v0");
> - Personality = llvm::ConstantExpr::getBitCast(Personality,
> PtrToInt8Ty);
> + llvm::Constant *Personality = getPersonalityFn(CGM);
> llvm::Value *llvm_eh_exception =
> CGM.getIntrinsic(llvm::Intrinsic::eh_exception);
> llvm::Value *llvm_eh_selector =
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list