Hi!

dwarf2out_switch_text_section is called even when -g0 or when not generating
dwarf debug info, if we need to handle there unwinding stuff.
But with -g0 e.g. line info tables aren't initialized.  Already a few lines
above this spot we guard it with cold_text_section != NULL, so this patch
just adds the same check to another needed spot.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-01-30  Jakub Jelinek  <ja...@redhat.com>

        PR debug/52027
        * dwarf2out.c (dwarf2out_switch_text_section): Don't call
        set_cur_line_info_table if not emitting debug info.

        * gcc.dg/tree-prof/pr52027.c: New test.

--- gcc/dwarf2out.c.jj  2012-01-26 09:22:21.000000000 +0100
+++ gcc/dwarf2out.c     2012-01-30 12:09:42.186932405 +0100
@@ -1177,7 +1177,8 @@ dwarf2out_switch_text_section (void)
 
   var_location_switch_text_section ();
 
-  set_cur_line_info_table (sect);
+  if (cold_text_section != NULL)
+    set_cur_line_info_table (sect);
 }
 
 /* And now, the subset of the debugging information support code necessary
--- gcc/testsuite/gcc.dg/tree-prof/pr52027.c.jj 2012-01-30 12:14:37.073184372 
+0100
+++ gcc/testsuite/gcc.dg/tree-prof/pr52027.c    2012-01-30 12:15:08.042005858 
+0100
@@ -0,0 +1,19 @@
+/* PR debug/52027 */
+/* { dg-require-effective-target freorder } */
+/* { dg-options "-O -freorder-blocks-and-partition -fno-reorder-functions" } */
+
+void
+foo (int len)
+{
+  char array[1000];
+  __builtin_memset (array, 0, len);
+}
+
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 1000; i++)
+    foo (8);
+  return 0;
+}

        Jakub

Reply via email to