Define & use special macros to record the name & size of cold partitions.
authorCaroline Tice <cmtice@google.com>
Thu, 30 Apr 2015 17:49:02 +0000 (10:49 -0700)
committerCaroline Tice <ctice@gcc.gnu.org>
Thu, 30 Apr 2015 17:49:02 +0000 (10:49 -0700)
Define & use special macros to record the name & size of cold
partitions.  (Fix PR 65929).

gcc/ChangeLog

PR 65929
* config/elfos.h (ASM_DECLARE_COLD_FUNCTION_NAME): New macro definition.
(ASM_DECLARE_COLD_FUNCTION_SIZE): New macro definition.
* doc/tm.texi.in (ASM_DECLARE_COLD_FUNCTION_NAME): Document new macro.
(ASM_DECLARE_COLD_FUNCTION_SIZE): Document new macro.
* final.c (final_scan_insn):  Use ASM_DECLARE_COLD_FUNCTION_NAME
instead of ASM_DECLARE_FUNCTION_NAME for cold partition name.
* varasm.c (assemble_end_function):  Use ASM_DECLARE_COLD_FUNCTION_SIZE
instead of ASM_DECLARE_FUNCTION_SIZE for cold partition size.

gcc/testsuite/ChangeLog:

PR  65929
* gcc.dg/tree-prof/cold_partition_label.c:  Only check for cold
partition size on certain targets.

From-SVN: r222643

gcc/ChangeLog
gcc/config/elfos.h
gcc/doc/tm.texi.in
gcc/final.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c
gcc/varasm.c

index 9f5cab0db22d05f2cc81a87e67883dd8f8253b0b..24ca2c2da2bf254ea820a0ebfd82585dcd6c758c 100644 (file)
@@ -1,3 +1,15 @@
+2015-04-30  Caroline Tice  <cmtice@google.com>
+
+        PR 65929
+       * config/elfos.h (ASM_DECLARE_COLD_FUNCTION_NAME): New macro definition.
+       (ASM_DECLARE_COLD_FUNCTION_SIZE): New macro definition.
+       * doc/tm.texi.in (ASM_DECLARE_COLD_FUNCTION_NAME): Document new macro.
+       (ASM_DECLARE_COLD_FUNCTION_SIZE): Document new macro.
+       * final.c (final_scan_insn):  Use ASM_DECLARE_COLD_FUNCTION_NAME
+       instead of ASM_DECLARE_FUNCTION_NAME for cold partition name.
+       * varasm.c (assemble_end_function):  Use ASM_DECLARE_COLD_FUNCTION_SIZE
+       instead of ASM_DECLARE_FUNCTION_SIZE for cold partition size.
+
 2015-04-30  Marek Polacek  <polacek@redhat.com>
 
        * varasm.c (handle_cache_entry): Fix logic.
index c3b9487482fb71e9cd78be7db5e7d3fe934a4c7f..2224961705c737f0401223c71ec03a9fc68edac1 100644 (file)
@@ -284,6 +284,22 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   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 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   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 6ff7aed9293d6aa92060ed24f632bbcbbf6cf846..86809676b39f23e2aaea5f123ded2a7d2dc19f7a 100644 (file)
@@ -5574,6 +5574,34 @@ You may wish to use @code{ASM_OUTPUT_MEASURED_SIZE} in the definition
 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 968e52594b3d0b782f898f2d2a78264e8cb72894..2b9846e881e4b6e34b15e4d29fe184214716756b 100644 (file)
@@ -2235,10 +2235,11 @@ final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
            {
              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 b6697843ae9ab627349c87003802f15d9ef1d97e..00af2c428333767e008dfeb7d8dc9fbe0722f313 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-30  Caroline Tice  <cmtice@google.com>
+
+       PR  65929
+       * gcc.dg/tree-prof/cold_partition_label.c:  Only check for cold
+       partition size on certain targets.
+
 2015-04-30  Renlin Li  <renlin.li@arm.com>
 
        * gcc.target/aarch64/vect-reduc-or_1.c: New.
index 643707f75f851ffc848f3dee5a100bff04105a7d..42a19abafe768927dc7b0d336ffd8873900fa002 100644 (file)
@@ -35,6 +35,6 @@ main (int argc, char *argv[])
   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 c2b35fd9c38f2690dc53e315f0afd5c0014380db..62d516303c21dc0359f5bafb05b06015c7f6285b 100644 (file)
@@ -1864,11 +1864,11 @@ assemble_end_function (tree decl, const char *fnname ATTRIBUTE_UNUSED)
 
       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)