From: Bernd Schmidt Date: Tue, 3 May 2011 13:08:36 +0000 (+0000) Subject: function.c (init_function_start): Call decide_function_section. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2c7eebae8a0b49351452b3a98fc1b2f26608bfbc;p=gcc.git function.c (init_function_start): Call decide_function_section. * function.c (init_function_start): Call decide_function_section. * varasm.c (decide_function_section): New function. (assemble_start_function): When not using flag_reorder_blocks_and_partition, don't compute in_cold_section_p or first_function_block_is_cold. * rtl.h (decide_function_section): Declare. * gcc.target/arm/cold-lc.c: New test. From-SVN: r173303 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3527b6e58aa..93b086231a1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2011-05-03 Bernd Schmidt + + * function.c (init_function_start): Call decide_function_section. + * varasm.c (decide_function_section): New function. + (assemble_start_function): When not using + flag_reorder_blocks_and_partition, don't compute in_cold_section_p + or first_function_block_is_cold. + * rtl.h (decide_function_section): Declare. + 2011-05-03 Uros Bizjak Jakub Jelinek diff --git a/gcc/function.c b/gcc/function.c index 973e5a1d34e..ab1ca9ecf52 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4515,6 +4515,7 @@ init_function_start (tree subr) else allocate_struct_function (subr, false); prepare_function_start (); + decide_function_section (subr); /* Warn if this value is an aggregate type, regardless of which calling convention we are using for it. */ diff --git a/gcc/rtl.h b/gcc/rtl.h index 04021a3f29d..62b677ac3c0 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1668,6 +1668,7 @@ extern rtx get_pool_constant (rtx); extern rtx get_pool_constant_mark (rtx, bool *); extern enum machine_mode get_pool_mode (const_rtx); extern rtx simplify_subtraction (rtx); +extern void decide_function_section (tree); /* In function.c */ extern rtx assign_stack_local (enum machine_mode, HOST_WIDE_INT, int); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8c4d5f755e6..c1c1fbe5e60 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-05-03 Bernd Schmidt + + * gcc.target/arm/cold-lc.c: New test. + 2011-05-03 Jakub Jelinek PR target/48774 diff --git a/gcc/testsuite/gcc.target/arm/cold-lc.c b/gcc/testsuite/gcc.target/arm/cold-lc.c new file mode 100644 index 00000000000..295c29fe8f0 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cold-lc.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mlong-calls" } */ +/* { dg-final { scan-assembler-not "bl\[^\n\]*dump_stack" } } */ + +extern void dump_stack (void) __attribute__ ((__cold__)) __attribute__ ((noinline)); +struct thread_info { + struct task_struct *task; +}; +extern struct thread_info *current_thread_info (void); + +void dump_stack (void) +{ + unsigned long stack; + show_stack ((current_thread_info ()->task), &stack); +} + +void die (char *str, void *fp, int nr) +{ + dump_stack (); + while (1); +} + diff --git a/gcc/varasm.c b/gcc/varasm.c index b4f38058e22..f46c21b3bde 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1512,6 +1512,33 @@ notice_global_symbol (tree decl) } } +/* If not using flag_reorder_blocks_and_partition, decide early whether the + current function goes into the cold section, so that targets can use + current_function_section during RTL expansion. DECL describes the + function. */ + +void +decide_function_section (tree decl) +{ + first_function_block_is_cold = false; + + if (flag_reorder_blocks_and_partition) + /* We will decide in assemble_start_function. */ + return; + + if (DECL_SECTION_NAME (decl)) + { + struct cgraph_node *node = cgraph_get_node (current_function_decl); + /* Calls to function_section rely on first_function_block_is_cold + being accurate. */ + first_function_block_is_cold = (node + && node->frequency + == NODE_FREQUENCY_UNLIKELY_EXECUTED); + } + + in_cold_section_p = first_function_block_is_cold; +} + /* Output assembler code for the constant pool of a function and associated with defining the name of the function. DECL describes the function. NAME is the function's name. For the constant pool, we use the current @@ -1524,7 +1551,6 @@ assemble_start_function (tree decl, const char *fnname) char tmp_label[100]; bool hot_label_written = false; - first_function_block_is_cold = false; if (flag_reorder_blocks_and_partition) { ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LHOTB", const_labelno); @@ -1559,6 +1585,8 @@ assemble_start_function (tree decl, const char *fnname) if (flag_reorder_blocks_and_partition) { + first_function_block_is_cold = false; + switch_to_section (unlikely_text_section ()); assemble_align (DECL_ALIGN (decl)); ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.cold_section_label); @@ -1575,18 +1603,9 @@ assemble_start_function (tree decl, const char *fnname) hot_label_written = true; first_function_block_is_cold = true; } - } - else if (DECL_SECTION_NAME (decl)) - { - struct cgraph_node *node = cgraph_get_node (current_function_decl); - /* Calls to function_section rely on first_function_block_is_cold - being accurate. */ - first_function_block_is_cold = (node - && node->frequency - == NODE_FREQUENCY_UNLIKELY_EXECUTED); + in_cold_section_p = first_function_block_is_cold; } - in_cold_section_p = first_function_block_is_cold; /* Switch to the correct text section for the start of the function. */