public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC] Centralize knowledge of eh personality routines
@ 2010-10-12 22:59 Richard Henderson
  2010-10-13  1:11 ` Jason Merrill
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Richard Henderson @ 2010-10-12 22:59 UTC (permalink / raw)
  To: GCC Patches; +Cc: rguenther, joseph, jason, java, ian, ebotcazou

[-- Attachment #1: Type: text/plain, Size: 558 bytes --]

The driver for this patch is SEH, which will add yet another function
name variant in each of these places in each front end.  While I could
adjust each language appropriately, it seems to me that it is a bit
cleaner to centralize this knowledge.

The next possibly objectionable point is including dwarf2.h in tree.h.
I went ahead and did this because in the past we had talked about using
the dwarf language enum in LTO.  I could see eliminating the hackish
language_string -> enum mapping that is done in dwarf2out.c as well.

Comments?  Objections?


r~

[-- Attachment #2: d-per-1 --]
[-- Type: text/plain, Size: 8447 bytes --]

gcc/
	* expr.c (build_personality_function): Take parameter LANG instead
	of parameter NAME.  Build the name based on a known lang-specific
	prefix and the unwind method in use.
	* tree.c (lhd_gcc_personality): Update call to
	build_personality_function.
	* tree.h: Include dwarf2.h.
	(build_personality_function): Update decl.
	* Makefile.in (TREE_H): Update deps.

gcc/ada/
	* gcc-interface/misc.c (gnat_eh_personality): Update call to
	build_personality_function.
gcc/cp/
	* cp-lang.c (cp_eh_personality): Update call to
	build_personality_function.
	* except.c (choose_personality_routine): Update function comment.
gcc/java/
	* lang.c (java_eh_personality): Update call to
	build_personality_function.
gcc/objc/
	* objc-act.c (objc_eh_personality): Update call to
	build_personality_function.
gcc/objcp/
	* objcp-lang.c (objcxx_eh_personality): Update call to
	build_personality_function.


diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index 7703e2e..3fea6a3 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -687,11 +687,7 @@ static tree
 gnat_eh_personality (void)
 {
   if (!gnat_eh_personality_decl)
-    gnat_eh_personality_decl
-      = build_personality_function (targetm.except_unwind_info () == UI_SJLJ
-				    ? "__gnat_eh_personality_sj"
-				    : "__gnat_eh_personality");
-
+    gnat_eh_personality_decl = build_personality_function (DW_LANG_Ada95);
   return gnat_eh_personality_decl;
 }
 
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index 0b70444..1126283 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -166,17 +166,10 @@ cp_eh_personality (void)
 {
   if (!cp_eh_personality_decl)
     {
-      const char *name;
+      enum dwarf_source_language lang;
 
-      name = (targetm.except_unwind_info () == UI_SJLJ
-	      ? (pragma_java_exceptions
-		 ? "__gcj_personality_sj0"
-		 : "__gxx_personality_sj0")
-	      : (pragma_java_exceptions
-		 ? "__gcj_personality_v0"
-		 : "__gxx_personality_v0"));
-
-      cp_eh_personality_decl = build_personality_function (name);
+      lang = (pragma_java_exceptions ? DW_LANG_Java : DW_LANG_C_plus_plus);
+      cp_eh_personality_decl = build_personality_function (lang);
     }
 
   return cp_eh_personality_decl;
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index 9d19aa9..b917664 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -295,9 +295,8 @@ decl_is_java_type (tree decl, int err)
 /* Select the personality routine to be used for exception handling,
    or issue an error if we need two different ones in the same
    translation unit.
-   ??? At present eh_personality_decl is set to
-   __gxx_personality_(sj|v)0 in init_exception_processing - should it
-   be done here instead?  */
+   ??? At present DECL_FUNCTION_PERSONALITY is set via
+   LANG_HOOKS_EH_PERSONALITY.  Should it be done here instead?  */
 void
 choose_personality_routine (enum languages lang)
 {
diff --git a/gcc/expr.c b/gcc/expr.c
index b0c160f..3093967 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -10255,13 +10255,63 @@ const_vector_from_tree (tree exp)
   return gen_rtx_CONST_VECTOR (mode, v);
 }
 
-
-/* Build a decl for a EH personality function named NAME. */
+/* Build a personality function given a language.  LANG is really an
+   enum dwarf_source_language.  */
 
 tree
-build_personality_function (const char *name)
+build_personality_function (enum dwarf_source_language lang)
 {
+  enum unwind_info_type ui = targetm.except_unwind_info ();
+  const char *prefix, *unwind, *version = "0";
   tree decl, type;
+  char *name;
+
+  switch (ui)
+    {
+    case UI_NONE:
+      return NULL;
+    case UI_SJLJ:
+      unwind = "_sj";
+      break;
+    case UI_DWARF2:
+    case UI_TARGET:
+      unwind = "_v";
+      break;
+    default:
+      gcc_unreachable ();
+    }
+
+  switch (lang)
+    {
+    case DW_LANG_Ada83:
+    case DW_LANG_Ada95:
+      prefix = "__gnat_eh_personality";
+      /* The GNAT folk did not follow the standard naming format.
+	 That can change if we ever have to increment the version.  */
+      if (ui == UI_DWARF2 || ui == UI_TARGET)
+	unwind = "";
+      version = "";
+      break;
+
+    case DW_LANG_C_plus_plus:
+      prefix = "__gxx_personality";
+      break;
+
+    case DW_LANG_Java:
+      prefix = "__gcj_personality";
+      break;
+
+    case DW_LANG_ObjC:
+      prefix = "__gnu_objc_personality";
+      break;
+
+    default:
+      /* All other languages use the minimal C personality.  */
+      prefix = "__gcc_personality";
+      break;
+    }
+
+  name = concat (prefix, unwind, version, NULL);
 
   type = build_function_type_list (integer_type_node, integer_type_node,
 				   long_long_unsigned_type_node,
@@ -10276,6 +10326,7 @@ build_personality_function (const char *name)
      are the flags assigned by targetm.encode_section_info.  */
   SET_SYMBOL_REF_DECL (XEXP (DECL_RTL (decl), 0), NULL);
 
+  free (name);
   return decl;
 }
 
diff --git a/gcc/java/lang.c b/gcc/java/lang.c
index fbe25ad..7b29ea3 100644
--- a/gcc/java/lang.c
+++ b/gcc/java/lang.c
@@ -911,11 +911,7 @@ static tree
 java_eh_personality (void)
 {
   if (!java_eh_personality_decl)
-    java_eh_personality_decl
-      = build_personality_function (targetm.except_unwind_info () == UI_SJLJ
-				    ? "__gcj_personality_sj0"
-				    : "__gcj_personality_v0");
-
+    java_eh_personality_decl = build_personality_function (DW_LANG_Java);
   return java_eh_personality_decl;
 }
 
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 3a13519..6e2a0fa 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -3693,13 +3693,8 @@ objc_eh_runtime_type (tree type)
 tree
 objc_eh_personality (void)
 {
-  if (!flag_objc_sjlj_exceptions
-      && !objc_eh_personality_decl)
-    objc_eh_personality_decl
-      = build_personality_function (targetm.except_unwind_info () == UI_SJLJ
-				    ? "__gnu_objc_personality_sj0"
-				    : "__gnu_objc_personality_v0");
-
+  if (!flag_objc_sjlj_exceptions && !objc_eh_personality_decl)
+    objc_eh_personality_decl = build_personality_function (DW_LANG_ObjC);
   return objc_eh_personality_decl;
 }
 #endif
diff --git a/gcc/objcp/objcp-lang.c b/gcc/objcp/objcp-lang.c
index fdb2976..1224c31 100644
--- a/gcc/objcp/objcp-lang.c
+++ b/gcc/objcp/objcp-lang.c
@@ -148,9 +148,7 @@ objcxx_eh_personality (void)
 {
   if (!objcp_eh_personality_decl)
     objcp_eh_personality_decl
-	= build_personality_function (targetm.except_unwind_info () == UI_SJLJ
-				      ? "__gxx_personality_sj0"
-				      : "__gxx_personality_v0");
+      = build_personality_function (DW_LANG_C_plus_plus);
 
   return objcp_eh_personality_decl;
 }
diff --git a/gcc/tree.c b/gcc/tree.c
index cf5881a..e02ad3e 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -10874,11 +10874,7 @@ tree
 lhd_gcc_personality (void)
 {
   if (!gcc_eh_personality_decl)
-    gcc_eh_personality_decl
-      = build_personality_function (targetm.except_unwind_info () == UI_SJLJ
-				    ? "__gcc_personality_sj0"
-				    : "__gcc_personality_v0");
-
+    gcc_eh_personality_decl = build_personality_function (DW_LANG_C);
   return gcc_eh_personality_decl;
 }
 
diff --git a/gcc/tree.h b/gcc/tree.h
index 8aedf1a..ef7f409 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "fixed-value.h"
 #include "alias.h"
 #include "flags.h"
+#include "dwarf2.h"		/* for enum dwarf_source_language */
 
 /* Codes of tree nodes */
 
@@ -5474,7 +5475,7 @@ extern unsigned HOST_WIDE_INT compute_builtin_object_size (tree, int);
 
 /* In expr.c.  */
 extern unsigned HOST_WIDE_INT highest_pow2_factor (const_tree);
-extern tree build_personality_function (const char *);
+extern tree build_personality_function (enum dwarf_source_language);
 
 /* In tree-inline.c.  */
 
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 8118c06..f1b6972 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -886,7 +886,7 @@ TREE_H = tree.h all-tree.def tree.def c-family/c-common.def \
 	$(lang_tree_files) $(MACHMODE_H) tree-check.h $(BUILTINS_DEF) \
 	$(INPUT_H) statistics.h $(VEC_H) treestruct.def $(HASHTAB_H) \
 	double-int.h alias.h $(SYMTAB_H) $(FLAGS_H) vecir.h \
-	$(REAL_H) $(FIXED_VALUE_H)
+	$(REAL_H) $(FIXED_VALUE_H) $(DWARF2_H)
 REGSET_H = regset.h $(BITMAP_H) hard-reg-set.h
 BASIC_BLOCK_H = basic-block.h $(PREDICT_H) $(VEC_H) $(FUNCTION_H) cfghooks.h
 GIMPLE_H = gimple.h gimple.def gsstruct.def pointer-set.h $(VEC_H) \

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC] Centralize knowledge of eh personality routines
  2010-10-12 22:59 [RFC] Centralize knowledge of eh personality routines Richard Henderson
@ 2010-10-13  1:11 ` Jason Merrill
  2010-10-13  4:58 ` Ian Lance Taylor
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Jason Merrill @ 2010-10-13  1:11 UTC (permalink / raw)
  To: Richard Henderson; +Cc: GCC Patches, rguenther, joseph, java, ian, ebotcazou

Makes sense to me.

Jason

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC] Centralize knowledge of eh personality routines
  2010-10-12 22:59 [RFC] Centralize knowledge of eh personality routines Richard Henderson
  2010-10-13  1:11 ` Jason Merrill
@ 2010-10-13  4:58 ` Ian Lance Taylor
  2010-10-13  7:04 ` Eric Botcazou
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Ian Lance Taylor @ 2010-10-13  4:58 UTC (permalink / raw)
  To: Richard Henderson; +Cc: GCC Patches, rguenther, joseph, jason, java, ebotcazou

Richard Henderson <rth@redhat.com> writes:

> The driver for this patch is SEH, which will add yet another function
> name variant in each of these places in each front end.  While I could
> adjust each language appropriately, it seems to me that it is a bit
> cleaner to centralize this knowledge.

Works for me.

> The next possibly objectionable point is including dwarf2.h in tree.h.

Yeah.  Ugh.  I guess it's that or just using int.

Ian

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC] Centralize knowledge of eh personality routines
  2010-10-12 22:59 [RFC] Centralize knowledge of eh personality routines Richard Henderson
  2010-10-13  1:11 ` Jason Merrill
  2010-10-13  4:58 ` Ian Lance Taylor
@ 2010-10-13  7:04 ` Eric Botcazou
  2010-10-13  7:09   ` Arnaud Charlet
  2010-10-13  7:23   ` Olivier Hainque
  2010-10-13  8:53 ` Andrew Haley
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 11+ messages in thread
From: Eric Botcazou @ 2010-10-13  7:04 UTC (permalink / raw)
  To: Richard Henderson
  Cc: GCC Patches, rguenther, joseph, jason, java, ian, Olivier Hainque

> The driver for this patch is SEH, which will add yet another function
> name variant in each of these places in each front end.  While I could
> adjust each language appropriately, it seems to me that it is a bit
> cleaner to centralize this knowledge.

-/* Build a decl for a EH personality function named NAME. */
+/* Build a personality function given a language.  LANG is really an
+   enum dwarf_source_language.  */

Left-overs from when it was only an integer?


+    case DW_LANG_Ada83:
+    case DW_LANG_Ada95:
+      prefix = "__gnat_eh_personality";
+      /* The GNAT folk did not follow the standard naming format.
+	 That can change if we ever have to increment the version.  */
+      if (ui == UI_DWARF2 || ui == UI_TARGET)
+	unwind = "";
+      version = "";
+      break;

Let's change that right now, we don't guarantee any ABI compatibility between 
different major releases.  Olivier, any objections?

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC] Centralize knowledge of eh personality routines
  2010-10-13  7:04 ` Eric Botcazou
@ 2010-10-13  7:09   ` Arnaud Charlet
  2010-10-13  7:23   ` Olivier Hainque
  1 sibling, 0 replies; 11+ messages in thread
From: Arnaud Charlet @ 2010-10-13  7:09 UTC (permalink / raw)
  To: Eric Botcazou
  Cc: Richard Henderson, GCC Patches, rguenther, joseph, jason, java,
	ian, Olivier Hainque

> +    case DW_LANG_Ada83:
> +    case DW_LANG_Ada95:
> +      prefix = "__gnat_eh_personality";
> +      /* The GNAT folk did not follow the standard naming format.
> +	 That can change if we ever have to increment the version.  */
> +      if (ui == UI_DWARF2 || ui == UI_TARGET)
> +	unwind = "";
> +      version = "";
> +      break;
> 
> Let's change that right now, we don't guarantee any ABI compatibility
> between different major releases.  Olivier, any objections?

Looks like a good idea to me, so that we're consistent with other languages
and follow the standard naming format. As you said, we don't guarantee
ABI compatibility.

Arno

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC] Centralize knowledge of eh personality routines
  2010-10-13  7:04 ` Eric Botcazou
  2010-10-13  7:09   ` Arnaud Charlet
@ 2010-10-13  7:23   ` Olivier Hainque
  1 sibling, 0 replies; 11+ messages in thread
From: Olivier Hainque @ 2010-10-13  7:23 UTC (permalink / raw)
  To: Eric Botcazou
  Cc: Richard Henderson, GCC Patches, rguenther, joseph, jason, java,
	ian, hainque

Eric Botcazou wrote:
> +    case DW_LANG_Ada83:
> +    case DW_LANG_Ada95:
> +      prefix = "__gnat_eh_personality";
> +      /* The GNAT folk did not follow the standard naming format.
> +	 That can change if we ever have to increment the version.  */

> Let's change that right now, we don't guarantee any ABI
> compatibility between different major releases.  Olivier, any
> objections?

 No, on the contrary, I'm all for it. Thanks :)

 Olivier

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC] Centralize knowledge of eh personality routines
  2010-10-12 22:59 [RFC] Centralize knowledge of eh personality routines Richard Henderson
                   ` (2 preceding siblings ...)
  2010-10-13  7:04 ` Eric Botcazou
@ 2010-10-13  8:53 ` Andrew Haley
  2010-10-13 14:14 ` Mark Mitchell
  2010-10-13 18:07 ` Richard Henderson
  5 siblings, 0 replies; 11+ messages in thread
From: Andrew Haley @ 2010-10-13  8:53 UTC (permalink / raw)
  To: java

On 10/12/2010 11:59 PM, Richard Henderson wrote:
> The driver for this patch is SEH, which will add yet another function
> name variant in each of these places in each front end.  While I could
> adjust each language appropriately, it seems to me that it is a bit
> cleaner to centralize this knowledge.
> 
> The next possibly objectionable point is including dwarf2.h in tree.h.
> I went ahead and did this because in the past we had talked about using
> the dwarf language enum in LTO.  I could see eliminating the hackish
> language_string -> enum mapping that is done in dwarf2out.c as well.
> 
> Comments?  Objections?

Sounds good.

Andrew.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC] Centralize knowledge of eh personality routines
  2010-10-12 22:59 [RFC] Centralize knowledge of eh personality routines Richard Henderson
                   ` (3 preceding siblings ...)
  2010-10-13  8:53 ` Andrew Haley
@ 2010-10-13 14:14 ` Mark Mitchell
  2010-10-13 18:07 ` Richard Henderson
  5 siblings, 0 replies; 11+ messages in thread
From: Mark Mitchell @ 2010-10-13 14:14 UTC (permalink / raw)
  To: Richard Henderson
  Cc: GCC Patches, rguenther, joseph, jason, java, ian, ebotcazou

On 10/12/2010 3:59 PM, Richard Henderson wrote:
> The driver for this patch is SEH, which will add yet another function
> name variant in each of these places in each front end.  While I could
> adjust each language appropriately, it seems to me that it is a bit
> cleaner to centralize this knowledge.

> Comments?  Objections?

None in principle, but I think it would be better to have
build_personality_function take a language prefix string (e.g., "gxx" or
"gcj") rather than an enum.  Logically, the middle-end shouldn't be
aware of what front-end languages exist, and passing in a string would
avoid that.  And also avoid the tree.h -> dwarf2.h issue.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC] Centralize knowledge of eh personality routines
  2010-10-12 22:59 [RFC] Centralize knowledge of eh personality routines Richard Henderson
                   ` (4 preceding siblings ...)
  2010-10-13 14:14 ` Mark Mitchell
@ 2010-10-13 18:07 ` Richard Henderson
  2010-10-13 18:12   ` Eric Botcazou
  5 siblings, 1 reply; 11+ messages in thread
From: Richard Henderson @ 2010-10-13 18:07 UTC (permalink / raw)
  To: GCC Patches; +Cc: rguenther, joseph, jason, java, ian, ebotcazou, mark

[-- Attachment #1: Type: text/plain, Size: 424 bytes --]

Based on the feedback from Mark, I've left the languages 
passing in a string, shortened to "gxx" etc.  That does
put off the decision where and when to use the dwarf2 enum.

Based on the feedback from the GNAT folk, I've renamed
the Ada personality routine to match the other languages.

I expect the full testsuite run for x86_64-linux to complete
within the next hour.  Ok to commit assuming the results 
look good?


r~

[-- Attachment #2: d-per-2 --]
[-- Type: text/plain, Size: 7248 bytes --]

gcc/
	* expr.c (build_personality_function): Take parameter LANG instead
	of parameter NAME.  Build the name based on the lang prefix and the
	unwind method in use.
	* tree.c (lhd_gcc_personality): Update call to
	build_personality_function.

gcc/ada/
	* gcc-interface/misc.c (gnat_eh_personality): Update call to
	build_personality_function.
gcc/cp/
	* cp-lang.c (cp_eh_personality): Update call to
	build_personality_function.
	* except.c (choose_personality_routine): Update function comment.
gcc/java/
	* lang.c (java_eh_personality): Update call to
	build_personality_function.
gcc/objc/
	* objc-act.c (objc_eh_personality): Update call to
	build_personality_function.
gcc/objcp/
	* objcp-lang.c (objcxx_eh_personality): Update call to
	build_personality_function.


diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index 7703e2e..a1b2490 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -687,11 +687,7 @@ static tree
 gnat_eh_personality (void)
 {
   if (!gnat_eh_personality_decl)
-    gnat_eh_personality_decl
-      = build_personality_function (targetm.except_unwind_info () == UI_SJLJ
-				    ? "__gnat_eh_personality_sj"
-				    : "__gnat_eh_personality");
-
+    gnat_eh_personality_decl = build_personality_function ("gnat");
   return gnat_eh_personality_decl;
 }
 
diff --git a/gcc/ada/raise-gcc.c b/gcc/ada/raise-gcc.c
index 3589bc5..512ff36 100644
--- a/gcc/ada/raise-gcc.c
+++ b/gcc/ada/raise-gcc.c
@@ -407,7 +407,7 @@ db_phases (int phases)
    ===================================
 
    The major point of this unit is to provide an exception propagation
-   personality routine for Ada. This is __gnat_eh_personality.
+   personality routine for Ada. This is __gnat_personality_v0.
 
    It is provided with a pointer to the propagated exception, an unwind
    context describing a location the propagation is going through, and a
@@ -440,7 +440,7 @@ db_phases (int phases)
      |
      |   (Ada frame)
      |
-     +--> __gnat_eh_personality (context, exception)
+     +--> __gnat_personality_v0 (context, exception)
 	   |
 	   +--> get_region_descriptor_for (context)
 	   |
@@ -1028,9 +1028,9 @@ extern void __gnat_notify_unhandled_exception (void);
    GNU-Ada exceptions are met.  */
 
 #ifdef __USING_SJLJ_EXCEPTIONS__
-#define PERSONALITY_FUNCTION    __gnat_eh_personality_sj
+#define PERSONALITY_FUNCTION    __gnat_personality_sj0
 #else
-#define PERSONALITY_FUNCTION    __gnat_eh_personality
+#define PERSONALITY_FUNCTION    __gnat_personality_v0
 #endif
 
 /* Major tweak for ia64-vms : the CHF propagation phase calls this personality
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index 0b70444..a07d7be 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -166,17 +166,8 @@ cp_eh_personality (void)
 {
   if (!cp_eh_personality_decl)
     {
-      const char *name;
-
-      name = (targetm.except_unwind_info () == UI_SJLJ
-	      ? (pragma_java_exceptions
-		 ? "__gcj_personality_sj0"
-		 : "__gxx_personality_sj0")
-	      : (pragma_java_exceptions
-		 ? "__gcj_personality_v0"
-		 : "__gxx_personality_v0"));
-
-      cp_eh_personality_decl = build_personality_function (name);
+      const char *lang = (pragma_java_exceptions ? "gcj" : "gxx");
+      cp_eh_personality_decl = build_personality_function (lang);
     }
 
   return cp_eh_personality_decl;
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index 9d19aa9..b917664 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -295,9 +295,8 @@ decl_is_java_type (tree decl, int err)
 /* Select the personality routine to be used for exception handling,
    or issue an error if we need two different ones in the same
    translation unit.
-   ??? At present eh_personality_decl is set to
-   __gxx_personality_(sj|v)0 in init_exception_processing - should it
-   be done here instead?  */
+   ??? At present DECL_FUNCTION_PERSONALITY is set via
+   LANG_HOOKS_EH_PERSONALITY.  Should it be done here instead?  */
 void
 choose_personality_routine (enum languages lang)
 {
diff --git a/gcc/expr.c b/gcc/expr.c
index b0c160f..0050518 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -10255,13 +10255,31 @@ const_vector_from_tree (tree exp)
   return gen_rtx_CONST_VECTOR (mode, v);
 }
 
-
-/* Build a decl for a EH personality function named NAME. */
+/* Build a decl for a personality function given a language prefix.  */
 
 tree
-build_personality_function (const char *name)
+build_personality_function (const char *lang)
 {
+  const char *unwind_and_version;
   tree decl, type;
+  char *name;
+
+  switch (targetm.except_unwind_info ())
+    {
+    case UI_NONE:
+      return NULL;
+    case UI_SJLJ:
+      unwind_and_version = "_sj0";
+      break;
+    case UI_DWARF2:
+    case UI_TARGET:
+      unwind_and_version = "_v0";
+      break;
+    default:
+      gcc_unreachable ();
+    }
+
+  name = ACONCAT (("__", lang, "_personality", unwind_and_version, NULL));
 
   type = build_function_type_list (integer_type_node, integer_type_node,
 				   long_long_unsigned_type_node,
diff --git a/gcc/java/lang.c b/gcc/java/lang.c
index fbe25ad..45722e5 100644
--- a/gcc/java/lang.c
+++ b/gcc/java/lang.c
@@ -911,11 +911,7 @@ static tree
 java_eh_personality (void)
 {
   if (!java_eh_personality_decl)
-    java_eh_personality_decl
-      = build_personality_function (targetm.except_unwind_info () == UI_SJLJ
-				    ? "__gcj_personality_sj0"
-				    : "__gcj_personality_v0");
-
+    java_eh_personality_decl = build_personality_function ("gcj");
   return java_eh_personality_decl;
 }
 
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 26d490e..edde784 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -3716,13 +3716,8 @@ objc_eh_runtime_type (tree type)
 tree
 objc_eh_personality (void)
 {
-  if (!flag_objc_sjlj_exceptions
-      && !objc_eh_personality_decl)
-    objc_eh_personality_decl
-      = build_personality_function (targetm.except_unwind_info () == UI_SJLJ
-				    ? "__gnu_objc_personality_sj0"
-				    : "__gnu_objc_personality_v0");
-
+  if (!flag_objc_sjlj_exceptions && !objc_eh_personality_decl)
+    objc_eh_personality_decl = build_personality_function ("gnu_objc");
   return objc_eh_personality_decl;
 }
 #endif
diff --git a/gcc/objcp/objcp-lang.c b/gcc/objcp/objcp-lang.c
index fdb2976..6a45404 100644
--- a/gcc/objcp/objcp-lang.c
+++ b/gcc/objcp/objcp-lang.c
@@ -147,11 +147,7 @@ static tree
 objcxx_eh_personality (void)
 {
   if (!objcp_eh_personality_decl)
-    objcp_eh_personality_decl
-	= build_personality_function (targetm.except_unwind_info () == UI_SJLJ
-				      ? "__gxx_personality_sj0"
-				      : "__gxx_personality_v0");
-
+    objcp_eh_personality_decl = build_personality_function ("gxx");
   return objcp_eh_personality_decl;
 }
 
diff --git a/gcc/tree.c b/gcc/tree.c
index cf5881a..28cc2d8 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -10874,11 +10874,7 @@ tree
 lhd_gcc_personality (void)
 {
   if (!gcc_eh_personality_decl)
-    gcc_eh_personality_decl
-      = build_personality_function (targetm.except_unwind_info () == UI_SJLJ
-				    ? "__gcc_personality_sj0"
-				    : "__gcc_personality_v0");
-
+    gcc_eh_personality_decl = build_personality_function ("gcc");
   return gcc_eh_personality_decl;
 }
 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC] Centralize knowledge of eh personality routines
  2010-10-13 18:07 ` Richard Henderson
@ 2010-10-13 18:12   ` Eric Botcazou
  2010-10-13 18:26     ` Richard Henderson
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Botcazou @ 2010-10-13 18:12 UTC (permalink / raw)
  To: Richard Henderson; +Cc: GCC Patches, rguenther, joseph, jason, java, ian, mark

> Based on the feedback from the GNAT folk, I've renamed
> the Ada personality routine to match the other languages.

Thanks.  The new ada/raise-gcc.c hunk isn't mentioned in the ChangeLog.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC] Centralize knowledge of eh personality routines
  2010-10-13 18:12   ` Eric Botcazou
@ 2010-10-13 18:26     ` Richard Henderson
  0 siblings, 0 replies; 11+ messages in thread
From: Richard Henderson @ 2010-10-13 18:26 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: GCC Patches, rguenther, joseph, jason, java, ian, mark

On 10/13/2010 11:11 AM, Eric Botcazou wrote:
>> Based on the feedback from the GNAT folk, I've renamed
>> the Ada personality routine to match the other languages.
> 
> Thanks.  The new ada/raise-gcc.c hunk isn't mentioned in the ChangeLog.
> 
Oops.  I'll fix it in the commit.


r~

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-10-13 18:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-12 22:59 [RFC] Centralize knowledge of eh personality routines Richard Henderson
2010-10-13  1:11 ` Jason Merrill
2010-10-13  4:58 ` Ian Lance Taylor
2010-10-13  7:04 ` Eric Botcazou
2010-10-13  7:09   ` Arnaud Charlet
2010-10-13  7:23   ` Olivier Hainque
2010-10-13  8:53 ` Andrew Haley
2010-10-13 14:14 ` Mark Mitchell
2010-10-13 18:07 ` Richard Henderson
2010-10-13 18:12   ` Eric Botcazou
2010-10-13 18:26     ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).