A function that only has cleanups (destructors) to run when an exception is raised currently is not assigned a personality function because we don't bother creating a call to eh.selector if there are no catches. But the personality function is still needed, since it is the personality function that analyses the exception table and decides where to jump to (to the cleanups in this case). This patch causes a call to eh.selector to be generated in every landing pad, even if it has no type infos, because that specifies the personality function.
Ciao, Duncan.
Index: gcc.llvm/gcc/llvm-convert.cpp =================================================================== --- gcc.llvm.orig/gcc/llvm-convert.cpp 2007-07-10 16:01:50.000000000 +0200 +++ gcc.llvm/gcc/llvm-convert.cpp 2007-07-10 16:05:06.000000000 +0200 @@ -2017,6 +2017,11 @@ // Fetch and store the exception selector. std::vector<Value*> Args; + // The exception and the personality function. + Args.push_back(Builder.CreateLoad(ExceptionValue, "eh_ptr")); + Args.push_back(CastToType(Instruction::BitCast, FuncCPPPersonality, + PointerType::get(Type::Int8Ty))); + for (std::vector<EHScope>::reverse_iterator I = CurrentEHScopes.rbegin(), E = CurrentEHScopes.rend(); I != E; ++I) { if (TREE_CODE(I->TryExpr) == TRY_CATCH_EXPR) { @@ -2030,16 +2035,6 @@ EH_FILTER_EXPR) ? FilterExpr : CatchList; } - if (I->InfosType == CatchList && !I->TypeInfos.size()) - continue; - - // Lazily add the exception and the personality function. - if (!Args.size()) { - Args.push_back(Builder.CreateLoad(ExceptionValue, "eh_ptr")); - Args.push_back(CastToType(Instruction::BitCast, FuncCPPPersonality, - PointerType::get(Type::Int8Ty))); - } - if (I->InfosType == FilterExpr) // Filter - note the size. Args.push_back(ConstantInt::get(Type::Int32Ty, I->TypeInfos.size())); @@ -2050,11 +2045,9 @@ } } - if (Args.size()) { - Value *Select = Builder.CreateCall(FuncEHSelector, &Args[0], Args.size(), - "eh_select"); - Builder.CreateStore(Select, ExceptionSelectorValue); - } + Value *Select = Builder.CreateCall(FuncEHSelector, &Args[0], Args.size(), + "eh_select"); + Builder.CreateStore(Select, ExceptionSelectorValue); }
_______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits