From 2ae367c1e7081c2ec9a47267551d197002e79b23 Mon Sep 17 00:00:00 2001 From: Sriraman Tallam Date: Tue, 19 Nov 2013 22:12:21 +0000 Subject: [PATCH] Emit a label for the split cold function part. Emit a label for the split cold function part. Label name is formed by suffixing the original function name with "cold". Patch tested for bootstrap on all default languages on x86_64 and regression testsuite checked for parity with RUNTESTFLAGS -m32 and m64. From-SVN: r205057 --- gcc/ChangeLog | 6 ++++ gcc/final.c | 9 +++++ gcc/testsuite/ChangeLog | 4 +++ .../gcc.dg/tree-prof/cold_partition_label.c | 36 +++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f06ccfbd8adc..9c79ee9e6784 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-11-19 Sriraman Tallam + + * final.c (final_scan_insn): Emit a label for the split + cold function part. Label name is formed by suffixing + the original function name with "cold". + 2013-11-19 David Malcolm * basic-block.h (ENTRY_BLOCK_PTR_FOR_FUNCTION): Rename macro to... diff --git a/gcc/final.c b/gcc/final.c index f2adde969751..2ab6a4df3e39 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -2168,6 +2168,15 @@ final_scan_insn (rtx insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, targetm.asm_out.function_switched_text_sections (asm_out_file, current_function_decl, in_cold_section_p); + /* Emit a label for the split cold section. Form label name by + suffixing "cold" to the original function's name. */ + if (in_cold_section_p) + { + tree cold_function_name + = clone_function_name (current_function_decl, "cold"); + ASM_OUTPUT_LABEL (asm_out_file, + IDENTIFIER_POINTER (cold_function_name)); + } break; case NOTE_INSN_BASIC_BLOCK: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7235aaf8a31b..190b2c4deafe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-11-19 Sriraman Tallam + + * gcc.dg/tree-prof/cold_partition_label.c: New testcase. + 2013-11-19 Ulrich Weigand * gcc.target/powerpc/ppc64-abi-2.c (MAKE_SLOT): New macro to diff --git a/gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c b/gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c new file mode 100644 index 000000000000..9dc75668e8da --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c @@ -0,0 +1,36 @@ +/* Test case to check if function foo gets split and the cold function + gets a label. */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -freorder-blocks-and-partition --save-temps" } */ + +#define SIZE 10000 + +const char *sarr[SIZE]; +const char *buf_hot; +const char *buf_cold; + +__attribute__((noinline)) +void +foo (int path) +{ + int i; + if (path) + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_hot; + } + else + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_cold; + } +} + +int +main (int argc, char *argv[]) +{ + buf_hot = "hello"; + buf_cold = "world"; + foo (argc); + return 0; +} -- 2.47.3