From aeb302bbec86aff44fadaad0c9c9bf5e59cbe3f5 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 8 Jun 1998 10:52:37 +0000 Subject: [PATCH] function.c: Define current_function_cannot_inline. * function.c: Define current_function_cannot_inline. (push_function_context_to): Save it. (pop_function_context_from): Restore it. * function.h (struct function): Provide it a home. * output.h: Declare it. * integrate.c (function_cannot_inline_p): Check it. * decl.c (cp_finish_decl): Disable inlining of extern inlines with static variables. From-SVN: r20332 --- gcc/ChangeLog | 9 +++++++++ gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 29 +++++++---------------------- gcc/function.c | 6 ++++++ gcc/function.h | 1 + gcc/integrate.c | 3 +++ gcc/output.h | 3 +++ 7 files changed, 34 insertions(+), 22 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ff1a1e4e3d8..07b0a2bf7d4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +Mon Jun 8 01:21:13 1998 Jason Merrill + + * function.c: Define current_function_cannot_inline. + (push_function_context_to): Save it. + (pop_function_context_from): Restore it. + * function.h (struct function): Provide it a home. + * output.h: Declare it. + * integrate.c (function_cannot_inline_p): Check it. + Mon Jun 8 10:43:15 1998 Richard Henderson * expr.c (force_operand): Detect PIC address loads before diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 07178e742ac..912b332332c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1998-06-08 Jason Merrill + + * decl.c (cp_finish_decl): Disable inlining of extern inlines + with static variables. + 1998-06-08 Mark Mitchell * init.c (build_offset_ref): Correct previous change to use build, diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 67720731f59..0505cc618a0 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6992,35 +6992,20 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) if (was_temp) end_temporary_allocation (); - /* Extern inline function static data has external linkage. */ + /* Extern inline function static data has external linkage. + Instead of trying to deal with that, we disable inlining of + such functions. The ASM_WRITTEN check is to avoid hitting this + for __FUNCTION__. */ if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) + && ! TREE_ASM_WRITTEN (decl) && current_function_decl && DECL_CONTEXT (decl) == current_function_decl && DECL_THIS_INLINE (current_function_decl) && TREE_PUBLIC (current_function_decl)) { - if (DECL_INTERFACE_KNOWN (current_function_decl)) - { - TREE_PUBLIC (decl) = 1; - DECL_EXTERNAL (decl) = DECL_EXTERNAL (current_function_decl); - } - /* We can only do this if we can use common or weak, and we - can't if it has been initialized and we don't support weak. */ - else if (DECL_INITIAL (decl) == NULL_TREE - || DECL_INITIAL (decl) == error_mark_node) - { - TREE_PUBLIC (decl) = 1; - DECL_COMMON (decl) = 1; - } - else if (flag_weak) - make_decl_one_only (decl); - - if (TREE_PUBLIC (decl)) - DECL_ASSEMBLER_NAME (decl) - = build_static_name (current_function_decl, DECL_NAME (decl)); - else if (! DECL_ARTIFICIAL (decl)) - cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl); + current_function_cannot_inline + = "function with static variable cannot be inline"; } else if (TREE_CODE (decl) == VAR_DECL diff --git a/gcc/function.c b/gcc/function.c index 00e7546b268..f8e3cd40667 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -214,6 +214,9 @@ int current_function_uses_pic_offset_table; /* The arg pointer hard register, or the pseudo into which it was copied. */ rtx current_function_internal_arg_pointer; +/* Language-specific reason why the current function cannot be made inline. */ +char *current_function_cannot_inline; + /* The FUNCTION_DECL for an inline function currently being expanded. */ tree inline_function_decl; @@ -507,6 +510,7 @@ push_function_context_to (context) p->uses_const_pool = current_function_uses_const_pool; p->uses_pic_offset_table = current_function_uses_pic_offset_table; p->internal_arg_pointer = current_function_internal_arg_pointer; + p->cannot_inline = current_function_cannot_inline; p->max_parm_reg = max_parm_reg; p->parm_reg_stack_loc = parm_reg_stack_loc; p->outgoing_args_size = current_function_outgoing_args_size; @@ -588,6 +592,7 @@ pop_function_context_from (context) current_function_uses_const_pool = p->uses_const_pool; current_function_uses_pic_offset_table = p->uses_pic_offset_table; current_function_internal_arg_pointer = p->internal_arg_pointer; + current_function_cannot_inline = p->cannot_inline; max_parm_reg = p->max_parm_reg; parm_reg_stack_loc = p->parm_reg_stack_loc; current_function_outgoing_args_size = p->outgoing_args_size; @@ -5319,6 +5324,7 @@ init_function_start (subr, filename, line) current_function_epilogue_delay_list = 0; current_function_uses_const_pool = 0; current_function_uses_pic_offset_table = 0; + current_function_cannot_inline = 0; /* We have not yet needed to make a label to jump to for tail-recursion. */ tail_recursion_label = 0; diff --git a/gcc/function.h b/gcc/function.h index 59a149d4481..e06366c9478 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -102,6 +102,7 @@ struct function rtx tail_recursion_label; rtx tail_recursion_reentry; rtx internal_arg_pointer; + char *cannot_inline; rtx arg_pointer_save_area; tree rtl_expr_chain; rtx last_parm_insn; diff --git a/gcc/integrate.c b/gcc/integrate.c index ef78b0a9248..518f1c0c12f 100644 --- a/gcc/integrate.c +++ b/gcc/integrate.c @@ -132,6 +132,9 @@ function_cannot_inline_p (fndecl) if (current_function_contains_functions) return "function with nested functions cannot be inline"; + if (current_function_cannot_inline) + return current_function_cannot_inline; + /* If its not even close, don't even look. */ if (!DECL_INLINE (fndecl) && get_max_uid () > 3 * max_insns) return "function too large to be inline"; diff --git a/gcc/output.h b/gcc/output.h index c3c0381ded6..dd9ad82a6bc 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -437,6 +437,9 @@ extern int current_function_uses_pic_offset_table; /* This is nonzero if the current function uses the constant pool. */ extern int current_function_uses_const_pool; +/* Language-specific reason why the current function cannot be made inline. */ +extern char *current_function_cannot_inline; + /* The line number of the beginning of the current function. sdbout.c needs this so that it can output relative linenumbers. */ -- 2.30.2