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: Group static constructors and destructors in specific subsections, take 2


> 
> This caused:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46628

Hi,
this problem is caused by dwarf2out trying to get into cold section to output
starting and ending label.  This is no longer so easy since one needs a
function declaration to get into cold section, otherwise we end up producing
cold section with data section flags.

This patch makes dwarf2out to behave roughly as before by waiting with
switching to the cold section until first function is output.

I think this is just latent problem since multiple cold section will lead to
bad debug info. (wilth -ffunction-sections -fpartition-functions-and-reorder).
How we should handle this case?  Does this patch seems resonable to fix the
regression?

Bootstrapped/regtested x86_64-linux.  My apologizes for the breakage.

Honza

	* dwarf2out.c (dwarf2out_begin_function): Set cold_text_section
	and output cold_text_section_label.
	(dwarf2out_init): Don't do that there.
	(dwarf2out_finish): Handle cold section end label only if cold
	section was used.
Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 167086)
+++ dwarf2out.c	(working copy)
@@ -21674,6 +21674,15 @@ dwarf2out_var_location (rtx loc_note)
 static void
 dwarf2out_begin_function (tree fun)
 {
+  if (flag_reorder_blocks_and_partition && !cold_text_section)
+    {
+      gcc_assert (current_function_decl == fun);
+      cold_text_section = unlikely_text_section ();
+      switch_to_section (cold_text_section);
+      ASM_OUTPUT_LABEL (asm_out_file, cold_text_section_label);
+      switch_to_section (current_function_section ());
+    }
+
   if (function_section (fun) != text_section)
     have_multiple_function_sections = true;
 
@@ -21996,13 +22005,6 @@ dwarf2out_init (const char *filename ATT
 
   switch_to_section (text_section);
   ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
-  if (flag_reorder_blocks_and_partition)
-    {
-      cold_text_section = unlikely_text_section ();
-      switch_to_section (cold_text_section);
-      ASM_OUTPUT_LABEL (asm_out_file, cold_text_section_label);
-    }
-
 }
 
 /* Called before cgraph_optimize starts outputtting functions, variables
@@ -23108,9 +23110,9 @@ dwarf2out_finish (const char *filename)
   /* Output a terminator label for the .text section.  */
   switch_to_section (text_section);
   targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0);
-  if (flag_reorder_blocks_and_partition)
+  if (cold_text_section)
     {
-      switch_to_section (unlikely_text_section ());
+      switch_to_section (cold_text_section);
       targetm.asm_out.internal_label (asm_out_file, COLD_END_LABEL, 0);
     }
 


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