Index: gcc/config/elfos.h =================================================================== --- gcc/config/elfos.h (revision 222635) +++ gcc/config/elfos.h (working copy) @@ -284,6 +284,22 @@ while (0) #endif +/* Write the extra assembler code needed to declare the name of a + cold function partition properly. Some svr4 assemblers need to also + have something extra said about the function's return value. We + allow for that here. */ + +#ifndef ASM_DECLARE_COLD_FUNCTION_NAME +#define ASM_DECLARE_COLD_FUNCTION_NAME(FILE, NAME, DECL) \ + do \ + { \ + ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \ + ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ + ASM_OUTPUT_FUNCTION_LABEL (FILE, NAME, DECL); \ + } \ + while (0) +#endif + /* Write the extra assembler code needed to declare an object properly. */ #ifdef HAVE_GAS_GNU_UNIQUE_OBJECT @@ -358,6 +374,17 @@ while (0) #endif +/* This is how to declare the size of a cold function partition. */ +#ifndef ASM_DECLARE_COLD_FUNCTION_SIZE +#define ASM_DECLARE_COLD_FUNCTION_SIZE(FILE, FNAME, DECL) \ + do \ + { \ + if (!flag_inhibit_size_directive) \ + ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \ + } \ + while (0) +#endif + /* A table of bytes codes used by the ASM_OUTPUT_ASCII and ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table corresponds to a particular byte value [0..255]. For any Index: gcc/doc/tm.texi.in =================================================================== --- gcc/doc/tm.texi.in (revision 222635) +++ gcc/doc/tm.texi.in (working copy) @@ -5574,6 +5574,34 @@ of this macro. @end defmac +@defmac ASM_DECLARE_COLD_FUNCTION_NAME (@var{stream}, @var{name}, @var{decl}) +A C statement (sans semicolon) to output to the stdio stream +@var{stream} any text necessary for declaring the name @var{name} of a +cold function partition which is being defined. This macro is responsible +for outputting the label definition (perhaps using +@code{ASM_OUTPUT_FUNCTION_LABEL}). The argument @var{decl} is the +@code{FUNCTION_DECL} tree node representing the function. + +If this macro is not defined, then the cold partition name is defined in the +usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}). + +You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the definition +of this macro. +@end defmac + +@defmac ASM_DECLARE_COLD_FUNCTION_SIZE (@var{stream}, @var{name}, @var{decl}) +A C statement (sans semicolon) to output to the stdio stream +@var{stream} any text necessary for declaring the size of a cold function +partition which is being defined. The argument @var{name} is the name of the +cold partition of the function. The argument @var{decl} is the +@code{FUNCTION_DECL} tree node representing the function. + +If this macro is not defined, then the partition size is not defined. + +You may wish to use @code{ASM_OUTPUT_MEASURED_SIZE} in the definition +of this macro. +@end defmac + @defmac ASM_DECLARE_OBJECT_NAME (@var{stream}, @var{name}, @var{decl}) A C statement (sans semicolon) to output to the stdio stream @var{stream} any text necessary for declaring the name @var{name} of an Index: gcc/final.c =================================================================== --- gcc/final.c (revision 222635) +++ gcc/final.c (working copy) @@ -2235,10 +2235,11 @@ { cold_function_name = clone_function_name (current_function_decl, "cold"); -#ifdef ASM_DECLARE_FUNCTION_NAME - ASM_DECLARE_FUNCTION_NAME (asm_out_file, - IDENTIFIER_POINTER (cold_function_name), - current_function_decl); +#ifdef ASM_DECLARE_COLD_FUNCTION_NAME + ASM_DECLARE_COLD_FUNCTION_NAME (asm_out_file, + IDENTIFIER_POINTER + (cold_function_name), + current_function_decl); #else ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (cold_function_name)); Index: gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c =================================================================== --- gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c (revision 222635) +++ gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c (working copy) @@ -35,6 +35,6 @@ return 0; } -/* { dg-final-use { scan-assembler "foo\[._\]+cold\[\._\]+0" } } */ -/* { dg-final-use { scan-assembler "size\[ \ta-zA-Z0-0\]+foo\[._\]+cold\[\._\]+0" } } */ +/* { dg-final-use { scan-assembler "foo\[._\]+cold\[\._\]+0" { target *-*-linux* *-*-gnu* } } } */ +/* { dg-final-use { scan-assembler "size\[ \ta-zA-Z0-0\]+foo\[._\]+cold\[\._\]+0" { target *-*-linux* *-*-gnu* } } } */ /* { dg-final-use { cleanup-saved-temps } } */ Index: gcc/varasm.c =================================================================== --- gcc/varasm.c (revision 222635) +++ gcc/varasm.c (working copy) @@ -1864,11 +1864,11 @@ save_text_section = in_section; switch_to_section (unlikely_text_section ()); -#ifdef ASM_DECLARE_FUNCTION_SIZE +#ifdef ASM_DECLARE_COLD_FUNCTION_SIZE if (cold_function_name != NULL_TREE) - ASM_DECLARE_FUNCTION_SIZE (asm_out_file, - IDENTIFIER_POINTER (cold_function_name), - decl); + ASM_DECLARE_COLD_FUNCTION_SIZE (asm_out_file, + IDENTIFIER_POINTER (cold_function_name), + decl); #endif ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.cold_section_end_label); if (first_function_block_is_cold)