Author: baldrick Date: Wed Aug 29 09:34:36 2007 New Revision: 41563 URL: http://llvm.org/viewvc/llvm-project?rev=41563&view=rev Log: Let languages specify how to add a catch-all to the end of an eh_selector call.
Modified: llvm-gcc-4.2/trunk/gcc/cp/except.c llvm-gcc-4.2/trunk/gcc/except.c llvm-gcc-4.2/trunk/gcc/except.h llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/cp/except.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/except.c?rev=41563&r1=41562&r2=41563&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/cp/except.c (original) +++ llvm-gcc-4.2/trunk/gcc/cp/except.c Wed Aug 29 09:34:36 2007 @@ -56,6 +56,16 @@ static int can_convert_eh (tree, tree); static tree cp_protect_cleanup_actions (void); +/* LLVM local begin */ +/* Do nothing (return NULL_TREE). */ + +tree +return_null_tree (void) +{ + return NULL_TREE; +} +/* LLVM local end */ + /* Sets up all the global eh stuff that needs to be initialized at the start of compilation. */ @@ -92,6 +102,8 @@ lang_eh_runtime_type = build_eh_type_type; lang_protect_cleanup_actions = &cp_protect_cleanup_actions; + /* LLVM local */ + lang_eh_catch_all = return_null_tree; } /* Returns an expression to be executed if an unhandled exception is Modified: llvm-gcc-4.2/trunk/gcc/except.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/except.c?rev=41563&r1=41562&r2=41563&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/except.c (original) +++ llvm-gcc-4.2/trunk/gcc/except.c Wed Aug 29 09:34:36 2007 @@ -95,6 +95,11 @@ /* Map a type to a runtime object to match type. */ tree (*lang_eh_runtime_type) (tree); +/* LLVM local begin */ +/* Return a type that catches all others */ +tree (*lang_eh_catch_all) (void); +/* LLVM local end */ + /* A hash table of label to region number. */ struct ehl_map_entry GTY(()) Modified: llvm-gcc-4.2/trunk/gcc/except.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/except.h?rev=41563&r1=41562&r2=41563&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/except.h (original) +++ llvm-gcc-4.2/trunk/gcc/except.h Wed Aug 29 09:34:36 2007 @@ -139,6 +139,13 @@ /* Map a type to a runtime object to match type. */ extern tree (*lang_eh_runtime_type) (tree); +/* LLVM local begin */ +/* If non-NULL, this function returns a type that covers all others, + a "catch-all" type. It may also return NULL_TREE, indicating that + the null runtime object catches all types, as in C++. */ +extern tree (*lang_eh_catch_all) (void); +/* LLVM local end */ + /* Just because the user configured --with-sjlj-exceptions=no doesn't mean that we can use call frame exceptions. Detect that the target 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=41563&r1=41562&r2=41563&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Aug 29 09:34:36 2007 @@ -1840,12 +1840,27 @@ } } - if (can_throw_external_1(i, false)) + 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))); + + // The representation of a catch-all is language specific. + Value *Catch_All; + if (!lang_eh_catch_all) { + // Use a "cleanup" - this should be good enough for most languages. + Catch_All = ConstantInt::get(Type::Int32Ty, 0); + } else { + tree catch_all_type = lang_eh_catch_all(); + if (catch_all_type == NULL_TREE) + // Use a C++ style null catch-all object. + Catch_All = Constant::getNullValue(PointerType::get(Type::Int8Ty)); + else + // This language has a type that catches all others. + Catch_All = Emit(lookup_type_for_runtime(catch_all_type), 0); + } + Args.push_back(Catch_All); + } // Emit the selector call. Value *Select = Builder.CreateCall(FuncEHSelector, Args.begin(), Args.end(), _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits