OSDN Git Service

* config/ia64/ia64.c: Fix a comment typo.
[pf3gnuchains/gcc-fork.git] / gcc / dwarf2out.c
index b750ff8..f78f860 100644 (file)
@@ -175,16 +175,17 @@ default_eh_frame_section (void)
 static GTY(()) varray_type used_rtx_varray;
 
 /* A pointer to the base of a list of incomplete types which might be
-   completed at some later time.  incomplete_types_list needs to be a VARRAY
-   because we want to tell the garbage collector about it.  */
-static GTY(()) varray_type incomplete_types;
+   completed at some later time.  incomplete_types_list needs to be a
+   VEC(tree,gc) because we want to tell the garbage collector about
+   it.  */
+static GTY(()) VEC(tree,gc) *incomplete_types;
 
 /* A pointer to the base of a table of references to declaration
    scopes.  This table is a display which tracks the nesting
    of declaration scopes at the current scope and containing
    scopes.  This table is used to find the proper place to
    define type declaration DIE's.  */
-static GTY(()) varray_type decl_scope_table;
+static GTY(()) VEC(tree,gc) *decl_scope_table;
 
 /* How to start an assembler comment.  */
 #ifndef ASM_COMMENT_START
@@ -1482,7 +1483,7 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
   src = SET_SRC (expr);
   dest = SET_DEST (expr);
 
-  if (GET_CODE (src) == REG)
+  if (REG_P (src))
     {
       rtx rsi = reg_saved_in (src);
       if (rsi)
@@ -4122,6 +4123,9 @@ static int maybe_emit_file (int);
 #ifndef TEXT_SECTION_LABEL
 #define TEXT_SECTION_LABEL             "Ltext"
 #endif
+#ifndef COLD_TEXT_SECTION_LABEL
+#define COLD_TEXT_SECTION_LABEL         "Ltext_cold"
+#endif
 #ifndef DEBUG_LINE_SECTION_LABEL
 #define DEBUG_LINE_SECTION_LABEL       "Ldebug_line"
 #endif
@@ -4149,6 +4153,8 @@ static int maybe_emit_file (int);
 
 static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
 static char text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char cold_text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char cold_end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 
 static char abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
 static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
 static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
@@ -4159,6 +4165,9 @@ static char ranges_section_label[2 * MAX_ARTIFICIAL_LABEL_BYTES];
 #ifndef TEXT_END_LABEL
 #define TEXT_END_LABEL         "Letext"
 #endif
+#ifndef COLD_END_LABEL
+#define COLD_END_LABEL          "Letext_cold"
+#endif
 #ifndef BLOCK_BEGIN_LABEL
 #define BLOCK_BEGIN_LABEL      "LBB"
 #endif
@@ -6800,12 +6809,15 @@ dwarf2out_switch_text_section (void)
 {
   dw_fde_ref fde;
 
+  if (!cfun)
+    internal_error ("Attempt to switch text sections without any code.");
+
   fde = &fde_table[fde_table_in_use - 1];
   fde->dw_fde_switched_sections = true;
-  fde->dw_fde_hot_section_label = xstrdup (hot_section_label);
-  fde->dw_fde_hot_section_end_label = xstrdup (hot_section_end_label);
-  fde->dw_fde_unlikely_section_label = xstrdup (unlikely_section_label);
-  fde->dw_fde_unlikely_section_end_label = xstrdup (cold_section_end_label);
+  fde->dw_fde_hot_section_label = cfun->hot_section_label;
+  fde->dw_fde_hot_section_end_label = cfun->hot_section_end_label;
+  fde->dw_fde_unlikely_section_label = cfun->cold_section_label;
+  fde->dw_fde_unlikely_section_end_label = cfun->cold_section_end_label;
   separate_line_info_table_in_use++;
 }
 
@@ -7235,14 +7247,15 @@ output_aranges (void)
     }
 
   dw2_asm_output_addr (DWARF2_ADDR_SIZE, text_section_label, "Address");
-  if (last_text_section == in_unlikely_executed_text
-      || (last_text_section == in_named
-         && last_text_section_name == unlikely_text_section_name))
-    dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label,
-                         unlikely_section_label, "Length");
-  else
-    dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label,
-                         text_section_label, "Length");
+  dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label,
+                       text_section_label, "Length");
+  if (flag_reorder_blocks_and_partition)
+    {
+      dw2_asm_output_addr (DWARF2_ADDR_SIZE, cold_text_section_label, 
+                          "Address");
+      dw2_asm_output_delta (DWARF2_ADDR_SIZE, cold_end_label,
+                           cold_text_section_label, "Length");
+    }
 
   for (i = 0; i < arange_table_in_use; i++)
     {
@@ -7332,24 +7345,11 @@ output_ranges (void)
             base of the text section.  */
          if (separate_line_info_table_in_use == 0)
            {
-             if (last_text_section == in_unlikely_executed_text
-                 || (last_text_section == in_named
-                     && last_text_section_name == unlikely_text_section_name))
-               {
-                 dw2_asm_output_delta (DWARF2_ADDR_SIZE, blabel,
-                                       unlikely_section_label,
-                                       fmt, i * 2 * DWARF2_ADDR_SIZE);
-                 dw2_asm_output_delta (DWARF2_ADDR_SIZE, elabel,
-                                       unlikely_section_label, NULL);
-               }
-             else
-               {
-                 dw2_asm_output_delta (DWARF2_ADDR_SIZE, blabel,
-                                       text_section_label,
-                                       fmt, i * 2 * DWARF2_ADDR_SIZE);
-                 dw2_asm_output_delta (DWARF2_ADDR_SIZE, elabel,
-                                       text_section_label, NULL);
-               }
+             dw2_asm_output_delta (DWARF2_ADDR_SIZE, blabel,
+                                   text_section_label,
+                                   fmt, i * 2 * DWARF2_ADDR_SIZE);
+             dw2_asm_output_delta (DWARF2_ADDR_SIZE, elabel,
+                                   text_section_label, NULL);
            }
 
          /* Otherwise, we add a DW_AT_entry_pc attribute to force the
@@ -7734,11 +7734,12 @@ output_line_info (void)
      a series of state machine operations.  */
   current_file = 1;
   current_line = 1;
-  
-  if (last_text_section == in_unlikely_executed_text
-      || (last_text_section == in_named
-         && last_text_section_name == unlikely_text_section_name))
-    strcpy (prev_line_label, unlikely_section_label);
+
+  if (cfun
+      && (last_text_section == in_unlikely_executed_text
+         || (last_text_section == in_named
+             && last_text_section_name == cfun->unlikely_text_section_name)))
+    strcpy (prev_line_label, cfun->cold_section_label);
   else
     strcpy (prev_line_label, text_section_label);
   for (lt_index = 1; lt_index < line_info_table_in_use; ++lt_index)
@@ -9283,7 +9284,7 @@ loc_descriptor_from_tree_1 (tree loc, int want_address)
 
 #ifdef ENABLE_CHECKING
       /* Otherwise this is a generic code; we should just lists all of
-        these explicitly.  Aborting means we forgot one.  */
+        these explicitly.  We forgot one.  */
       gcc_unreachable ();
 #else
       /* In a release build, we want to degrade gracefully: better to
@@ -10112,7 +10113,6 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl,
       dw_loc_list_ref list;
       rtx varloc;
 
-
       /* We need to figure out what section we should use as the base
         for the address ranges where a given location is valid.
         1. If this particular DECL has a section associated with it,
@@ -10134,10 +10134,12 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl,
          tree sectree = DECL_SECTION_NAME (current_function_decl);
          secname = TREE_STRING_POINTER (sectree);
        }
-      else if (last_text_section == in_unlikely_executed_text
-              || (last_text_section == in_named
-                  && last_text_section_name == unlikely_text_section_name))
-       secname = unlikely_section_label;
+      else if (cfun
+              && (last_text_section == in_unlikely_executed_text
+                  || (last_text_section == in_named
+                      && last_text_section_name == 
+                      cfun->unlikely_text_section_name)))
+       secname = cfun->cold_section_label;
       else
        secname = text_section_label;
 
@@ -10583,7 +10585,7 @@ add_abstract_origin_attribute (dw_die_ref die, tree origin)
      trees (in the case of java, they simply have no block tree, in some other
      languages).  For these functions, there is nothing we can really do to
      output correct debug info for inlined functions in all cases.  Rather
-     than abort, we'll just produce deficient debug info now, in that we will
+     than die, we'll just produce deficient debug info now, in that we will
      have variables without a proper abstract origin.  In the future, when all
      functions are lowered, we should re-add a gcc_assert (origin_die)
      here.  */
@@ -10666,7 +10668,7 @@ add_name_and_src_coords_attributes (dw_die_ref die, tree decl)
 static void
 push_decl_scope (tree scope)
 {
-  VARRAY_PUSH_TREE (decl_scope_table, scope);
+  VEC_safe_push (tree, gc, decl_scope_table, scope);
 }
 
 /* Pop a declaration scope.  */
@@ -10674,9 +10676,7 @@ push_decl_scope (tree scope)
 static inline void
 pop_decl_scope (void)
 {
-  gcc_assert (VARRAY_ACTIVE_SIZE (decl_scope_table) > 0);
-
-  VARRAY_POP (decl_scope_table);
+  VEC_pop (tree, decl_scope_table);
 }
 
 /* Return the DIE for the scope that immediately contains this type.
@@ -10719,8 +10719,8 @@ scope_die_for (tree t, dw_die_ref context_die)
       /* For types, we can just look up the appropriate DIE.  But
         first we check to see if we're in the middle of emitting it
         so we know where the new DIE should go.  */
-      for (i = VARRAY_ACTIVE_SIZE (decl_scope_table) - 1; i >= 0; --i)
-       if (VARRAY_TREE (decl_scope_table, i) == containing_scope)
+      for (i = VEC_length (tree, decl_scope_table) - 1; i >= 0; --i)
+       if (VEC_index (tree, decl_scope_table, i) == containing_scope)
          break;
 
       if (i < 0)
@@ -10976,8 +10976,8 @@ retry_incomplete_types (void)
 {
   int i;
 
-  for (i = VARRAY_ACTIVE_SIZE (incomplete_types) - 1; i >= 0; i--)
-    gen_type_die (VARRAY_TREE (incomplete_types, i), comp_unit_die);
+  for (i = VEC_length (tree, incomplete_types) - 1; i >= 0; i--)
+    gen_type_die (VEC_index (tree, incomplete_types, i), comp_unit_die);
 }
 
 /* Generate a DIE to represent an inlined instance of an enumeration type.  */
@@ -11615,8 +11615,13 @@ gen_variable_die (tree decl, dw_die_ref context_die)
      copy decls and set the DECL_ABSTRACT flag on them instead of
      sharing them.
 
-     ??? Duplicated blocks have been rewritten to use .debug_ranges.  */
-  else if (old_die && TREE_STATIC (decl)
+     ??? Duplicated blocks have been rewritten to use .debug_ranges.
+
+     ??? The declare_in_namespace support causes us to get two DIEs for one
+     variable, both of which are declarations.  We want to avoid considering
+     one to be a specification, so we must test that this DIE is not a
+     declaration.  */
+  else if (old_die && TREE_STATIC (decl) && ! declaration
           && get_AT_flag (old_die, DW_AT_declaration) == 1)
     {
       /* This is a definition of a C++ class level static.  */
@@ -11999,7 +12004,7 @@ gen_member_die (tree type, dw_die_ref context_die)
   /* First output info about the base classes.  */
   if (binfo)
     {
-      VEC (tree) *accesses = BINFO_BASE_ACCESSES (binfo);
+      VEC(tree,gc) *accesses = BINFO_BASE_ACCESSES (binfo);
       int i;
       tree base;
 
@@ -12118,7 +12123,7 @@ gen_struct_or_union_type_die (tree type, dw_die_ref context_die)
       /* We don't need to do this for function-local types.  */
       if (TYPE_STUB_DECL (type)
          && ! decl_function_context (TYPE_STUB_DECL (type)))
-       VARRAY_PUSH_TREE (incomplete_types, type);
+       VEC_safe_push (tree, gc, incomplete_types, type);
     }
 }
 
@@ -12535,7 +12540,7 @@ is_redundant_typedef (tree decl)
   return 0;
 }
 
-/* Returns the DIE for decl or aborts.  */
+/* Returns the DIE for decl.  A DIE will always be returned.  */
 
 static dw_die_ref
 force_decl_die (tree decl)
@@ -12588,8 +12593,7 @@ force_decl_die (tree decl)
          gcc_unreachable ();
        }
 
-      /* See if we can find the die for this deci now.
-        If not then abort.  */
+      /* We should be able to find the DIE now.  */
       if (!decl_die)
        decl_die = lookup_decl_die (decl);
       gcc_assert (decl_die);
@@ -12598,7 +12602,7 @@ force_decl_die (tree decl)
   return decl_die;
 }
 
-/* Returns the DIE for decl or aborts.  */
+/* Returns the DIE for TYPE.  A DIE is always returned.  */
 
 static dw_die_ref
 force_type_die (tree type)
@@ -13181,6 +13185,14 @@ lookup_filename (const char *file_name)
   VARRAY_PUSH_CHAR_PTR (file_table, save_file_name);
   VARRAY_PUSH_UINT (file_table_emitted, 0);
 
+  /* If the assembler is emitting the file table, and we aren't eliminating
+     unused debug types, then we must emit .file here.  If we are eliminating
+     unused debug types, then this will be done by the maybe_emit_file call in
+     prune_unused_types_walk_attribs.  */
+
+  if (DWARF2_ASM_LINE_DEBUG_INFO && ! flag_eliminate_unused_debug_types)
+    maybe_emit_file (i);
+
   return i;
 }
 
@@ -13256,10 +13268,11 @@ dwarf2out_var_location (rtx loc_note)
   newloc->var_loc_note = loc_note;
   newloc->next = NULL;
 
-  if (last_text_section == in_unlikely_executed_text
-      || (last_text_section == in_named
-         && last_text_section_name == unlikely_text_section_name))
-    newloc->section_label = unlikely_section_label;
+  if (cfun
+      && (last_text_section == in_unlikely_executed_text
+         || (last_text_section == in_named
+             && last_text_section_name == cfun->unlikely_text_section_name)))
+    newloc->section_label = cfun->cold_section_label;
   else
     newloc->section_label = text_section_label;
 
@@ -13464,7 +13477,7 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
                                    decl_loc_table_eq, NULL);
 
   /* Allocate the initial hunk of the decl_scope_table.  */
-  VARRAY_TREE_INIT (decl_scope_table, 256, "decl_scope_table");
+  decl_scope_table = VEC_alloc (tree, gc, 256);
 
   /* Allocate the initial hunk of the abbrev_die_table.  */
   abbrev_die_table = ggc_alloc_cleared (ABBREV_DIE_TABLE_INCREMENT
@@ -13489,7 +13502,7 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
      in this value in dwarf2out_finish.  */
   comp_unit_die = gen_compile_unit_die (NULL);
 
-  VARRAY_TREE_INIT (incomplete_types, 64, "incomplete_types");
+  incomplete_types = VEC_alloc (tree, gc, 64);
 
   VARRAY_RTX_INIT (used_rtx_varray, 32, "used_rtx_varray");
 
@@ -13497,6 +13510,9 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
   ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label,
                               DEBUG_ABBREV_SECTION_LABEL, 0);
   ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
+  ASM_GENERATE_INTERNAL_LABEL (cold_text_section_label, 
+                              COLD_TEXT_SECTION_LABEL, 0);
+  ASM_GENERATE_INTERNAL_LABEL (cold_end_label, COLD_END_LABEL, 0);
 
   ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label,
                               DEBUG_INFO_SECTION_LABEL, 0);
@@ -13521,6 +13537,11 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
 
   text_section ();
   ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
+  if (flag_reorder_blocks_and_partition)
+    {
+      unlikely_text_section ();
+      ASM_OUTPUT_LABEL (asm_out_file, cold_text_section_label);
+    }
 }
 
 /* A helper function for dwarf2out_finish called through
@@ -13852,6 +13873,11 @@ dwarf2out_finish (const char *filename)
   /* Output a terminator label for the .text section.  */
   text_section ();
   targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0);
+  if (flag_reorder_blocks_and_partition)
+    {
+      unlikely_text_section ();
+      targetm.asm_out.internal_label (asm_out_file, COLD_END_LABEL, 0);
+    }
 
   /* Output the source line correspondence table.  We must do this
      even if there is no line information.  Otherwise, on an empty