This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [csl-arm] Use __cxa_end_cleanup


On Wednesday 29 September 2004 05:36, Mark Mitchell wrote:
> Paul Brook wrote:
>
> Can these two functions:

> >+default_init_unwind_resume_libfunc (void)
...
> >+const char *
> >+default_cxx_unwind_resume_name (void)

> use one-another?  Like, could the former call the latter?

> >+arm_cxx_unwind_resume_name (void)
...

> And this one could do:
>
> #ifdef TARGET_UNWIND_INFO
>   if (!USING_SJLJ_EXCEPTIONS)
>      return "__cxa_end_cleanup";
> #endif
>    return default_cxx_unwind_resume_name ();
>
> (I'm looking for ways to avoid spreading these magic identifiers around.)
>
> Other than that, this looks OK to me.  If the ideas above don't work or
> don't make sense, go with the version you have.

Changed as you suggested, retested and and applied to csl-arm-branch.

Paul

2004-09-29  Paul Brook  <paul@codesourcery.com>

 * c-decl.c (finish_decl): Call default_init_unwind_resume_libfunc.
 * except.c (default_init_unwind_resume_libfunc): New function.
 * except.h (default_init_unwind_resume_libfunc): Add prototype.
 * optabs.c (init_optabs): Don't set unwind_resume_libfunc.
 * target-def.h (TARGET_CXX_UNWIND_RESUME_NAME): Define.
 (TARGET_CXX): Use it.
 * target.h (struct gcc_target): Add cxx.unwind_resume_name.
 * targhooks.c (default_unwind_resume_name): New function.
 * targhooks.h (default_unwind_resume_name): Add prototype.
 * config/arm/arm.h (arm_cxx_unwind_resume_name): New function.
 (TARGET_CXX_UNWIND_RESUME_NAME): Define.
 * doc/tm.texi: Document TARGET_CXX_UNWIND_RESUME_NAME.
cp/
 * except.c (init_exception_processing): Set unwind_resume_libfunc.
ada/
 * misc.c (gnat_init_gcc_eh): Call default_init_unwind_resume_libfunc.
java/
 * decl.c (java_init_decl_processing): Call
 default_init_unwind_resume_libfunc.
libstdc++/
 * acinclude.m4: Check for __cxa_end_cleanup.
 * aclocal.m4: Regenerate.
 * configure: Regenerate.
 * libsupc++/eh_arm.cc: Only compile for arm EABI targets.
 (__cxa_end_cleanup): Declare ((naked)) to avoid messing with the
 stack.

Index: gcc/c-decl.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/c-decl.c,v
retrieving revision 1.455.4.6
diff -u -p -r1.455.4.6 c-decl.c
--- gcc/c-decl.c 17 Aug 2004 19:39:07 -0000 1.455.4.6
+++ gcc/c-decl.c 28 Sep 2004 13:37:45 -0000
@@ -2944,6 +2944,7 @@ finish_decl (tree decl, tree init, tree 
   = init_one_libfunc (USING_SJLJ_EXCEPTIONS
         ? "__gcc_personality_sj0"
         : "__gcc_personality_v0");
+       default_init_unwind_resume_libfunc ();
        using_eh_for_cleanups ();
      }
 
Index: gcc/except.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/except.c,v
retrieving revision 1.253.4.5
diff -u -p -r1.253.4.5 except.c
--- gcc/except.c 22 Sep 2004 15:40:26 -0000 1.253.4.5
+++ gcc/except.c 29 Sep 2004 14:06:41 -0000
@@ -3852,4 +3852,13 @@ output_function_exception_table (void)
   function_section (current_function_decl);
 }
 
+
+/* Initialize unwind_resume_libfunc.  */
+
+void
+default_init_unwind_resume_libfunc (void)
+{
+  /* The default c++ routines aren't actually c++ specific, so use those.  */
+  unwind_resume_libfunc = init_one_libfunc (default_unwind_resume_name ());
+}
 #include "gt-except.h"
Index: gcc/except.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/except.h,v
retrieving revision 1.72.4.2
diff -u -p -r1.72.4.2 except.h
--- gcc/except.h 15 Jul 2004 01:49:00 -0000 1.72.4.2
+++ gcc/except.h 28 Sep 2004 13:37:45 -0000
@@ -122,6 +122,7 @@ extern rtx get_exception_pointer (struct
 extern int duplicate_eh_regions (struct function *, struct inline_remap *);
 
 extern void sjlj_emit_function_exit_after (rtx);
+extern void default_init_unwind_resume_libfunc (void);
 
 
 /* If non-NULL, this is a function that returns an expression to be
Index: gcc/optabs.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/optabs.c,v
retrieving revision 1.202.2.4
diff -u -p -r1.202.2.4 optabs.c
--- gcc/optabs.c 19 Aug 2004 22:04:31 -0000 1.202.2.4
+++ gcc/optabs.c 28 Sep 2004 13:37:45 -0000
@@ -5467,9 +5467,6 @@ init_optabs (void)
   bzero_libfunc = init_one_libfunc ("bzero");
   setbits_libfunc = init_one_libfunc ("__setbits");
 
-  unwind_resume_libfunc = init_one_libfunc (USING_SJLJ_EXCEPTIONS
-         ? "_Unwind_SjLj_Resume"
-         : "_Unwind_Resume");
 #ifndef DONT_USE_BUILTIN_SETJMP
   setjmp_libfunc = init_one_libfunc ("__builtin_setjmp");
   longjmp_libfunc = init_one_libfunc ("__builtin_longjmp");
Index: gcc/target-def.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/target-def.h,v
retrieving revision 1.59.2.11
diff -u -p -r1.59.2.11 target-def.h
--- gcc/target-def.h 22 Sep 2004 15:40:27 -0000 1.59.2.11
+++ gcc/target-def.h 29 Sep 2004 14:07:10 -0000
@@ -397,6 +397,10 @@ Foundation, 59 Temple Place - Suite 330,
 #define TARGET_CXX_EXPORT_CLASS_DATA hook_bool_void_false
 #endif
 
+#ifndef TARGET_CXX_UNWIND_RESUME_NAME
+#define TARGET_CXX_UNWIND_RESUME_NAME default_unwind_resume_name
+#endif
+
 #define TARGET_CXX    \
   {      \
     TARGET_CXX_GUARD_TYPE,   \
@@ -405,7 +409,8 @@ Foundation, 59 Temple Place - Suite 330,
     TARGET_CXX_COOKIE_HAS_SIZE,   \
     TARGET_CXX_CDTOR_RETURNS_THIS,  \
     TARGET_CXX_KEY_METHOD_MAY_BE_INLINE, \
-    TARGET_CXX_EXPORT_CLASS_DATA   \
+    TARGET_CXX_EXPORT_CLASS_DATA,   \
+    TARGET_CXX_UNWIND_RESUME_NAME  \
   }
 
 /* The whole shebang.  */
Index: gcc/target.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/target.h,v
retrieving revision 1.67.2.13
diff -u -p -r1.67.2.13 target.h
--- gcc/target.h 22 Sep 2004 15:40:27 -0000 1.67.2.13
+++ gcc/target.h 28 Sep 2004 13:37:45 -0000
@@ -469,6 +469,9 @@ struct gcc_target
        etc.) should be exported from the current DLL, even when the
        associated class is not exported.  */
     bool (*export_class_data) (void);
+    /* Return the name of the function used to exit from a c++ cleanup
+       handler.  */
+    const char * (*unwind_resume_name) (void);
   } cxx;
 
   /* Leave the boolean fields at the end.  */
Index: gcc/targhooks.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/targhooks.c,v
retrieving revision 2.8.6.5
diff -u -p -r2.8.6.5 targhooks.c
--- gcc/targhooks.c 15 Jul 2004 01:49:02 -0000 2.8.6.5
+++ gcc/targhooks.c 29 Sep 2004 14:05:58 -0000
@@ -61,6 +61,7 @@ Software Foundation, 59 Temple Place - S
 #include "target.h"
 #include "tm_p.h"
 #include "target-def.h"
+#include "except.h"
 
 void
 default_external_libcall (rtx fun ATTRIBUTE_UNUSED)
@@ -246,6 +247,16 @@ default_cxx_get_cookie_size (tree type)
 }
 
 
+/* Return the name of the function used to exit from a cleanup handler.  */
+
+const char *
+default_unwind_resume_name (void)
+{
+  return USING_SJLJ_EXCEPTIONS ? "_Unwind_SjLj_Resume"
+          : "_Unwind_Resume";
+}
+
+
 /* Emit any directives required to unwind this instruction.  */
 
 void
Index: gcc/targhooks.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/targhooks.h,v
retrieving revision 2.3.6.5
diff -u -p -r2.3.6.5 targhooks.h
--- gcc/targhooks.h 15 Jul 2004 01:49:03 -0000 2.3.6.5
+++ gcc/targhooks.h 29 Sep 2004 14:06:15 -0000
@@ -39,5 +39,6 @@ extern bool hook_bool_CUMULATIVE_ARGS_tr
 extern bool hook_bool_machine_mode_true (enum machine_mode);
 extern tree default_cxx_guard_type (void);
 extern tree default_cxx_get_cookie_size (tree);
+extern const char * default_unwind_resume_name (void);
 
 extern void default_unwind_emit (FILE *, rtx);
Index: gcc/ada/misc.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/ada/misc.c,v
retrieving revision 1.66.4.3
diff -u -p -r1.66.4.3 misc.c
--- gcc/ada/misc.c 9 Apr 2004 13:40:16 -0000 1.66.4.3
+++ gcc/ada/misc.c 28 Sep 2004 13:37:45 -0000
@@ -436,6 +436,7 @@ gnat_init_gcc_eh (void)
   using_eh_for_cleanups ();
 
   eh_personality_libfunc = init_one_libfunc ("__gnat_eh_personality");
+  default_init_unwind_resume_libfunc ();
   lang_eh_type_covers = gnat_eh_type_covers;
   lang_eh_runtime_type = gnat_eh_runtime_type;
 
Index: gcc/config/arm/arm.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.303.2.55
diff -u -p -r1.303.2.55 arm.c
--- gcc/config/arm/arm.c 27 Sep 2004 17:15:13 -0000 1.303.2.55
+++ gcc/config/arm/arm.c 29 Sep 2004 14:17:47 -0000
@@ -171,6 +171,7 @@ static bool arm_cookie_has_size (void);
 static bool arm_cxx_cdtor_returns_this (void);
 static bool arm_cxx_key_method_may_be_inline (void);
 static bool arm_cxx_export_class_data (void);
+static const char * arm_cxx_unwind_resume_name (void);
 static void arm_init_libfuncs (void);
 
 
@@ -290,6 +291,9 @@ static void arm_init_libfuncs (void);
 #undef TARGET_CXX_EXPORT_CLASS_DATA
 #define TARGET_CXX_EXPORT_CLASS_DATA arm_cxx_export_class_data
 
+#undef TARGET_CXX_UNWIND_RESUME_NAME
+#define TARGET_CXX_UNWIND_RESUME_NAME arm_cxx_unwind_resume_name
+
 #ifdef TARGET_UNWIND_INFO
 /* EABI unwinding tables use a different format to teh typeinfo tables.  */
 #undef TARGET_UNWIND_EMIT
@@ -14983,3 +14987,17 @@ arm_output_fn_unwind (FILE * f, bool pro
   else
     fputs ("\t.fnend\n", f);
 }
+
+
+/* Return the name of the unwind library resume routine.  */
+
+static const char *
+arm_cxx_unwind_resume_name (void)
+{
+#ifdef TARGET_UNWIND_INFO
+  /* The EABI says use this routine, not _Unwind_Resume.  */
+  if (!USING_SJLJ_EXCEPTIONS)
+    return "__cxa_end_cleanup";
+#endif
+  return default_unwind_resume_name ();
+}
Index: gcc/cp/except.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/cp/except.c,v
retrieving revision 1.160.4.4
diff -u -p -r1.160.4.4 except.c
--- gcc/cp/except.c 16 Aug 2004 17:14:13 -0000 1.160.4.4
+++ gcc/cp/except.c 28 Sep 2004 13:37:45 -0000
@@ -37,6 +37,7 @@ Boston, MA 02111-1307, USA.  */
 #include "except.h"
 #include "toplev.h"
 #include "tree-inline.h"
+#include "target.h"
 
 static void push_eh_cleanup (tree);
 static tree prepare_eh_type (tree);
@@ -79,6 +80,8 @@ init_exception_processing (void)
   eh_personality_libfunc = init_one_libfunc (USING_SJLJ_EXCEPTIONS
           ? "__gxx_personality_sj0"
           : "__gxx_personality_v0");
+  unwind_resume_libfunc =
+    init_one_libfunc (targetm.cxx.unwind_resume_name ());
 
   lang_eh_runtime_type = build_eh_type_type;
   lang_protect_cleanup_actions = &cp_protect_cleanup_actions;
Index: gcc/doc/tm.texi
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/doc/tm.texi,v
retrieving revision 1.264.2.18
diff -u -p -r1.264.2.18 tm.texi
--- gcc/doc/tm.texi 22 Sep 2004 15:40:31 -0000 1.264.2.18
+++ gcc/doc/tm.texi 28 Sep 2004 13:37:45 -0000
@@ -8583,6 +8583,11 @@ have ELF ``default'' visibility, indepen
 the containing class.
 @end deftypefn
 
+@deftypefn {Target Hook} const char * TARGET_CXX_UNWIND_RESUME_NAME (void)
+This hook returns the name of the routine that should be called to
+resume unwinding at the end of a C++ catch handler.
+@end deftypefn
+
 @node Misc
 @section Miscellaneous Parameters
 @cindex parameters, miscellaneous
Index: gcc/java/decl.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/java/decl.c,v
retrieving revision 1.169.2.2
diff -u -p -r1.169.2.2 decl.c
--- gcc/java/decl.c 3 Mar 2004 16:04:45 -0000 1.169.2.2
+++ gcc/java/decl.c 28 Sep 2004 13:37:45 -0000
@@ -905,6 +905,7 @@ java_init_decl_processing (void)
   eh_personality_libfunc = init_one_libfunc (USING_SJLJ_EXCEPTIONS
                                              ? "__gcj_personality_sj0"
                                              : "__gcj_personality_v0");
+  default_init_unwind_resume_libfunc ();
 
   lang_eh_runtime_type = do_nothing;
 
Index: libstdc++-v3/acinclude.m4
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libstdc++-v3/acinclude.m4,v
retrieving revision 1.275.2.7
diff -u -p -r1.275.2.7 acinclude.m4
--- libstdc++-v3/acinclude.m4 16 Aug 2004 23:52:33 -0000 1.275.2.7
+++ libstdc++-v3/acinclude.m4 28 Sep 2004 13:37:45 -0000
@@ -1544,6 +1544,8 @@ EOF
         enable_sjlj_exceptions=yes
       elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
         enable_sjlj_exceptions=no
+      elif grep __cxa_end_cleanup conftest.s >/dev/null 2>&1 ; then
+        enable_sjlj_exceptions=no
       fi
     fi
     CXXFLAGS="$old_CXXFLAGS"
Index: libstdc++-v3/aclocal.m4
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libstdc++-v3/aclocal.m4,v
retrieving revision 1.289.2.8
diff -u -p -r1.289.2.8 aclocal.m4
--- libstdc++-v3/aclocal.m4 16 Aug 2004 23:52:33 -0000 1.289.2.8
+++ libstdc++-v3/aclocal.m4 28 Sep 2004 13:37:45 -0000
@@ -1557,6 +1557,8 @@ EOF
         enable_sjlj_exceptions=yes
       elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
         enable_sjlj_exceptions=no
+      elif grep __cxa_end_cleanup conftest.s >/dev/null 2>&1 ; then
+        enable_sjlj_exceptions=no
       fi
     fi
     CXXFLAGS="$old_CXXFLAGS"
Index: libstdc++-v3/configure
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libstdc++-v3/configure,v
retrieving revision 1.364.2.8
diff -u -p -r1.364.2.8 configure
--- libstdc++-v3/configure 16 Aug 2004 23:52:34 -0000 1.364.2.8
+++ libstdc++-v3/configure 28 Sep 2004 13:37:45 -0000
@@ -5042,6 +5042,8 @@ EOF
         enable_sjlj_exceptions=yes
       elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
         enable_sjlj_exceptions=no
+      elif grep __cxa_end_cleanup conftest.s >/dev/null 2>&1 ; then
+        enable_sjlj_exceptions=no
       fi
     fi
     CXXFLAGS="$old_CXXFLAGS"
Index: libstdc++-v3/libsupc++/eh_arm.cc
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libstdc++-v3/libsupc++/Attic/eh_arm.cc,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 eh_arm.cc
--- libstdc++-v3/libsupc++/eh_arm.cc 22 Sep 2004 15:40:33 -0000 1.1.2.1
+++ libstdc++-v3/libsupc++/eh_arm.cc 28 Sep 2004 23:45:48 -0000
@@ -27,9 +27,10 @@
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
-
 #include "unwind-cxx.h"
 
+#ifdef __ARM_EABI_UNWINDER__
+
 using namespace __cxxabiv1;
 
 
@@ -71,11 +72,11 @@ __cxa_begin_cleanup(_Unwind_Exception* u
 {
 }
 
-extern "C" void
-__cxa_end_cleanup(_Unwind_Exception* ue_header)
+/* This needs to tailcall _Unwind_Resume without clobbering any registers,
+   or altering the stack.  */
+extern "C" void __attribute__((naked))
+__cxa_end_cleanup (_Unwind_Exception* ue_header)
 {
-  /* TODO: This should really be an assembly stub which doesn't corrupt any
-     registers.  */
-  _Unwind_Resume(ue_header);
+  _Unwind_Resume (ue_header);
 }
-
+#endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]