aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorbernds <>2011-05-03 13:08:36 +0000
committerbernds <>2011-05-03 13:08:36 +0000
commited6d3b2dc43bfefdb68265a8945edfea79909932 (patch)
tree2d807f2a3c1c4b7e1108c8950f4b2d7408be0561 /gcc/varasm.c
parent166a2e3948daa191307937ae9564dec0685765f0 (diff)
* 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.
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c41
1 files changed, 30 insertions, 11 deletions
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. */