except.h (struct eh_region_d): Add use_cxa_end_cleanup.

* except.h (struct eh_region_d): Add use_cxa_end_cleanup.
	* except.c (gen_eh_region): Set it.
	(duplicate_eh_regions_1): Copy it.
	* tree-eh.c (lower_resx): Use it to determine which function
	to call to resume.

	* langhooks.h (struct lang_hooks): Add eh_use_cxa_end_cleanup.
	* langhooks-def.h (LANG_HOOKS_EH_USE_CXA_END_CLEANUP): New.

	* builtins.def (BUILT_IN_CXA_END_CLEANUP): New.
	* tree.c (build_common_builtin_nodes): Remove parameter.  Build
	BUILT_IN_CXA_END_CLEANUP if necessary.
	* tree.h (build_common_builtin_nodes): Update decl.

	* c-common.c (c_define_builtins): Update call to
	build_common_builtin_nodes.

gcc/ada/
	* gcc-interface/utils.c (gnat_install_builtins): Update call to
	build_common_builtin_nodes.

gcc/cp/
	* cp-objcp-common.h (LANG_HOOKS_EH_USE_CXA_END_CLEANUP): New.

gcc/fortran/
	* f95-lang.c (gfc_init_builtin_functions): Update call to
	build_common_builtin_nodes.

gcc/java/
	* builtins.c (initialize_builtins): Update call to
	build_common_builtin_nodes.
	* lang.c (LANG_HOOKS_EH_USE_CXA_END_CLEANUP): New.

From-SVN: r152241
This commit is contained in:
Richard Henderson 2009-09-28 09:44:32 -07:00 committed by Richard Henderson
parent aa633255e7
commit 384c400a82
19 changed files with 89 additions and 37 deletions

View File

@ -1,3 +1,20 @@
2009-09-28 Richard Henderson <rth@redhat.com>
* except.h (struct eh_region_d): Add use_cxa_end_cleanup.
* except.c (gen_eh_region): Set it.
(duplicate_eh_regions_1): Copy it.
* tree-eh.c (lower_resx): Use it to determine which function
to call to resume.
* langhooks.h (struct lang_hooks): Add eh_use_cxa_end_cleanup.
* langhooks-def.h (LANG_HOOKS_EH_USE_CXA_END_CLEANUP): New.
* builtins.def (BUILT_IN_CXA_END_CLEANUP): New.
* tree.c (build_common_builtin_nodes): Remove parameter. Build
BUILT_IN_CXA_END_CLEANUP if necessary.
* c-common.c (c_define_builtins): Update call to
build_common_builtin_nodes.
2009-09-28 Andrew Pinski <andrew_pinski@playstation.sony.com>
* spu.c (get_branch_target): Return NULL for ASM_OPERANDS patterns.

View File

@ -1,3 +1,8 @@
2009-09-28 Richard Henderson <rth@redhat.com>
* gcc-interface/utils.c (gnat_install_builtins): Update call to
build_common_builtin_nodes.
2009-09-26 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Filter out

View File

@ -5662,7 +5662,7 @@ gnat_install_builtins (void)
know about internal specificities and control attributes accordingly, for
instance __builtin_alloca vs no-throw and -fstack-check. We will ignore
the generic definition from builtins.def. */
build_common_builtin_nodes (false);
build_common_builtin_nodes ();
/* Now, install the target specific builtins, such as the AltiVec family on
ppc, and the common set as exposed by builtins.def. */

View File

@ -761,6 +761,7 @@ DEF_BUILTIN (BUILT_IN_EMUTLS_REGISTER_COMMON,
/* Exception support. */
DEF_BUILTIN_STUB (BUILT_IN_UNWIND_RESUME, "__builtin_unwind_resume")
DEF_BUILTIN_STUB (BUILT_IN_CXA_END_CLEANUP, "__builtin_cxa_end_cleanup")
DEF_BUILTIN_STUB (BUILT_IN_EH_POINTER, "__builtin_eh_pointer")
DEF_BUILTIN_STUB (BUILT_IN_EH_FILTER, "__builtin_eh_filter")
DEF_BUILTIN_STUB (BUILT_IN_EH_COPY_VALUES, "__builtin_eh_copy_values")

View File

@ -4574,7 +4574,7 @@ c_define_builtins (tree va_list_ref_type_node, tree va_list_arg_type_node)
targetm.init_builtins ();
build_common_builtin_nodes (c_dialect_cxx ());
build_common_builtin_nodes ();
if (flag_mudflap)
mudflap_init ();

View File

@ -1,3 +1,7 @@
2009-09-28 Richard Henderson <rth@redhat.com>
* cp-objcp-common.h (LANG_HOOKS_EH_USE_CXA_END_CLEANUP): New.
2009-09-24 Jakub Jelinek <jakub@redhat.com>
* method.c (make_thunk, make_alias_for): Don't set

View File

@ -142,4 +142,7 @@ extern bool cp_function_decl_explicit_p (tree decl);
#undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE
#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE cxx_omp_privatize_by_reference
#undef LANG_HOOKS_EH_USE_CXA_END_CLEANUP
#define LANG_HOOKS_EH_USE_CXA_END_CLEANUP true
#endif /* GCC_CP_OBJCP_COMMON */

View File

@ -369,6 +369,10 @@ gen_eh_region (enum eh_region_type type, eh_region outer)
new_eh->index = VEC_length (eh_region, cfun->eh->region_array);
VEC_safe_push (eh_region, gc, cfun->eh->region_array, new_eh);
/* Copy the language's notion of whether to use __cxa_end_cleanup. */
if (targetm.arm_eabi_unwinder && lang_hooks.eh_use_cxa_end_cleanup)
new_eh->use_cxa_end_cleanup = true;
return new_eh;
}
@ -573,6 +577,9 @@ duplicate_eh_regions_1 (struct duplicate_eh_regions_data *data,
EH_LANDING_PAD_NR (new_lp->post_landing_pad) = new_lp->index;
}
/* Make sure to preserve the original use of __cxa_end_cleanup. */
new_r->use_cxa_end_cleanup = old_r->use_cxa_end_cleanup;
for (old_r = old_r->inner; old_r ; old_r = old_r->next_peer)
duplicate_eh_regions_1 (data, old_r, new_r);
}

View File

@ -171,6 +171,10 @@ struct GTY(()) eh_region_d
Each region gets its own psuedos so that if there are nested exceptions
we do not overwrite the values of the first exception. */
rtx exc_ptr_reg, filter_reg;
/* True if this region should use __cxa_end_cleanup instead
of _Unwind_Resume. */
bool use_cxa_end_cleanup;
};
typedef struct eh_landing_pad_d *eh_landing_pad;

View File

@ -1,3 +1,8 @@
2009-09-28 Richard Henderson <rth@redhat.com>
* f95-lang.c (gfc_init_builtin_functions): Update call to
build_common_builtin_nodes.
2009-09-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* simplify.c (gfc_simplify_acos, gfc_simplify_acosh,

View File

@ -1131,7 +1131,7 @@ gfc_init_builtin_functions (void)
BUILT_IN_EMUTLS_REGISTER_COMMON,
"__emutls_register_common", false);
build_common_builtin_nodes (false);
build_common_builtin_nodes ();
targetm.init_builtins ();
}

View File

@ -1,3 +1,9 @@
2009-09-28 Richard Henderson <rth@redhat.com>
* builtins.c (initialize_builtins): Update call to
build_common_builtin_nodes.
* lang.c (LANG_HOOKS_EH_USE_CXA_END_CLEANUP): New.
2009-09-14 Richard Henderson <rth@redhat.com>
* builtins.c (initialize_builtins): Update call to

View File

@ -584,7 +584,7 @@ initialize_builtins (void)
build_function_type_list (ptr_type_node, int_type_node, NULL_TREE),
"__builtin_return_address", BUILTIN_NOTHROW);
build_common_builtin_nodes (true);
build_common_builtin_nodes ();
}
/* If the call matches a builtin, return the

View File

@ -164,6 +164,9 @@ struct GTY(()) language_function {
#undef LANG_HOOKS_EH_PERSONALITY
#define LANG_HOOKS_EH_PERSONALITY java_eh_personality
#undef LANG_HOOKS_EH_USE_CXA_END_CLEANUP
#define LANG_HOOKS_EH_USE_CXA_END_CLEANUP true
/* Each front end provides its own. */
struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;

View File

@ -110,6 +110,7 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
#define LANG_HOOKS_INIT_TS lhd_do_nothing
#define LANG_HOOKS_EH_PERSONALITY lhd_gcc_personality
#define LANG_HOOKS_EH_RUNTIME_TYPE lhd_pass_through_t
#define LANG_HOOKS_EH_USE_CXA_END_CLEANUP false
/* Attribute hooks. */
#define LANG_HOOKS_ATTRIBUTE_TABLE NULL
@ -283,6 +284,7 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_EXPR_TO_DECL, \
LANG_HOOKS_EH_PERSONALITY, \
LANG_HOOKS_EH_RUNTIME_TYPE, \
LANG_HOOKS_EH_USE_CXA_END_CLEANUP, \
}
#endif /* GCC_LANG_HOOKS_DEF_H */

View File

@ -430,6 +430,10 @@ struct lang_hooks
/* Map a type to a runtime object to match type. */
tree (*eh_runtime_type) (tree);
/* True if this language uses __cxa_end_cleanup when the ARM EABI
is enabled. */
bool eh_use_cxa_end_cleanup;
/* Whenever you add entries here, make sure you adjust langhooks-def.h
and langhooks.c accordingly. */
};

View File

@ -2949,21 +2949,16 @@ lower_resx (basic_block bb, gimple stmt, struct pointer_map_t *mnt_map)
up the call chain. We resolve this by generating a call to the
_Unwind_Resume library function. */
/* ??? The ARM EABI redefines _Unwind_Resume as __cxa_end_cleanup
/* The ARM EABI redefines _Unwind_Resume as __cxa_end_cleanup
with no arguments for C++ and Java. Check for that. */
switch (targetm.arm_eabi_unwinder)
if (src_r->use_cxa_end_cleanup)
{
fn = implicit_built_in_decls[BUILT_IN_CXA_END_CLEANUP];
x = gimple_build_call (fn, 0);
gsi_insert_before (&gsi, x, GSI_SAME_STMT);
}
else
{
default:
fn = implicit_built_in_decls[BUILT_IN_UNWIND_RESUME];
if (TYPE_ARG_TYPES (TREE_TYPE (fn)) == void_list_node)
{
x = gimple_build_call (fn, 0);
gsi_insert_before (&gsi, x, GSI_SAME_STMT);
break;
}
/* FALLTHRU */
case 0:
fn = implicit_built_in_decls[BUILT_IN_EH_POINTER];
src_nr = build_int_cst (NULL, src_r->index);
x = gimple_build_call (fn, 1, src_nr);
@ -2975,7 +2970,6 @@ lower_resx (basic_block bb, gimple stmt, struct pointer_map_t *mnt_map)
fn = implicit_built_in_decls[BUILT_IN_UNWIND_RESUME];
x = gimple_build_call (fn, 1, var);
gsi_insert_before (&gsi, x, GSI_SAME_STMT);
break;
}
gcc_assert (EDGE_COUNT (bb->succs) == 0);

View File

@ -8890,13 +8890,10 @@ local_define_builtin (const char *name, tree type, enum built_in_function code,
/* Call this function after instantiating all builtins that the language
front end cares about. This will build the rest of the builtins that
are relied upon by the tree optimizers and the middle-end.
ENABLE_CXA_END_CLEANUP should be true for C++ and Java, where the ARM
EABI requires a slightly different implementation of _Unwind_Resume. */
are relied upon by the tree optimizers and the middle-end. */
void
build_common_builtin_nodes (bool enable_cxa_end_cleanup)
build_common_builtin_nodes (void)
{
tree tmp, tmp2, ftype;
@ -9003,23 +9000,23 @@ build_common_builtin_nodes (bool enable_cxa_end_cleanup)
local_define_builtin ("__builtin_profile_func_exit", ftype,
BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit", 0);
if (enable_cxa_end_cleanup && targetm.arm_eabi_unwinder)
/* If there's a possibility that we might use the ARM EABI, build the
alternate __cxa_end_cleanup node used to resume from C++ and Java. */
if (targetm.arm_eabi_unwinder)
{
ftype = build_function_type (void_type_node, void_list_node);
local_define_builtin ("__builtin_unwind_resume", ftype,
BUILT_IN_UNWIND_RESUME,
local_define_builtin ("__builtin_cxa_end_cleanup", ftype,
BUILT_IN_CXA_END_CLEANUP,
"__cxa_end_cleanup", ECF_NORETURN);
}
else
{
tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
ftype = build_function_type (void_type_node, tmp);
local_define_builtin ("__builtin_unwind_resume", ftype,
BUILT_IN_UNWIND_RESUME,
(USING_SJLJ_EXCEPTIONS
? "_Unwind_SjLj_Resume" : "_Unwind_Resume"),
ECF_NORETURN);
}
tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
ftype = build_function_type (void_type_node, tmp);
local_define_builtin ("__builtin_unwind_resume", ftype,
BUILT_IN_UNWIND_RESUME,
(USING_SJLJ_EXCEPTIONS
? "_Unwind_SjLj_Resume" : "_Unwind_Resume"),
ECF_NORETURN);
/* The exception object and filter values from the runtime. The argument
must be zero before exception lowering, i.e. from the front end. After

View File

@ -4949,7 +4949,7 @@ extern int real_minus_onep (const_tree);
extern void init_ttree (void);
extern void build_common_tree_nodes (bool, bool);
extern void build_common_tree_nodes_2 (int);
extern void build_common_builtin_nodes (bool);
extern void build_common_builtin_nodes (void);
extern tree build_nonstandard_integer_type (unsigned HOST_WIDE_INT, int);
extern tree build_range_type (tree, tree, tree);
extern bool subrange_type_for_debug_p (const_tree, tree *, tree *);