This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Your hot/cold patch
I made a tiny sub-patch containing just the changes I think are
necessary to check in what you want.
The changelog and patch are below. I only did minimal testing: I
bootstrapped
this patch on an Apple G4 running apple-pc darwin, and on an x86
running Linux.
As soon as you say this is okay I will commit it.
-- Caroline Tice
ctice@apple.com
On Aug 10, 2004, at 11:03 AM, Caroline Tice wrote:
You want me to check in just the changes to those two functions? Not
all the changes in varasm.c?
I can do that if you want, but I want to go over those changes again
to convince myself that they don't depend on something else I've added
to varasm.c that you haven't approved yet...
-- Caroline
On Aug 10, 2004, at 8:55 AM, Mark Mitchell wrote:
Caroline --
I've been looking at:
http://gcc.gnu.org/ml/gcc-patches/2004-07/msg01545.htm
I don't feel qualified to revie w the whole thing. However, the
changes to text_section and assemble_start_function are OK, and I
would like to see them checked in since text_section is presently
broken on some targets due to the extra alignment. Would you please
check in those two bits? Or, if you are not available, I will take
care of that.
Please let me know,
--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com
2004-08-10 Caroline Tice <ctice@apple.com
* varasm.c (unlikely_section_label): New global variable.
(unlikely_text_section_name): New global variable.
(text_section): Remove alignment statement.
(unlikely_text_section): Remove alignment statement; use
unlikely_section_label rather than hard-coded string.
(assemble_start_function): Initialize unlikely_section_label and
unlikely_text_section_name; make sure cold section is properly
aligned at start of function; output unlikely_section_label if
appropriate.
Index: gcc/varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.437
diff -c -3 -p -r1.437 varasm.c
*** gcc/varasm.c 5 Aug 2004 05:51:51 -0000 1.437
--- gcc/varasm.c 10 Aug 2004 19:54:44 -0000
*************** tree last_assemble_variable_decl;
*** 106,111 ****
--- 106,123 ----
bool unlikely_section_label_printed = false;
+ /* The following global variable indicates the label name to be put at
+ the start of the first cold section within each function, when
+ partitioning basic blocks into hot and cold sections. */
+
+ char *unlikely_section_label = NULL;
+
+ /* The following global variable indicates the section name to be used
+ for the current cold section, when partitioning hot and cold basic
+ blocks into separate sections. */
+
+ char *unlikely_text_section_name = NULL;
+
/* RTX_UNCHANGING_P in a MEM can mean it is stored into, for
initialization.
So giving constant the alias set for the type will allow such
initializations to appear to conflict with the load of the
constant. We
*************** text_section (void)
*** 206,212 ****
{
in_section = in_text;
fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
- ASM_OUTPUT_ALIGN (asm_out_file, 2);
}
}
--- 218,223 ----
*************** unlikely_text_section (void)
*** 229,241 ****
if (!unlikely_section_label_printed)
{
! fprintf (asm_out_file, "__%s_unlikely_section:\n",
! current_function_name ());
unlikely_section_label_printed = true;
-
- /* Make sure that we have appropriate alignment for
instructions
- in this section. */
- assemble_align (FUNCTION_BOUNDARY);
}
}
}
--- 240,247 ----
if (!unlikely_section_label_printed)
{
! ASM_OUTPUT_LABEL (asm_out_file, unlikely_section_label);
unlikely_section_label_printed = true;
}
}
}
*************** assemble_start_function (tree decl, cons
*** 1094,1100 ****
--- 1100,1115 ----
{
int align;
+ if (unlikely_text_section_name)
+ free (unlikely_text_section_name);
+
unlikely_section_label_printed = false;
+ unlikely_text_section_name = NULL;
+
+ if (unlikely_section_label)
+ free (unlikely_section_label);
+ unlikely_section_label = xmalloc ((strlen (fnname) + 18) * sizeof
(char));
+ sprintf (unlikely_section_label, "%s_unlikely_section", fnname);
/* The following code does not need preprocessing in the assembler.
*/
*************** assemble_start_function (tree decl, cons
*** 1103,1108 ****
--- 1118,1137 ----
if (CONSTANT_POOL_BEFORE_FUNCTION)
output_constant_pool (fnname, decl);
+ /* Make sure the cold text (code) section is properly aligned. This
+ is necessary here in the case where the function has both hot and
+ cold sections, because we don't want to re-set the alignment
when the
+ section switch happens mid-function. We don't need to set the
hot
+ section alignment here, because code further down in this
function
+ sets the alignment for whichever section comes first, and if
there
+ is a hot section it is guaranteed to be first. */
+
+ if (flag_reorder_blocks_and_partition)
+ {
+ unlikely_text_section ();
+ assemble_align (FUNCTION_BOUNDARY);
+ }
+
resolve_unique_section (decl, 0, flag_function_sections);
function_section (decl);
*************** assemble_start_function (tree decl, cons
*** 1153,1158 ****
--- 1182,1194 ----
/* Standard thing is just output label for the function. */
ASM_OUTPUT_LABEL (asm_out_file, fnname);
#endif /* ASM_DECLARE_FUNCTION_NAME */
+
+ if (in_unlikely_text_section ()
+ && !unlikely_section_label_printed)
+ {
+ ASM_OUTPUT_LABEL (asm_out_file, unlikely_section_label);
+ unlikely_section_label_printed = true;
+ }
}
/* Output assembler code associated with defining the size of the