Finally and truly remove exception handling code. llvm-svn: 82695
diff --git a/llvm-gcc-4.2/gcc/except.c b/llvm-gcc-4.2/gcc/except.c index fa97fe7..af7c05c 100644 --- a/llvm-gcc-4.2/gcc/except.c +++ b/llvm-gcc-4.2/gcc/except.c
@@ -4085,7 +4085,11 @@ and even requires additional instructions on some targets. */ const char *name = USING_SJLJ_EXCEPTIONS ? "_Unwind_SjLj_Resume" +#ifdef LLVM_STACKSENSITIVE_UNWIND_RESUME + : "_Unwind_Resume_or_Rethrow"; +#else : "_Unwind_Resume"; +#endif tree decl = build_decl (FUNCTION_DECL, get_identifier (name), build_function_type_list (void_type_node, ptr_type_node, NULL_TREE));
diff --git a/llvm-gcc-4.2/gcc/llvm-backend.cpp b/llvm-gcc-4.2/gcc/llvm-backend.cpp index 210db32..1c12e20 100644 --- a/llvm-gcc-4.2/gcc/llvm-backend.cpp +++ b/llvm-gcc-4.2/gcc/llvm-backend.cpp
@@ -1386,7 +1386,7 @@ #endif } - // No debug info for globals when optimization is on. While this is + // No debug info for globals when optimization is on. While this is // something that would be accurate and useful to a user, it currently // affects some optimizations that, e.g., count uses. if (TheDebugInfo && !optimize) {
diff --git a/llvm-gcc-4.2/gcc/llvm-convert.cpp b/llvm-gcc-4.2/gcc/llvm-convert.cpp index 611efa8..d06a27c 100644 --- a/llvm-gcc-4.2/gcc/llvm-convert.cpp +++ b/llvm-gcc-4.2/gcc/llvm-convert.cpp
@@ -1905,12 +1905,32 @@ Args.push_back(Emit(TType, 0)); } } - } else { - // Cleanup region. - Args.push_back(ConstantInt::get(Type::Int32Ty, 0)); } } + 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. + + // 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::getUnqual(Type::Int8Ty)); + else + // This language has a type that catches all others. + Catch_All = Emit(catch_all_type, 0); + } + Args.push_back(Catch_All); + } + // Emit the selector call. Value *Select = Builder.CreateCall(FuncEHSelector, Args.begin(), Args.end(), "eh_select"); @@ -2043,7 +2063,11 @@ if (UnwindBB) { CreateExceptionValues(); EmitBlock(UnwindBB); - Builder.CreateUnwind(); + // Fetch and store exception handler. + Value *Arg = Builder.CreateLoad(ExceptionValue, "eh_ptr"); + assert(llvm_unwind_resume_libfunc && "no unwind resume function!"); + Builder.CreateCall(DECL_LLVM(llvm_unwind_resume_libfunc), Arg); + Builder.CreateUnreachable(); } }