Author: baldrick Date: Mon Aug 27 11:11:09 2007 New Revision: 41487 URL: http://llvm.org/viewvc/llvm-project?rev=41487&view=rev Log: Filters are now specified using the number of type infos plus one. If an eh.selector call isn't guaranteed to match, append a catch-all. Also, some trivial cleanups.
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-internal.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=41487&r1=41486&r2=41487&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Aug 27 11:11:09 2007 @@ -1757,18 +1757,6 @@ } -/// getLandingPad - Return the landing pad for the given exception handling -/// region, creating it if necessary. -BasicBlock *TreeToLLVM::getLandingPad(unsigned RegionNo) { - LandingPads.grow(RegionNo); - BasicBlock *&LandingPad = LandingPads[RegionNo]; - - if (!LandingPad) - LandingPad = new BasicBlock("lpad"); - - return LandingPad; -} - /// getPostPad - Return the post landing pad for the given exception handling /// region, creating it if necessary. BasicBlock *TreeToLLVM::getPostPad(unsigned RegionNo) { @@ -1829,7 +1817,7 @@ tree TypeList = get_eh_type_list(region); unsigned Length = list_length(TypeList); Args.reserve(Args.size() + Length + 1); - Args.push_back(ConstantInt::get(Type::Int32Ty, Length)); + Args.push_back(ConstantInt::get(Type::Int32Ty, Length + 1)); // Add the type infos. for (; TypeList; TypeList = TREE_CHAIN(TypeList)) { @@ -1855,6 +1843,13 @@ } } + if (can_throw_external_1(i, false)) + // Some exceptions from this region may not be caught by any handler. + // Since invokes are required to branch to the unwind label no matter + // what exception is being unwound, append a catch-all. + // FIXME: The use of null as catch-all is C++ specific. + Args.push_back(Constant::getNullValue(PointerType::get(Type::Int8Ty))); + // Emit the selector call. Value *Select = Builder.CreateCall(FuncEHSelector, Args.begin(), Args.end(), "eh_select"); @@ -2250,12 +2245,23 @@ if (!NoUnwind) { int RegionNo = lookup_stmt_eh_region(exp); + // Is the call contained in an exception handling region? if (RegionNo > 0) { - if (can_throw_internal_1(RegionNo, false)) + // Are there any exception handlers for this region? + if (can_throw_internal_1(RegionNo, false)) { // Turn the call into an invoke. - LandingPad = getLandingPad(RegionNo); - else + LandingPads.grow(RegionNo); + BasicBlock *&ThisPad = LandingPads[RegionNo]; + + // Create a landing pad if one didn't exist already. + if (!ThisPad) + ThisPad = new BasicBlock("lpad"); + + LandingPad = ThisPad; + } else { + // Can this call unwind out of the current function? NoUnwind = !can_throw_external_1(RegionNo, false); + } } } } Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=41487&r1=41486&r2=41487&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Mon Aug 27 11:11:09 2007 @@ -242,8 +242,6 @@ bool isBitfield() const { return BitStart != 255; } }; -typedef IndexedMap<BasicBlock *> RegionMapType; - /// TreeToLLVM - An instance of this class is created and used to convert the /// body of each function to LLVM. /// @@ -268,10 +266,10 @@ //===---------------------- Exception Handling --------------------------===// /// LandingPads - The landing pad for a given EH region. - RegionMapType LandingPads; + IndexedMap<BasicBlock *> LandingPads; /// PostPads - The post landing pad for a given EH region. - RegionMapType PostPads; + IndexedMap<BasicBlock *> PostPads; /// ExceptionValue - Is the local to receive the current exception. Value *ExceptionValue; @@ -421,10 +419,6 @@ /// handling. void CreateExceptionValues(); - /// getLandingPad - Return the landing pad for the given exception handling - /// region, creating it if necessary. - BasicBlock *getLandingPad(unsigned RegionNo); - /// getPostPad - Return the post landing pad for the given exception handling /// region, creating it if necessary. BasicBlock *getPostPad(unsigned RegionNo); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits