This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: New optimization, partitioning hot/cold basic blocks



On Apr 9, 2004, at 23:31, Andrew Pinski wrote:


On Mar 16, 2004, at 19:42, Caroline Tice wrote:

+ #define SECTION_FORMAT_STRING ".section\t\"%s\"\n\t.align 2\n"

What is this for?



To make sure the correct alignments, "dots", etc. end up being output for whichever architecture
we are on, when writing out the assembly directive for changing between hot/cold sections. Yes, this
*is* necessary. Without it I get bugs on both architectures I've tried this on.

Well since .align is not supported on all targets, I think you should be using ASM_OUTPUT_ALIGN instead. So this part of the patch is wrong for some targets.


Also again some targets do not support .section so this is wrong for most of them,
in fact darwin did not support the attribute section until lately. This is what is
causing the problem on MIPS as O32 ABI does not support .section. Also this will cause
a bootstrap failure on i686-pc-cygwin which also does not support .section or named sections.


You should check targetm.have_named_sections instead and use the old way if false then.
have_named_sections was added back in 2001 by RTH so I think that is why RTH was asking
this question of "what is this for?"


This patch implements my suggestions and I tested on i686-openbsd3.1 which does not support .section.
Plus it removes the unused Target defines which I remove the usage of.


OK after testing on sparc-solaris, i686-pc-linux-gnu, and other targets that are effected?

Thanks,
Andrew Pinski

ChangeLog:

* varasm.c (text_section): Use TEXT_SECTION_ASM_OP and
ASM_OUTPUT_ALIGN instead of SECTION_FORMAT_STRING
and NORMAL_TEXT_SECTION_NAME.
(unlikely_text_section): Check targetm.have_named_sections
instead of TARGET_ASM_NAMED_SECTION and use TEXT_SECTION_ASM_OP
instead of SECTION_FORMAT_STRING.
* config/mips/iris5.h (current_section_name): Add in_unlikely_executed_text
case and move the abort into the switch.
* config/rs6000/sysv4.h (HOT_TEXT_SECTION_NAME): Remove.
(NORMAL_TEXT_SECTION_NAME): Remove.
(UNLIKELY_EXECUTED_TEXT_SECTION_NAME): Remove.
(SECTION_FORMAT_STRING): Remove.
* defaults.h (SECTION_FORMAT_STRING): Remove.
* tm.texi (NORMAL_TEXT_SECTION_NAME): Remove.
(SECTION_FORMAT_STRING): Remove.



Patch: Index: defaults.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/defaults.h,v retrieving revision 1.134 diff -u -d -b -w -u -p -r1.134 defaults.h --- defaults.h 9 Apr 2004 19:57:41 -0000 1.134 +++ defaults.h 10 Apr 2004 20:49:40 -0000 @@ -631,10 +631,6 @@ You Lose! You must define PREFERRED_DEB #define UNLIKELY_EXECUTED_TEXT_SECTION_NAME "text.unlikely" #endif

-#ifndef SECTION_FORMAT_STRING
-#define SECTION_FORMAT_STRING "\t.section\t%s\n\t.align 2\n"
-#endif
-
#ifndef HAS_LONG_COND_BRANCH
#define HAS_LONG_COND_BRANCH 0
#endif
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.419
diff -u -d -b -w -u -p -r1.419 varasm.c
--- varasm.c 9 Apr 2004 19:57:43 -0000 1.419
+++ varasm.c 10 Apr 2004 20:49:42 -0000
@@ -208,7 +208,8 @@ text_section (void)
if (in_section != in_text)
{
in_section = in_text;
- fprintf (asm_out_file, SECTION_FORMAT_STRING, NORMAL_TEXT_SECTION_NAME);
+ ASM_OUTPUT_ALIGN (asm_out_file, 2);
+ fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
}
}


@@ -221,15 +222,15 @@ unlikely_text_section (void)
&& (in_section != in_named
|| strcmp (in_named_name, UNLIKELY_EXECUTED_TEXT_SECTION_NAME) != 0))
{
-#ifdef TARGET_ASM_NAMED_SECTION
-
+ if (targetm.have_named_sections)
named_section (NULL_TREE, UNLIKELY_EXECUTED_TEXT_SECTION_NAME, 0);
-
-#else
+ else
+ {
in_section = in_unlikely_executed_text;
- fprintf (asm_out_file, SECTION_FORMAT_STRING,
- UNLIKELY_EXECUTED_TEXT_SECTION_NAME);
-#endif /* ifdef TARGET_ASM_NAMED_SECTION */
+ ASM_OUTPUT_ALIGN (asm_out_file, 2);
+ fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
+ }
+
if (!unlikely_section_label_printed)
{
fprintf (asm_out_file, "__%s_unlikely_section:\n",
Index: config/mips/iris5.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris5.h,v
retrieving revision 1.29
diff -u -d -b -w -u -p -r1.29 iris5.h
--- config/mips/iris5.h 17 Feb 2004 20:42:53 -0000 1.29
+++ config/mips/iris5.h 10 Apr 2004 20:49:42 -0000
@@ -213,6 +213,7 @@ current_section_name (void) \
switch (in_section) \
{ \
case no_section: return NULL; \
+ case in_unlikely_executed_text: \
case in_text: return ".text"; \
case in_data: return ".data"; \
case in_bss: return ".bss"; \
@@ -223,8 +224,8 @@ current_section_name (void) \
return ".rdata"; \
case in_named: \
return in_named_name; \
+ default: abort(); \
} \
- abort (); \
} \
\
unsigned int \
Index: config/rs6000/sysv4.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/sysv4.h,v
retrieving revision 1.147
diff -u -d -b -w -u -p -r1.147 sysv4.h
--- config/rs6000/sysv4.h 9 Apr 2004 19:57:46 -0000 1.147
+++ config/rs6000/sysv4.h 10 Apr 2004 20:49:42 -0000
@@ -434,11 +434,6 @@ do { \


#define BSS_SECTION_ASM_OP "\t.section\t\".bss\""

-#define HOT_TEXT_SECTION_NAME ".text"
-#define NORMAL_TEXT_SECTION_NAME ".text"
-#define UNLIKELY_EXECUTED_TEXT_SECTION_NAME ".text.unlikely"
-#define SECTION_FORMAT_STRING ".section\t\"%s\"\n\t.align 2\n"
-
 /* Override elfos.h definition.  */
 #undef	INIT_SECTION_ASM_OP
 #define	INIT_SECTION_ASM_OP "\t.section\t\".init\",\"ax\""
Index: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.319
diff -u -d -b -w -u -p -r1.319 tm.texi
--- doc/tm.texi	9 Apr 2004 19:57:47 -0000	1.319
+++ doc/tm.texi	10 Apr 2004 20:49:43 -0000
@@ -5802,13 +5802,6 @@ frequently executed functions of the pro
 a default definition if the target supports named sections.
 @end defmac

-@defmac NORMAL_TEXT_SECTION_NAME
-If defined, a C string constant for the name of the section containing code
-that does not go into the ``unlikely executed text'' partition. This is used
-as part of the optimization that partitions hot and cold basic blocks into
-separate sections in the .o and executable files.
-@end defmac
-
@defmac UNLIKELY_EXECUTED_TEXT_SECTION_NAME
If defined, a C string constant for the name of the section containing unlikely
executed functions in the program.
@@ -5858,12 +5851,6 @@ If defined, a C expression whose value i
containing the assembler operation to identify the following data as
finalization code. If not defined, GCC will assume such a section does
not exist.
-@end defmac
-
-@defmac SECTION_FORMAT_STRING
-If defined, format string used by fprintf to write out the
-text section headers for the hot and cold sections of the
-assembly file, when hot and cold partitioning is being performed.
@end defmac


@defmac CRT_CALL_STATIC_FUNCTION (@var{section_op}, @var{function})


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]