tree.h (struct tree_common): Rename raises_flag to nothrow_flag.

* tree.h (struct tree_common): Rename raises_flag to nothrow_flag.
        (TREE_NOTHROW): Rename from TREE_RAISES.
        * toplev.c (rest_of_compilation): Set it.
        * print-tree.c (print_node): Adjust.
        * tree.c (stabilize_reference, build, build1): Don't set TREE_RAISES.
        (stabilize_reference_1, get_unwidened, get_narrower): Likewise.
        * calls.c (emit_call_1): Add 'nothrow' parm.  Add
        REG_EH_REGION note as appropriate.
        (libfunc_nothrow): New fn.
        (emit_library_call, emit_library_call_value): Use it.
        (expand_call): Check TREE_NOTHROW.

cp:
        * call.c (build_call): Set TREE_NOTHROW on the CALL_EXPR as
        appropriate.
        * decl.c (define_function): Set TREE_NOTHROW on the FUNCTION_DECL.
        * except.c (call_eh_info, alloc_eh_object, expand_throw): Set
        TREE_NOTHROW or TREE_THIS_VOLATILE on the function as appropriate.
        * rtti.c (build_runtime_decl, get_tinfo_decl, build_dynamic_cast_1,
        expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc,
        expand_generic_desc): Likewise.

From-SVN: r32453
This commit is contained in:
Jason Merrill 2000-03-09 15:34:52 -05:00
parent 217ab4b7e7
commit 12a22e76d6
11 changed files with 108 additions and 34 deletions

View File

@ -1,11 +1,23 @@
2000-03-09 Jason Merrill <jason@casey.cygnus.com>
* tree.h (struct tree_common): Rename raises_flag to nothrow_flag.
(TREE_NOTHROW): Rename from TREE_RAISES.
* toplev.c (rest_of_compilation): Set it.
* print-tree.c (print_node): Adjust.
* tree.c (stabilize_reference, build, build1): Don't set TREE_RAISES.
(stabilize_reference_1, get_unwidened, get_narrower): Likewise.
* calls.c (emit_call_1): Add 'nothrow' parm. Add
REG_EH_REGION note as appropriate.
(libfunc_nothrow): New fn.
(emit_library_call, emit_library_call_value): Use it.
(expand_call): Check TREE_NOTHROW.
* varasm.c (make_decl_rtl): Skip initial '*' when setting
DECL_ASSEMBLER_NAME.
2000-03-09 Andreas Jaeger <aj@suse.de>
* config/mips/linux.h (NO_IMPLICIT_EXTERN_C): Define.
* mips/linux.h (NO_IMPLICIT_EXTERN_C): Define.
(TARGET_MEM_FUNCTIONS): Define.
2000-03-09 Jason Merrill <jason@casey.cygnus.com>

View File

@ -134,7 +134,7 @@ static int calls_function PARAMS ((tree, int));
static int calls_function_1 PARAMS ((tree, int));
static void emit_call_1 PARAMS ((rtx, tree, tree, HOST_WIDE_INT,
HOST_WIDE_INT, HOST_WIDE_INT, rtx,
rtx, int, rtx, int));
rtx, int, rtx, int, int));
static void precompute_register_parameters PARAMS ((int,
struct arg_data *,
int *));
@ -163,6 +163,7 @@ static void compute_argument_addresses PARAMS ((struct arg_data *,
static rtx rtx_for_function_call PARAMS ((tree, tree));
static void load_register_parameters PARAMS ((struct arg_data *,
int, rtx *));
static int libfunc_nothrow PARAMS ((rtx));
#if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
static rtx save_fixed_argument_area PARAMS ((int, rtx, int *, int *));
@ -383,7 +384,7 @@ prepare_call_address (funexp, fndecl, call_fusage, reg_parm_seen)
static void
emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
struct_value_size, next_arg_reg, valreg, old_inhibit_defer_pop,
call_fusage, is_const)
call_fusage, is_const, nothrow)
rtx funexp;
tree fndecl ATTRIBUTE_UNUSED;
tree funtype ATTRIBUTE_UNUSED;
@ -394,7 +395,7 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
rtx valreg;
int old_inhibit_defer_pop;
rtx call_fusage;
int is_const;
int is_const, nothrow;
{
rtx rounded_stack_size_rtx = GEN_INT (rounded_stack_size);
#if defined (HAVE_call) && defined (HAVE_call_value)
@ -491,6 +492,12 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
if (is_const)
CONST_CALL_P (call_insn) = 1;
/* If this call can't throw, attach a REG_EH_REGION reg note to that
effect. */
if (nothrow)
REG_NOTES (call_insn) = gen_rtx_EXPR_LIST (REG_EH_REGION, GEN_INT (-1),
REG_NOTES (call_insn));
/* Restore this now, so that we do defer pops for this call's args
if the context of the call as a whole permits. */
inhibit_defer_pop = old_inhibit_defer_pop;
@ -1682,6 +1689,8 @@ expand_call (exp, target, ignore)
int is_const = 0;
/* Nonzero if this is a call to a `volatile' function. */
int is_volatile = 0;
/* Nonzero if this is a call to a function that won't throw an exception. */
int nothrow = TREE_NOTHROW (exp);
#if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
/* Define the boundary of the register parm stack space that needs to be
save, if any. */
@ -1756,6 +1765,9 @@ expand_call (exp, target, ignore)
if (TREE_THIS_VOLATILE (fndecl))
is_volatile = 1;
if (TREE_NOTHROW (fndecl))
nothrow = 1;
}
}
@ -2418,7 +2430,7 @@ expand_call (exp, target, ignore)
emit_call_1 (funexp, fndecl, funtype, unadjusted_args_size,
args_size.constant, struct_value_size,
FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
valreg, old_inhibit_defer_pop, call_fusage, is_const);
valreg, old_inhibit_defer_pop, call_fusage, is_const, nothrow);
/* If call is cse'able, make appropriate pair of reg-notes around it.
Test valreg so we don't crash; may safely ignore `const'
@ -2666,6 +2678,22 @@ expand_call (exp, target, ignore)
return target;
}
/* Returns nonzero if FUN is the symbol for a library function which can
not throw. */
static int
libfunc_nothrow (fun)
rtx fun;
{
if (fun == throw_libfunc
|| fun == rethrow_libfunc
|| fun == sjthrow_libfunc
|| fun == sjpopnthrow_libfunc)
return 0;
return 1;
}
/* Output a library call to function FUN (a SYMBOL_REF rtx)
(emitting the queue unless NO_QUEUE is nonzero),
for a value of mode OUTMODE,
@ -2714,6 +2742,7 @@ emit_library_call VPARAMS((rtx orgfun, int no_queue, enum machine_mode outmode,
int old_inhibit_defer_pop = inhibit_defer_pop;
rtx call_fusage = 0;
int reg_parm_stack_space = 0;
int nothrow;
#if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
/* Define the boundary of the register parm stack space that needs to be
save, if any. */
@ -2747,6 +2776,8 @@ emit_library_call VPARAMS((rtx orgfun, int no_queue, enum machine_mode outmode,
fun = orgfun;
nothrow = libfunc_nothrow (fun);
/* Copy all the libcall-arguments out of the varargs data
and into a vector ARGVEC.
@ -3139,7 +3170,7 @@ emit_library_call VPARAMS((rtx orgfun, int no_queue, enum machine_mode outmode,
original_args_size.constant, args_size.constant, 0,
FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
outmode != VOIDmode ? hard_libcall_value (outmode) : NULL_RTX,
old_inhibit_defer_pop + 1, call_fusage, no_queue);
old_inhibit_defer_pop + 1, call_fusage, no_queue, nothrow);
pop_temp_slots ();
@ -3234,6 +3265,7 @@ emit_library_call_value VPARAMS((rtx orgfun, rtx value, int no_queue,
int struct_value_size = 0;
int is_const;
int reg_parm_stack_space = 0;
int nothrow;
#ifdef ACCUMULATE_OUTGOING_ARGS
int needed;
#endif
@ -3272,6 +3304,8 @@ emit_library_call_value VPARAMS((rtx orgfun, rtx value, int no_queue,
is_const = no_queue;
fun = orgfun;
nothrow = libfunc_nothrow (fun);
#ifdef PREFERRED_STACK_BOUNDARY
/* Ensure current function's preferred stack boundary is at least
what we need. */
@ -3737,7 +3771,7 @@ emit_library_call_value VPARAMS((rtx orgfun, rtx value, int no_queue,
struct_value_size,
FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
mem_value == 0 ? hard_libcall_value (outmode) : NULL_RTX,
old_inhibit_defer_pop + 1, call_fusage, is_const);
old_inhibit_defer_pop + 1, call_fusage, is_const, nothrow);
/* Now restore inhibit_defer_pop to its actual original value. */
OK_DEFER_POP;

View File

@ -1,3 +1,14 @@
2000-03-09 Jason Merrill <jason@casey.cygnus.com>
* call.c (build_call): Set TREE_NOTHROW on the CALL_EXPR as
appropriate.
* decl.c (define_function): Set TREE_NOTHROW on the FUNCTION_DECL.
* except.c (call_eh_info, alloc_eh_object, expand_throw): Set
TREE_NOTHROW or TREE_THIS_VOLATILE on the function as appropriate.
* rtti.c (build_runtime_decl, get_tinfo_decl, build_dynamic_cast_1,
expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc,
expand_generic_desc): Likewise.
2000-03-08 Nathan Sidwell <nathan@codesourcery.com>
* exception.cc (__cp_pop_exception): Cleanup the original object.

View File

@ -368,6 +368,7 @@ build_call (function, result_type, parms)
tree function, result_type, parms;
{
int is_constructor = 0;
int nothrow;
tree tmp;
tree decl;
@ -385,6 +386,11 @@ build_call (function, result_type, parms)
else
decl = NULL_TREE;
/* We check both the decl and the type; a function may be known not to
throw without being declared throw(). */
nothrow = ((decl && TREE_NOTHROW (decl))
|| TYPE_NOTHROW_P (TREE_TYPE (TREE_TYPE (function))));
if (decl && DECL_CONSTRUCTOR_P (decl))
is_constructor = 1;
@ -408,6 +414,7 @@ build_call (function, result_type, parms)
TREE_HAS_CONSTRUCTOR (function) = is_constructor;
TREE_TYPE (function) = result_type;
TREE_SIDE_EFFECTS (function) = 1;
TREE_NOTHROW (function) = nothrow;
return function;
}

View File

@ -6479,6 +6479,10 @@ define_function (name, type, pfn, library_name)
TREE_PUBLIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
/* If no exception specifier was given, assume it doesn't throw. */
if (TYPE_RAISES_EXCEPTIONS (type) == NULL_TREE)
TREE_NOTHROW (decl) = 1;
my_friendly_assert (DECL_CONTEXT (decl) == NULL_TREE, 392);
DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);

View File

@ -258,6 +258,7 @@ call_eh_info ()
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
}
@ -805,6 +806,7 @@ alloc_eh_object (type)
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
}
@ -857,6 +859,7 @@ expand_throw (exp)
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
TREE_THIS_VOLATILE (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
}
@ -976,6 +979,7 @@ expand_throw (exp)
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
}
@ -1005,6 +1009,7 @@ expand_throw (exp)
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
}

View File

@ -185,6 +185,7 @@ build_runtime_decl (name, type)
DECL_EXTERNAL (d) = 1;
TREE_PUBLIC (d) = 1;
DECL_ARTIFICIAL (d) = 1;
TREE_THIS_VOLATILE (d) = 1;
pushdecl_top_level (d);
make_function_rtl (d);
}
@ -423,6 +424,7 @@ get_tinfo_decl (type)
DECL_EXTERNAL (d) = 1;
TREE_PUBLIC (d) = 1;
DECL_ARTIFICIAL (d) = 1;
TREE_NOTHROW (d) = 1;
DECL_NOT_REALLY_EXTERN (d) = 1;
SET_DECL_TINFO_FN_P (d);
TREE_TYPE (name) = type;
@ -818,9 +820,10 @@ build_dynamic_cast_1 (type, expr)
DECL_EXTERNAL (dcast_fn) = 1;
TREE_PUBLIC (dcast_fn) = 1;
DECL_ARTIFICIAL (dcast_fn) = 1;
TREE_NOTHROW (dcast_fn) = 1;
pushdecl (dcast_fn);
if (new_abi_rtti_p ())
/* We want it's name mangling. */
/* We want its name mangling. */
set_mangled_name_for_decl (dcast_fn);
make_function_rtl (dcast_fn);
pop_nested_namespace (ns);
@ -915,6 +918,7 @@ expand_si_desc (tdecl, type)
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
}
@ -1074,6 +1078,7 @@ expand_class_desc (tdecl, type)
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
}
@ -1118,6 +1123,7 @@ expand_ptr_desc (tdecl, type)
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
}
@ -1163,6 +1169,7 @@ expand_attr_desc (tdecl, type)
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
}
@ -1200,6 +1207,7 @@ expand_generic_desc (tdecl, type, fnname)
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
}

View File

@ -301,8 +301,8 @@ print_node (file, prefix, node, indent)
fputs (" asm_written", file);
if (TREE_USED (node))
fputs (" used", file);
if (TREE_RAISES (node))
fputs (" raises", file);
if (TREE_NOTHROW (node))
fputs (" nothrow", file);
if (!ggc_p && TREE_PERMANENT (node))
fputs (" permanent", file);
if (TREE_PUBLIC (node))

View File

@ -3679,6 +3679,10 @@ rest_of_compilation (decl)
#endif
current_function_nothrow = nothrow_function_p ();
if (current_function_nothrow)
/* Now we know that this can't throw; set the flag for the benefit
of other functions later in this translation unit. */
TREE_NOTHROW (current_function_decl) = 1;
/* Now turn the rtl into assembler code. */

View File

@ -3025,7 +3025,6 @@ stabilize_reference (ref)
TREE_READONLY (result) = TREE_READONLY (ref);
TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (ref);
TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (ref);
TREE_RAISES (result) = TREE_RAISES (ref);
return result;
}
@ -3108,7 +3107,6 @@ stabilize_reference_1 (e)
TREE_READONLY (result) = TREE_READONLY (e);
TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (e);
TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (e);
TREE_RAISES (result) = TREE_RAISES (e);
return result;
}
@ -3161,15 +3159,11 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
{
if (TREE_SIDE_EFFECTS (arg0))
TREE_SIDE_EFFECTS (t) = 1;
if (TREE_RAISES (arg0))
TREE_RAISES (t) = 1;
}
if (arg1 && fro > 1)
{
if (TREE_SIDE_EFFECTS (arg1))
TREE_SIDE_EFFECTS (t) = 1;
if (TREE_RAISES (arg1))
TREE_RAISES (t) = 1;
}
}
else if (length == 1)
@ -3184,7 +3178,6 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
{
if (arg0 && TREE_SIDE_EFFECTS (arg0))
TREE_SIDE_EFFECTS (t) = 1;
TREE_RAISES (t) = (arg0 && TREE_RAISES (arg0));
}
}
else
@ -3197,8 +3190,6 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
{
if (TREE_SIDE_EFFECTS (operand))
TREE_SIDE_EFFECTS (t) = 1;
if (TREE_RAISES (operand))
TREE_RAISES (t) = 1;
}
}
}
@ -3254,8 +3245,6 @@ build1 (code, type, node)
{
if (TREE_SIDE_EFFECTS (node))
TREE_SIDE_EFFECTS (t) = 1;
if (TREE_RAISES (node))
TREE_RAISES (t) = 1;
}
switch (code)
@ -4827,7 +4816,6 @@ get_unwidened (op, for_type)
TREE_OPERAND (op, 1));
TREE_SIDE_EFFECTS (win) = TREE_SIDE_EFFECTS (op);
TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op);
TREE_RAISES (win) = TREE_RAISES (op);
}
}
return win;
@ -4914,7 +4902,6 @@ get_narrower (op, unsignedp_ptr)
TREE_OPERAND (op, 1));
TREE_SIDE_EFFECTS (win) = TREE_SIDE_EFFECTS (op);
TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op);
TREE_RAISES (win) = TREE_RAISES (op);
}
}
*unsignedp_ptr = uns;

View File

@ -206,7 +206,7 @@ struct tree_common
unsigned asm_written_flag: 1;
unsigned used_flag : 1;
unsigned raises_flag : 1;
unsigned nothrow_flag : 1;
unsigned static_flag : 1;
unsigned public_flag : 1;
unsigned private_flag : 1;
@ -322,10 +322,10 @@ struct tree_common
TREE_USED in
expressions, IDENTIFIER_NODE
raises_flag:
nothrow_flag:
TREE_RAISES in
expressions
TREE_NOTHROW in
CALL_EXPR, FUNCTION_DECL
*/
/* Define accessors for the fields that all tree nodes have
@ -599,9 +599,9 @@ extern void tree_class_check_failed PARAMS ((const tree, char,
was used. */
#define TREE_USED(NODE) ((NODE)->common.used_flag)
/* Nonzero for a tree node whose evaluation could result
in the raising of an exception. Not implemented yet. */
#define TREE_RAISES(NODE) ((NODE)->common.raises_flag)
/* In a FUNCTION_DECL, nonzero means a call to the function cannot throw
an exception. In a CALL_EXPR, nonzero means the call cannot throw. */
#define TREE_NOTHROW(NODE) ((NODE)->common.nothrow_flag)
/* Used in classes in C++. */
#define TREE_PRIVATE(NODE) ((NODE)->common.private_flag)
@ -1300,15 +1300,17 @@ struct tree_type
contour that restored a stack level and which is now exited. */
#define DECL_TOO_LATE(NODE) (DECL_CHECK (NODE)->decl.bit_field_flag)
/* In a FUNCTION_DECL, nonzero means a built in function. */
#define DECL_BUILT_IN(NODE) (DECL_BUILT_IN_CLASS (NODE) != NOT_BUILT_IN)
/* For a builtin function, identify which part of the compiler defined it. */
#define DECL_BUILT_IN_CLASS(NODE) (DECL_CHECK (NODE)->decl.built_in_class)
/* Unused in FUNCTION_DECL. */
/* In a VAR_DECL that's static,
nonzero if the space is in the text section. */
#define DECL_IN_TEXT_SECTION(NODE) (DECL_CHECK (NODE)->decl.bit_field_flag)
/* In a FUNCTION_DECL, nonzero means a built in function. */
#define DECL_BUILT_IN(NODE) (DECL_BUILT_IN_CLASS (NODE) != NOT_BUILT_IN)
/* For a builtin function, identify which part of the compiler defined it. */
#define DECL_BUILT_IN_CLASS(NODE) (DECL_CHECK (NODE)->decl.built_in_class)
/* Used in VAR_DECLs to indicate that the variable is a vtable.
Used in FIELD_DECLs for vtable pointers.
Used in FUNCTION_DECLs to indicate that the function is virtual. */