OSDN Git Service

* g++.dg/init/new1.C, g++.dg/template/alignof1.C,
[pf3gnuchains/gcc-fork.git] / gcc / dwarf2out.c
index 80f16db..c931420 100644 (file)
@@ -1,5 +1,5 @@
 /* Output Dwarf2 format symbol table information from the GNU C compiler.
-   Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Contributed by Gary Funck (gary@intrepid.com).
    Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com).
@@ -36,8 +36,11 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #include "config.h"
 #include "system.h"
+#include "coretypes.h"
+#include "tm.h"
 #include "tree.h"
 #include "flags.h"
+#include "real.h"
 #include "rtl.h"
 #include "hard-reg-set.h"
 #include "regs.h"
@@ -61,6 +64,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "target.h"
 #include "langhooks.h"
 #include "hashtable.h"
+#include "hashtab.h"
 
 #ifdef DWARF2_DEBUGGING_INFO
 static void dwarf2out_source_line      PARAMS ((unsigned int, const char *));
@@ -91,6 +95,7 @@ int
 dwarf2out_do_frame ()
 {
   return (write_symbols == DWARF2_DEBUG
+         || write_symbols == VMS_AND_DWARF2_DEBUG
 #ifdef DWARF2_FRAME_INFO
          || DWARF2_FRAME_INFO
 #endif
@@ -101,13 +106,6 @@ dwarf2out_do_frame ()
          );
 }
 
-/* The number of the current function definition for which debugging
-   information is being generated.  These numbers range from 1 up to the
-   maximum number of function definitions contained within the current
-   compilation unit.  These numbers are used to create unique label id's
-   unique to each function definition.  */
-unsigned current_funcdef_number = 0;
-
 /* The size of the target's pointer type.  */
 #ifndef PTR_SIZE
 #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
@@ -121,17 +119,50 @@ void
 default_eh_frame_section ()
 {
 #ifdef EH_FRAME_SECTION_NAME
+#ifdef HAVE_LD_RO_RW_SECTION_MIXING
+  int fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0);
+  int per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
+  int lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
+  int flags;
+
+  flags = (! flag_pic
+          || ((fde_encoding & 0x70) != DW_EH_PE_absptr
+              && (fde_encoding & 0x70) != DW_EH_PE_aligned
+              && (per_encoding & 0x70) != DW_EH_PE_absptr
+              && (per_encoding & 0x70) != DW_EH_PE_aligned
+              && (lsda_encoding & 0x70) != DW_EH_PE_absptr
+              && (lsda_encoding & 0x70) != DW_EH_PE_aligned))
+         ? 0 : SECTION_WRITE;
+  named_section_flags (EH_FRAME_SECTION_NAME, flags);
+#else
   named_section_flags (EH_FRAME_SECTION_NAME, SECTION_WRITE);
+#endif
 #else
   tree label = get_file_function_name ('F');
 
   data_section ();
   ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
-  ASM_GLOBALIZE_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
+  (*targetm.asm_out.globalize_label) (asm_out_file, IDENTIFIER_POINTER (label));
   ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
 #endif
 }
 
+/* Array of RTXes referenced by the debugging information, which therefore
+   must be kept around forever.  */
+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;
+
+/* 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;
+
 #if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
 
 /* How to start an assembler comment.  */
@@ -192,6 +223,7 @@ typedef struct dw_fde_struct
   const char *dw_fde_end;
   dw_cfi_ref dw_fde_cfi;
   unsigned funcdef_number;
+  unsigned all_throwers_are_sibcalls : 1;
   unsigned nothrow : 1;
   unsigned uses_eh_lsda : 1;
 }
@@ -231,7 +263,7 @@ dw_fde_node;
 #else
 #define DWARF_CIE_DATA_ALIGNMENT ((int) UNITS_PER_WORD)
 #endif
-#endif /* not DWARF_CIE_DATA_ALIGNMENT */
+#endif
 
 /* A pointer to the base of a table that contains frame description
    information for each routine.  */
@@ -273,7 +305,8 @@ static const char *dwarf_cfi_name   PARAMS ((unsigned));
 static dw_cfi_ref new_cfi              PARAMS ((void));
 static void add_cfi                    PARAMS ((dw_cfi_ref *, dw_cfi_ref));
 static void add_fde_cfi                        PARAMS ((const char *, dw_cfi_ref));
-static void lookup_cfa_1               PARAMS ((dw_cfi_ref, dw_cfa_location *));
+static void lookup_cfa_1               PARAMS ((dw_cfi_ref,
+                                                dw_cfa_location *));
 static void lookup_cfa                 PARAMS ((dw_cfa_location *));
 static void reg_save                   PARAMS ((const char *, unsigned,
                                                 unsigned, long));
@@ -293,12 +326,8 @@ static void get_cfa_from_loc_descr         PARAMS ((dw_cfa_location *,
                                                struct dw_loc_descr_struct *));
 static struct dw_loc_descr_struct *build_cfa_loc
                                        PARAMS ((dw_cfa_location *));
-static void def_cfa_1                  PARAMS ((const char *, dw_cfa_location *));
-
-/* .debug_str support.  */
-static hashnode indirect_string_alloc  PARAMS ((hash_table *));
-static int output_indirect_string      PARAMS ((struct cpp_reader *,
-                                                hashnode, const PTR));
+static void def_cfa_1                  PARAMS ((const char *,
+                                                dw_cfa_location *));
 
 /* How to start an assembler comment.  */
 #ifndef ASM_COMMENT_START
@@ -309,11 +338,6 @@ static int output_indirect_string  PARAMS ((struct cpp_reader *,
 #define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4)
 #define DW_FORM_ref (DWARF_OFFSET_SIZE == 8 ? DW_FORM_ref8 : DW_FORM_ref4)
 
-/* Pseudo-op for defining a new section.  */
-#ifndef SECTION_ASM_OP
-#define SECTION_ASM_OP "\t.section\t"
-#endif
-
 #ifndef DEBUG_FRAME_SECTION
 #define DEBUG_FRAME_SECTION    ".debug_frame"
 #endif
@@ -321,41 +345,23 @@ static int output_indirect_string PARAMS ((struct cpp_reader *,
 #ifndef FUNC_BEGIN_LABEL
 #define FUNC_BEGIN_LABEL       "LFB"
 #endif
+
 #ifndef FUNC_END_LABEL
 #define FUNC_END_LABEL         "LFE"
 #endif
+
 #define FRAME_BEGIN_LABEL      "Lframe"
 #define CIE_AFTER_SIZE_LABEL   "LSCIE"
 #define CIE_END_LABEL          "LECIE"
-#define CIE_LENGTH_LABEL       "LLCIE"
 #define FDE_LABEL              "LSFDE"
 #define FDE_AFTER_SIZE_LABEL   "LASFDE"
 #define FDE_END_LABEL          "LEFDE"
-#define FDE_LENGTH_LABEL       "LLFDE"
 #define LINE_NUMBER_BEGIN_LABEL        "LSLT"
 #define LINE_NUMBER_END_LABEL  "LELT"
 #define LN_PROLOG_AS_LABEL     "LASLTP"
 #define LN_PROLOG_END_LABEL    "LELTP"
 #define DIE_LABEL_PREFIX       "DW"
 
-/* Definitions of defaults for various types of primitive assembly language
-   output operations.  These may be overridden from within the tm.h file,
-   but typically, that is unnecessary.  */
-
-#ifdef SET_ASM_OP
-#ifndef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
-#define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO)            \
- do {                                                                  \
-  fprintf (FILE, "%s", SET_ASM_OP);                                    \
-  assemble_name (FILE, SY);                                            \
-  fputc (',', FILE);                                                   \
-  assemble_name (FILE, HI);                                            \
-  fputc ('-', FILE);                                                   \
-  assemble_name (FILE, LO);                                            \
- } while (0)
-#endif
-#endif /* SET_ASM_OP */
-
 /* The DWARF 2 CFA column which tracks the return address.  Normally this
    is the column for PC, or the first column after all of the hard
    registers.  */
@@ -373,6 +379,12 @@ static int output_indirect_string  PARAMS ((struct cpp_reader *,
 #define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
 #endif
 
+/* The offset from the incoming value of %sp to the top of the stack frame
+   for the current function.  */
+#ifndef INCOMING_FRAME_SP_OFFSET
+#define INCOMING_FRAME_SP_OFFSET 0
+#endif
+\f
 /* Hook used by __throw.  */
 
 rtx
@@ -381,12 +393,6 @@ expand_builtin_dwarf_fp_regnum ()
   return GEN_INT (DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM));
 }
 
-/* The offset from the incoming value of %sp to the top of the stack frame
-   for the current function.  */
-#ifndef INCOMING_FRAME_SP_OFFSET
-#define INCOMING_FRAME_SP_OFFSET 0
-#endif
-\f
 /* Return a pointer to a copy of the section string name S with all
    attributes stripped off, and an asterisk prepended (for assemble_name).  */
 
@@ -415,18 +421,19 @@ expand_builtin_init_dwarf_reg_sizes (address)
   int i;
   enum machine_mode mode = TYPE_MODE (char_type_node);
   rtx addr = expand_expr (address, NULL_RTX, VOIDmode, 0);
-  rtx mem = gen_rtx_MEM (mode, addr);
+  rtx mem = gen_rtx_MEM (BLKmode, addr);
 
-  for (i = 0; i < DWARF_FRAME_REGISTERS; ++i)
-    {
-      int offset = DWARF_FRAME_REGNUM (i) * GET_MODE_SIZE (mode);
-      int size = GET_MODE_SIZE (reg_raw_mode[i]);
+  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+    if (DWARF_FRAME_REGNUM (i) < DWARF_FRAME_REGISTERS)
+      {
+       HOST_WIDE_INT offset = DWARF_FRAME_REGNUM (i) * GET_MODE_SIZE (mode);
+       HOST_WIDE_INT size = GET_MODE_SIZE (reg_raw_mode[i]);
 
-      if (offset < 0)
-       continue;
+       if (offset < 0)
+         continue;
 
-      emit_move_insn (adjust_address (mem, mode, offset), GEN_INT (size));
-    }
+       emit_move_insn (adjust_address (mem, mode, offset), GEN_INT (size));
+      }
 }
 
 /* Convert a DWARF call frame info. operation to its string name */
@@ -473,8 +480,18 @@ dwarf_cfi_name (cfi_opc)
       return "DW_CFA_def_cfa_register";
     case DW_CFA_def_cfa_offset:
       return "DW_CFA_def_cfa_offset";
+
+    /* DWARF 3 */
     case DW_CFA_def_cfa_expression:
       return "DW_CFA_def_cfa_expression";
+    case DW_CFA_expression:
+      return "DW_CFA_expression";
+    case DW_CFA_offset_extended_sf:
+      return "DW_CFA_offset_extended_sf";
+    case DW_CFA_def_cfa_sf:
+      return "DW_CFA_def_cfa_sf";
+    case DW_CFA_def_cfa_offset_sf:
+      return "DW_CFA_def_cfa_offset_sf";
 
     /* SGI/MIPS specific */
     case DW_CFA_MIPS_advance_loc8:
@@ -533,7 +550,6 @@ dwarf2out_cfi_label ()
 
   ASM_GENERATE_INTERNAL_LABEL (label, "LCFI", label_num++);
   ASM_OUTPUT_LABEL (asm_out_file, label);
-
   return label;
 }
 
@@ -657,6 +673,7 @@ dwarf2out_def_cfa (label, reg, offset)
 
 /* This routine does the actual work.  The CFA is now calculated from
    the dw_cfa_location structure.  */
+
 static void
 def_cfa_1 (label, loc_p)
      const char *label;
@@ -674,15 +691,11 @@ def_cfa_1 (label, loc_p)
   loc.reg = DWARF_FRAME_REGNUM (loc.reg);
   lookup_cfa (&old_cfa);
 
-  if (loc.reg == old_cfa.reg && loc.offset == old_cfa.offset &&
-      loc.indirect == old_cfa.indirect)
-    {
-      if (loc.indirect == 0
-         || loc.base_offset == old_cfa.base_offset)
-       /* Nothing changed so no need to issue any call frame
-           instructions.  */
-       return;
-    }
+  /* If nothing changed, no need to issue any call frame instructions.  */
+  if (loc.reg == old_cfa.reg && loc.offset == old_cfa.offset
+      && loc.indirect == old_cfa.indirect
+      && (loc.indirect == 0 || loc.base_offset == old_cfa.base_offset))
+    return;
 
   cfi = new_cfi ();
 
@@ -722,6 +735,7 @@ def_cfa_1 (label, loc_p)
         calculate the CFA using a full location expression since no
         register-offset pair is available.  */
       struct dw_loc_descr_struct *loc_list;
+
       cfi->dw_cfi_opc = DW_CFA_def_cfa_expression;
       loc_list = build_cfa_loc (&loc);
       cfi->dw_cfi_oprnd1.dw_cfi_loc = loc_list;
@@ -771,10 +785,8 @@ reg_save (label, reg, sreg, offset)
 #endif
       offset /= DWARF_CIE_DATA_ALIGNMENT;
       if (offset < 0)
-       {
-         cfi->dw_cfi_opc = DW_CFA_GNU_negative_offset_extended;
-         offset = -offset;
-       }
+       cfi->dw_cfi_opc = DW_CFA_offset_extended_sf;
+
       cfi->dw_cfi_oprnd2.dw_cfi_offset = offset;
     }
   else if (sreg == reg)
@@ -801,6 +813,7 @@ dwarf2out_window_save (label)
      const char *label;
 {
   dw_cfi_ref cfi = new_cfi ();
+
   cfi->dw_cfi_opc = DW_CFA_GNU_window_save;
   add_fde_cfi (label, cfi);
 }
@@ -817,6 +830,7 @@ dwarf2out_args_size (label, size)
 
   if (size == old_args_size)
     return;
+
   old_args_size = size;
 
   cfi = new_cfi ();
@@ -867,7 +881,7 @@ initial_return_save (rtl)
      rtx rtl;
 {
   unsigned int reg = (unsigned int) -1;
-  long offset = 0;
+  HOST_WIDE_INT offset = 0;
 
   switch (GET_CODE (rtl))
     {
@@ -875,6 +889,7 @@ initial_return_save (rtl)
       /* RA is in a register.  */
       reg = DWARF_FRAME_REGNUM (REGNO (rtl));
       break;
+
     case MEM:
       /* RA is on the stack.  */
       rtl = XEXP (rtl, 0);
@@ -885,20 +900,25 @@ initial_return_save (rtl)
            abort ();
          offset = 0;
          break;
+
        case PLUS:
          if (REGNO (XEXP (rtl, 0)) != STACK_POINTER_REGNUM)
            abort ();
          offset = INTVAL (XEXP (rtl, 1));
          break;
+
        case MINUS:
          if (REGNO (XEXP (rtl, 0)) != STACK_POINTER_REGNUM)
            abort ();
          offset = -INTVAL (XEXP (rtl, 1));
          break;
+
        default:
          abort ();
        }
+
       break;
+
     case PLUS:
       /* The return address is at some offset from any value we can
         actually load.  For instance, on the SPARC it is in %i7+8. Just
@@ -907,6 +927,7 @@ initial_return_save (rtl)
        abort ();
       initial_return_save (XEXP (rtl, 0));
       return;
+
     default:
       abort ();
     }
@@ -919,11 +940,11 @@ initial_return_save (rtl)
 
 static long
 stack_adjust_offset (pattern)
-  rtx pattern;
+     rtx pattern;
 {
   rtx src = SET_SRC (pattern);
   rtx dest = SET_DEST (pattern);
-  long offset = 0;
+  HOST_WIDE_INT offset = 0;
   enum rtx_code code;
 
   if (dest == stack_pointer_rtx)
@@ -936,6 +957,8 @@ stack_adjust_offset (pattern)
        return 0;
 
       offset = INTVAL (XEXP (src, 1));
+      if (code == PLUS)
+       offset = -offset;
     }
   else if (GET_CODE (dest) == MEM)
     {
@@ -943,28 +966,47 @@ stack_adjust_offset (pattern)
       src = XEXP (dest, 0);
       code = GET_CODE (src);
 
-      if (! (code == PRE_DEC || code == PRE_INC
-            || code == PRE_MODIFY)
-         || XEXP (src, 0) != stack_pointer_rtx)
-       return 0;
-
-      if (code == PRE_MODIFY)
+      switch (code)
        {
-         rtx val = XEXP (XEXP (src, 1), 1);
-         /* We handle only adjustments by constant amount.  */
-         if (GET_CODE (XEXP (src, 1)) != PLUS ||
-             GET_CODE (val) != CONST_INT)
-           abort();
-         offset = -INTVAL (val);
+       case PRE_MODIFY:
+       case POST_MODIFY:
+         if (XEXP (src, 0) == stack_pointer_rtx)
+           {
+             rtx val = XEXP (XEXP (src, 1), 1);
+             /* We handle only adjustments by constant amount.  */
+             if (GET_CODE (XEXP (src, 1)) != PLUS ||
+                 GET_CODE (val) != CONST_INT)
+               abort ();
+             offset = -INTVAL (val);
+             break;
+           }
+         return 0;
+
+       case PRE_DEC:
+       case POST_DEC:
+         if (XEXP (src, 0) == stack_pointer_rtx)
+           {
+             offset = GET_MODE_SIZE (GET_MODE (dest));
+             break;
+           }
+         return 0;
+
+       case PRE_INC:
+       case POST_INC:
+         if (XEXP (src, 0) == stack_pointer_rtx)
+           {
+             offset = -GET_MODE_SIZE (GET_MODE (dest));
+             break;
+           }
+         return 0;
+
+       default:
+         return 0;
        }
-      else offset = GET_MODE_SIZE (GET_MODE (dest));
     }
   else
     return 0;
 
-  if (code == PLUS || code == PRE_INC)
-    offset = -offset;
-
   return offset;
 }
 
@@ -976,14 +1018,13 @@ static void
 dwarf2out_stack_adjust (insn)
      rtx insn;
 {
-  long offset;
+  HOST_WIDE_INT offset;
   const char *label;
+  int i;
 
-  if (!flag_asynchronous_unwind_tables
-      && GET_CODE (insn) == CALL_INSN)
+  if (!flag_asynchronous_unwind_tables && GET_CODE (insn) == CALL_INSN)
     {
       /* Extract the size of the args from the CALL rtx itself.  */
-
       insn = PATTERN (insn);
       if (GET_CODE (insn) == PARALLEL)
        insn = XVECEXP (insn, 0, 0);
@@ -991,14 +1032,14 @@ dwarf2out_stack_adjust (insn)
        insn = SET_SRC (insn);
       if (GET_CODE (insn) != CALL)
        abort ();
+
       dwarf2out_args_size ("", INTVAL (XEXP (insn, 1)));
       return;
     }
 
   /* If only calls can throw, and we have a frame pointer,
      save up adjustments until we see the CALL_INSN.  */
-  else if (!flag_asynchronous_unwind_tables
-          && cfa.reg != STACK_POINTER_REGNUM)
+  else if (!flag_asynchronous_unwind_tables && cfa.reg != STACK_POINTER_REGNUM)
     return;
 
   if (GET_CODE (insn) == BARRIER)
@@ -1013,23 +1054,15 @@ dwarf2out_stack_adjust (insn)
 #endif
     }
   else if (GET_CODE (PATTERN (insn)) == SET)
-    {
-      offset = stack_adjust_offset (PATTERN (insn));
-    }
+    offset = stack_adjust_offset (PATTERN (insn));
   else if (GET_CODE (PATTERN (insn)) == PARALLEL
           || GET_CODE (PATTERN (insn)) == SEQUENCE)
     {
       /* There may be stack adjustments inside compound insns.  Search
-         for them.  */
-      int j;
-
-      offset = 0;
-      for (j = XVECLEN (PATTERN (insn), 0) - 1; j >= 0; j--)
-       {
-         rtx pattern = XVECEXP (PATTERN (insn), 0, j);
-         if (GET_CODE (pattern) == SET)
-           offset += stack_adjust_offset (pattern);
-       }
+        for them.  */
+      for (offset = 0, i = XVECLEN (PATTERN (insn), 0) - 1; i >= 0; i--)
+       if (GET_CODE (XVECEXP (PATTERN (insn), 0, i)) == SET)
+         offset += stack_adjust_offset (XVECEXP (PATTERN (insn), 0, i));
     }
   else
     return;
@@ -1043,6 +1076,7 @@ dwarf2out_stack_adjust (insn)
 #ifndef STACK_GROWS_DOWNWARD
   offset = -offset;
 #endif
+
   args_size += offset;
   if (args_size < 0)
     args_size = 0;
@@ -1087,7 +1121,7 @@ flush_queued_reg_saves ()
 {
   struct queued_reg_save *q, *next;
 
-  for (q = queued_reg_saves; q ; q = next)
+  for (q = queued_reg_saves; q; q = next)
     {
       dwarf2out_reg_save (last_reg_save_label, REGNO (q->reg), q->cfa_offset);
       next = q->next;
@@ -1104,13 +1138,13 @@ clobbers_queued_reg_save (insn)
 {
   struct queued_reg_save *q;
 
-  for (q = queued_reg_saves; q ; q = q->next)
+  for (q = queued_reg_saves; q; q = q->next)
     if (modified_in_p (q->reg, insn))
       return true;
 
   return false;
 }
-  
+
 
 /* A temporary register holding an integral value used in adjusting SP
    or setting up the store_reg.  The "offset" field holds the integer
@@ -1146,7 +1180,7 @@ static dw_cfa_location cfa_temp;
   had better be the one we think we're using for this purpose.
 
   Except: If the register being saved is the CFA register, and the
-  offset is non-zero, we are saving the CFA, so we assume we have to
+  offset is nonzero, we are saving the CFA, so we assume we have to
   use DW_CFA_def_cfa_expression.  If the offset is 0, we assume that
   the intent is to save the value of SP from the previous frame.
 
@@ -1161,7 +1195,7 @@ static dw_cfa_location cfa_temp;
               stores the value, which will be used to adjust the
               stack pointer.  cfa_temp is also used like cfa_store,
               to track stores to the stack via fp or a temp reg.
+
   Rules  1- 4: Setting a register's value to cfa.reg or an expression
               with cfa.reg as the first operand changes the cfa.reg and its
               cfa.offset.  Rule 1 and 4 also set cfa_temp.reg and
@@ -1191,7 +1225,8 @@ static dw_cfa_location cfa_temp;
           cfa_temp.offset = cfa.offset
 
   Rule 2:
-  (set sp ({minus,plus,losum} {sp,fp}:cfa.reg {<const_int>,<reg>:cfa_temp.reg}))
+  (set sp ({minus,plus,losum} {sp,fp}:cfa.reg
+                             {<const_int>,<reg>:cfa_temp.reg}))
   effects: cfa.reg = sp if fp used
           cfa.offset += {+/- <const_int>, cfa_temp.offset} if cfa.reg==sp
           cfa_store.offset += {+/- <const_int>, cfa_temp.offset}
@@ -1251,7 +1286,9 @@ static dw_cfa_location cfa_temp;
           cfa.base_offset = -cfa_store.offset
 
   Rule 12:
-  (set (mem ({minus,plus,losum} <reg1>:{cfa_store,cfa_temp} <const_int>)) <reg2>)
+  (set (mem ({minus,plus,losum} <reg1>:{cfa_store,cfa_temp} <const_int>))
+
+       <reg2>)
   effects: cfa.reg = <reg1>
           cfa.base_offset = -/+ <const_int> - {cfa_store,cfa_temp}.offset
 
@@ -1272,28 +1309,24 @@ dwarf2out_frame_debug_expr (expr, label)
      const char *label;
 {
   rtx src, dest;
-  long offset;
+  HOST_WIDE_INT offset;
 
   /* If RTX_FRAME_RELATED_P is set on a PARALLEL, process each member of
      the PARALLEL independently. The first element is always processed if
      it is a SET. This is for backward compatibility.   Other elements
      are processed only if they are SETs and the RTX_FRAME_RELATED_P
      flag is set in them.  */
-
-  if (GET_CODE (expr) == PARALLEL
-      || GET_CODE (expr) == SEQUENCE)
+  if (GET_CODE (expr) == PARALLEL || GET_CODE (expr) == SEQUENCE)
     {
       int par_index;
       int limit = XVECLEN (expr, 0);
 
       for (par_index = 0; par_index < limit; par_index++)
-       {
-         rtx x = XVECEXP (expr, 0, par_index);
+       if (GET_CODE (XVECEXP (expr, 0, par_index)) == SET
+           && (RTX_FRAME_RELATED_P (XVECEXP (expr, 0, par_index))
+               || par_index == 0))
+         dwarf2out_frame_debug_expr (XVECEXP (expr, 0, par_index), label);
 
-         if (GET_CODE (x) == SET &&
-             (RTX_FRAME_RELATED_P (x) || par_index == 0))
-           dwarf2out_frame_debug_expr (x, label);
-       }
       return;
     }
 
@@ -1409,6 +1442,7 @@ dwarf2out_frame_debug_expr (expr, label)
                  cfa_temp.reg = cfa.reg;
                  cfa_temp.offset = cfa.offset;
                }
+
              /* Rule 5 */
              else if (GET_CODE (XEXP (src, 0)) == REG
                       && REGNO (XEXP (src, 0)) == cfa_temp.reg
@@ -1421,6 +1455,7 @@ dwarf2out_frame_debug_expr (expr, label)
                  cfa_store.reg = REGNO (dest);
                  cfa_store.offset = cfa.offset - cfa_temp.offset;
                }
+
              /* Rule 9 */
              else if (GET_CODE (src) == LO_SUM
                       && GET_CODE (XEXP (src, 1)) == CONST_INT)
@@ -1445,6 +1480,7 @@ dwarf2out_frame_debug_expr (expr, label)
              || (unsigned) REGNO (XEXP (src, 0)) != cfa_temp.reg
              || GET_CODE (XEXP (src, 1)) != CONST_INT)
            abort ();
+
          if ((unsigned) REGNO (dest) != cfa_temp.reg)
            cfa_temp.reg = REGNO (dest);
          cfa_temp.offset |= INTVAL (XEXP (src, 1));
@@ -1459,6 +1495,7 @@ dwarf2out_frame_debug_expr (expr, label)
        default:
          abort ();
        }
+
       def_cfa_1 (label, &cfa);
       break;
 
@@ -1475,18 +1512,20 @@ dwarf2out_frame_debug_expr (expr, label)
        case PRE_MODIFY:
          /* We can't handle variable size modifications.  */
          if (GET_CODE (XEXP (XEXP (XEXP (dest, 0), 1), 1)) != CONST_INT)
-           abort();
+           abort ();
          offset = -INTVAL (XEXP (XEXP (XEXP (dest, 0), 1), 1));
 
          if (REGNO (XEXP (XEXP (dest, 0), 0)) != STACK_POINTER_REGNUM
              || cfa_store.reg != STACK_POINTER_REGNUM)
            abort ();
+
          cfa_store.offset += offset;
          if (cfa.reg == STACK_POINTER_REGNUM)
            cfa.offset = cfa_store.offset;
 
          offset = -cfa_store.offset;
          break;
+
          /* Rule 11 */
        case PRE_INC:
        case PRE_DEC:
@@ -1497,6 +1536,7 @@ dwarf2out_frame_debug_expr (expr, label)
          if (REGNO (XEXP (XEXP (dest, 0), 0)) != STACK_POINTER_REGNUM
              || cfa_store.reg != STACK_POINTER_REGNUM)
            abort ();
+
          cfa_store.offset += offset;
          if (cfa.reg == STACK_POINTER_REGNUM)
            cfa.offset = cfa_store.offset;
@@ -1557,7 +1597,6 @@ dwarf2out_frame_debug_expr (expr, label)
              /* If the source register is exactly the CFA, assume
                 we're saving SP like any other register; this happens
                 on the ARM.  */
-
              def_cfa_1 (label, &cfa);
              queue_reg_save (label, stack_pointer_rtx, offset);
              break;
@@ -1566,13 +1605,14 @@ dwarf2out_frame_debug_expr (expr, label)
            {
              /* Otherwise, we'll need to look in the stack to
                  calculate the CFA.  */
-
              rtx x = XEXP (dest, 0);
+
              if (GET_CODE (x) != REG)
                x = XEXP (x, 0);
              if (GET_CODE (x) != REG)
                abort ();
-             cfa.reg = (unsigned) REGNO (x);
+
+             cfa.reg = REGNO (x);
              cfa.base_offset = offset;
              cfa.indirect = 1;
              def_cfa_1 (label, &cfa);
@@ -1609,6 +1649,7 @@ dwarf2out_frame_debug (insn)
       lookup_cfa (&cfa);
       if (cfa.reg != (unsigned long) DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM))
        abort ();
+
       cfa.reg = STACK_POINTER_REGNUM;
       cfa_store = cfa;
       cfa_temp.reg = -1;
@@ -1622,12 +1663,12 @@ dwarf2out_frame_debug (insn)
   if (! RTX_FRAME_RELATED_P (insn))
     {
       if (!ACCUMULATE_OUTGOING_ARGS)
-        dwarf2out_stack_adjust (insn);
+       dwarf2out_stack_adjust (insn);
+
       return;
     }
 
   label = dwarf2out_cfi_label ();
-
   src = find_reg_note (insn, REG_FRAME_RELATED_EXPR, NULL_RTX);
   if (src)
     insn = XEXP (src, 0);
@@ -1646,12 +1687,10 @@ output_cfi (cfi, fde, for_eh)
      int for_eh;
 {
   if (cfi->dw_cfi_opc == DW_CFA_advance_loc)
-    {
-      dw2_asm_output_data (1, (cfi->dw_cfi_opc
-                              | (cfi->dw_cfi_oprnd1.dw_cfi_offset & 0x3f)),
-                          "DW_CFA_advance_loc 0x%lx",
-                          cfi->dw_cfi_oprnd1.dw_cfi_offset);
-    }
+    dw2_asm_output_data (1, (cfi->dw_cfi_opc
+                            | (cfi->dw_cfi_oprnd1.dw_cfi_offset & 0x3f)),
+                        "DW_CFA_advance_loc 0x%lx",
+                        cfi->dw_cfi_oprnd1.dw_cfi_offset);
   else if (cfi->dw_cfi_opc == DW_CFA_offset)
     {
       dw2_asm_output_data (1, (cfi->dw_cfi_opc
@@ -1661,12 +1700,10 @@ output_cfi (cfi, fde, for_eh)
       dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
     }
   else if (cfi->dw_cfi_opc == DW_CFA_restore)
-    {
-      dw2_asm_output_data (1, (cfi->dw_cfi_opc
-                              | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f)),
-                          "DW_CFA_restore, column 0x%lx",
-                          cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-    }
+    dw2_asm_output_data (1, (cfi->dw_cfi_opc
+                            | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f)),
+                        "DW_CFA_restore, column 0x%lx",
+                        cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
   else
     {
       dw2_asm_output_data (1, cfi->dw_cfi_opc,
@@ -1684,51 +1721,81 @@ output_cfi (cfi, fde, for_eh)
            dw2_asm_output_addr (DWARF2_ADDR_SIZE,
                                 cfi->dw_cfi_oprnd1.dw_cfi_addr, NULL);
          break;
+
        case DW_CFA_advance_loc1:
          dw2_asm_output_delta (1, cfi->dw_cfi_oprnd1.dw_cfi_addr,
                                fde->dw_fde_current_label, NULL);
          fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
+
        case DW_CFA_advance_loc2:
          dw2_asm_output_delta (2, cfi->dw_cfi_oprnd1.dw_cfi_addr,
                                fde->dw_fde_current_label, NULL);
          fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
+
        case DW_CFA_advance_loc4:
          dw2_asm_output_delta (4, cfi->dw_cfi_oprnd1.dw_cfi_addr,
                                fde->dw_fde_current_label, NULL);
          fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
+
        case DW_CFA_MIPS_advance_loc8:
          dw2_asm_output_delta (8, cfi->dw_cfi_oprnd1.dw_cfi_addr,
                                fde->dw_fde_current_label, NULL);
          fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
+
        case DW_CFA_offset_extended:
-       case DW_CFA_GNU_negative_offset_extended:
        case DW_CFA_def_cfa:
-         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, NULL);
+         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
+                                      NULL);
          dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
          break;
+
+       case DW_CFA_offset_extended_sf:
+       case DW_CFA_def_cfa_sf:
+         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
+                                      NULL);
+         dw2_asm_output_data_sleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
+         break;
+
        case DW_CFA_restore_extended:
        case DW_CFA_undefined:
        case DW_CFA_same_value:
        case DW_CFA_def_cfa_register:
-         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, NULL);
+         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
+                                      NULL);
          break;
+
        case DW_CFA_register:
-         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, NULL);
-         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_reg_num, NULL);
+         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
+                                      NULL);
+         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_reg_num,
+                                      NULL);
          break;
+
        case DW_CFA_def_cfa_offset:
        case DW_CFA_GNU_args_size:
          dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset, NULL);
          break;
+
+       case DW_CFA_def_cfa_offset_sf:
+         dw2_asm_output_data_sleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset, NULL);
+         break;
+
        case DW_CFA_GNU_window_save:
          break;
+
        case DW_CFA_def_cfa_expression:
+       case DW_CFA_expression:
          output_cfa_loc (cfi);
          break;
+
+       case DW_CFA_GNU_negative_offset_extended:
+         /* Obsoleted by DW_CFA_offset_extended_sf.  */
+         abort ();
+
        default:
          break;
        }
@@ -1754,12 +1821,17 @@ output_call_frame_info (for_eh)
   int per_encoding = DW_EH_PE_absptr;
   int lsda_encoding = DW_EH_PE_absptr;
 
-  /* If we don't have any functions we'll want to unwind out of, don't
-     emit any EH unwind information.  */
+  /* Don't emit a CIE if there won't be any FDEs.  */
+  if (fde_table_in_use == 0)
+    return;
+
+  /* If we don't have any functions we'll want to unwind out of, don't emit any
+     EH unwind information.  */
   if (for_eh)
     {
       int any_eh_needed = flag_asynchronous_unwind_tables;
-      for (i = 0; i < fde_table_in_use; ++i)
+
+      for (i = 0; i < fde_table_in_use; i++)
        if (fde_table[i].uses_eh_lsda)
          any_eh_needed = any_lsda_needed = 1;
        else if (! fde_table[i].nothrow)
@@ -1835,7 +1907,7 @@ output_call_frame_info (for_eh)
       if (p > augmentation + 1)
        {
          augmentation[0] = 'z';
-          *p = '\0';
+         *p = '\0';
        }
 
       /* Ug.  Some platforms can't do unaligned dynamic relocations at all.  */
@@ -1860,13 +1932,11 @@ output_call_frame_info (for_eh)
            abort ();
        }
     }
-  dw2_asm_output_nstring (augmentation, -1, "CIE Augmentation");
 
+  dw2_asm_output_nstring (augmentation, -1, "CIE Augmentation");
   dw2_asm_output_data_uleb128 (1, "CIE Code Alignment Factor");
-
   dw2_asm_output_data_sleb128 (DWARF_CIE_DATA_ALIGNMENT,
                               "CIE Data Alignment Factor");
-
   dw2_asm_output_data (1, DWARF_FRAME_RETURN_COLUMN, "CIE RA Column");
 
   if (augmentation[0])
@@ -1879,9 +1949,11 @@ output_call_frame_info (for_eh)
          dw2_asm_output_encoded_addr_rtx (per_encoding,
                                           eh_personality_libfunc, NULL);
        }
+
       if (any_lsda_needed)
        dw2_asm_output_data (1, lsda_encoding, "LSDA Encoding (%s)",
                             eh_data_format_name (lsda_encoding));
+
       if (fde_encoding != DW_EH_PE_absptr)
        dw2_asm_output_data (1, fde_encoding, "FDE Encoding (%s)",
                             eh_data_format_name (fde_encoding));
@@ -1891,20 +1963,22 @@ output_call_frame_info (for_eh)
     output_cfi (cfi, NULL, for_eh);
 
   /* Pad the CIE out to an address sized boundary.  */
-  ASM_OUTPUT_ALIGN (asm_out_file, 
+  ASM_OUTPUT_ALIGN (asm_out_file,
                    floor_log2 (for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE));
   ASM_OUTPUT_LABEL (asm_out_file, l2);
 
   /* Loop through all of the FDE's.  */
-  for (i = 0; i < fde_table_in_use; ++i)
+  for (i = 0; i < fde_table_in_use; i++)
     {
       fde = &fde_table[i];
 
       /* Don't emit EH unwind info for leaf functions that don't need it.  */
-      if (for_eh && fde->nothrow && ! fde->uses_eh_lsda)
+      if (!flag_asynchronous_unwind_tables && for_eh
+         && (fde->nothrow || fde->all_throwers_are_sibcalls)
+         && !fde->uses_eh_lsda)
        continue;
 
-      ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, FDE_LABEL, for_eh + i * 2);
+      (*targetm.asm_out.internal_label) (asm_out_file, FDE_LABEL, for_eh + i * 2);
       ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + i * 2);
       ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + i * 2);
       dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
@@ -1923,15 +1997,15 @@ output_call_frame_info (for_eh)
                   gen_rtx_SYMBOL_REF (Pmode, fde->dw_fde_begin),
                   "FDE initial location");
          dw2_asm_output_delta (size_of_encoded_value (fde_encoding),
-                               fde->dw_fde_end, fde->dw_fde_begin, 
+                               fde->dw_fde_end, fde->dw_fde_begin,
                                "FDE address range");
        }
       else
        {
          dw2_asm_output_addr (DWARF2_ADDR_SIZE, fde->dw_fde_begin,
                               "FDE initial location");
-         dw2_asm_output_delta (DWARF2_ADDR_SIZE, 
-                               fde->dw_fde_end, fde->dw_fde_begin, 
+         dw2_asm_output_delta (DWARF2_ADDR_SIZE,
+                               fde->dw_fde_end, fde->dw_fde_begin,
                                "FDE address range");
        }
 
@@ -1968,8 +2042,9 @@ output_call_frame_info (for_eh)
                {
                  if (lsda_encoding == DW_EH_PE_aligned)
                    ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
-                 dw2_asm_output_data (size_of_encoded_value (lsda_encoding),
-                                      0, "Language Specific Data Area (none)");
+                 dw2_asm_output_data
+                   (size_of_encoded_value (lsda_encoding), 0,
+                    "Language Specific Data Area (none)");
                }
            }
          else
@@ -1983,15 +2058,13 @@ output_call_frame_info (for_eh)
        output_cfi (cfi, fde, for_eh);
 
       /* Pad the FDE out to an address sized boundary.  */
-      ASM_OUTPUT_ALIGN (asm_out_file, 
+      ASM_OUTPUT_ALIGN (asm_out_file,
                        floor_log2 ((for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE)));
       ASM_OUTPUT_LABEL (asm_out_file, l2);
     }
 
-#ifndef EH_FRAME_SECTION_NAME
-  if (for_eh)
+  if (for_eh && targetm.terminate_dw2_eh_frame_info)
     dw2_asm_output_data (4, 0, "End of Table");
-#endif
 #ifdef MIPS_DEBUGGING_INFO
   /* Work around Irix 6 assembler bug whereby labels at the end of a section
      get a value of 0.  Putting .align 0 after the label fixes it.  */
@@ -2028,13 +2101,11 @@ dwarf2out_begin_prologue (line, file)
     return;
 #endif
 
-  ++current_funcdef_number;
-
   function_section (current_function_decl);
   ASM_GENERATE_INTERNAL_LABEL (label, FUNC_BEGIN_LABEL,
-                              current_funcdef_number);
+                              current_function_funcdef_no);
   ASM_OUTPUT_DEBUG_LABEL (asm_out_file, FUNC_BEGIN_LABEL,
-                         current_funcdef_number);
+                         current_function_funcdef_no);
   current_function_func_begin_label = get_identifier (label);
 
 #ifdef IA64_UNWIND_INFO
@@ -2061,14 +2132,15 @@ dwarf2out_begin_prologue (line, file)
   fde->dw_fde_current_label = NULL;
   fde->dw_fde_end = NULL;
   fde->dw_fde_cfi = NULL;
-  fde->funcdef_number = current_funcdef_number;
+  fde->funcdef_number = current_function_funcdef_no;
   fde->nothrow = current_function_nothrow;
   fde->uses_eh_lsda = cfun->uses_eh_lsda;
+  fde->all_throwers_are_sibcalls = cfun->all_throwers_are_sibcalls;
 
   args_size = old_args_size = 0;
 
-  /* We only want to output line number information for the genuine
-     dwarf2 prologue case, not the eh frame case.  */
+  /* We only want to output line number information for the genuine dwarf2
+     prologue case, not the eh frame case.  */
 #ifdef DWARF2_DEBUGGING_INFO
   if (file)
     dwarf2out_source_line (line, file);
@@ -2080,14 +2152,17 @@ dwarf2out_begin_prologue (line, file)
    been generated.  */
 
 void
-dwarf2out_end_epilogue ()
+dwarf2out_end_epilogue (line, file)
+     unsigned int line ATTRIBUTE_UNUSED;
+     const char *file ATTRIBUTE_UNUSED;
 {
   dw_fde_ref fde;
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
   /* Output a label to mark the endpoint of the code generated for this
-     function.        */
-  ASM_GENERATE_INTERNAL_LABEL (label, FUNC_END_LABEL, current_funcdef_number);
+     function.  */
+  ASM_GENERATE_INTERNAL_LABEL (label, FUNC_END_LABEL,
+                              current_function_funcdef_no);
   ASM_OUTPUT_LABEL (asm_out_file, label);
   fde = &fde_table[fde_table_in_use - 1];
   fde->dw_fde_end = xstrdup (label);
@@ -2115,8 +2190,9 @@ void
 dwarf2out_frame_finish ()
 {
   /* Output call frame information.  */
-  if (write_symbols == DWARF2_DEBUG)
+  if (write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
     output_call_frame_info (0);
+
   if (! USING_SJLJ_EXCEPTIONS && (flag_unwind_tables || flag_exceptions))
     output_call_frame_info (1);
 }
@@ -2124,6 +2200,11 @@ dwarf2out_frame_finish ()
 /* And now, the subset of the debugging information support code necessary
    for emitting location expressions.  */
 
+/* We need some way to distinguish DW_OP_addr with a direct symbol
+   relocation from DW_OP_addr with a dtp-relative symbol relocation.  */
+#define INTERNAL_DW_OP_tls_addr                (0x100 + DW_OP_addr)
+
+
 typedef struct dw_val_struct *dw_val_ref;
 typedef struct die_struct *dw_die_ref;
 typedef struct dw_loc_descr_struct *dw_loc_descr_ref;
@@ -2139,6 +2220,7 @@ typedef enum
   dw_val_class_offset,
   dw_val_class_loc,
   dw_val_class_loc_list,
+  dw_val_class_range_list,
   dw_val_class_const,
   dw_val_class_unsigned_const,
   dw_val_class_long_long,
@@ -2187,10 +2269,11 @@ typedef struct dw_val_struct
       long unsigned val_unsigned;
       dw_long_long_const val_long_long;
       dw_float_const val_float;
-      struct {
-       dw_die_ref die;
-       int external;
-      } val_die_ref;
+      struct
+       {
+         dw_die_ref die;
+         int external;
+       } val_die_ref;
       unsigned val_fde_index;
       struct indirect_string_node *val_str;
       char *val_lbl_id;
@@ -2221,7 +2304,8 @@ typedef struct dw_loc_list_struct
   dw_loc_list_ref dw_loc_next;
   const char *begin; /* Label for begin address of range */
   const char *end;  /* Label for end address of range */
-  char *ll_symbol; /* Label for beginning of location list. Only on head of list */
+  char *ll_symbol; /* Label for beginning of location list.
+                     Only on head of list */
   const char *section; /* Section this loclist is relative to */
   dw_loc_descr_ref expr;
 } dw_loc_list_node;
@@ -2246,6 +2330,7 @@ dwarf_stack_op_name (op)
   switch (op)
     {
     case DW_OP_addr:
+    case INTERNAL_DW_OP_tls_addr:
       return "DW_OP_addr";
     case DW_OP_deref:
       return "DW_OP_deref";
@@ -2535,6 +2620,16 @@ dwarf_stack_op_name (op)
       return "DW_OP_xderef_size";
     case DW_OP_nop:
       return "DW_OP_nop";
+    case DW_OP_push_object_address:
+      return "DW_OP_push_object_address";
+    case DW_OP_call2:
+      return "DW_OP_call2";
+    case DW_OP_call4:
+      return "DW_OP_call4";
+    case DW_OP_call_ref:
+      return "DW_OP_call_ref";
+    case DW_OP_GNU_push_tls_address:
+      return "DW_OP_GNU_push_tls_address";
     default:
       return "OP_<unknown>";
     }
@@ -2592,6 +2687,7 @@ size_of_loc_descr (loc)
   switch (loc->dw_loc_opc)
     {
     case DW_OP_addr:
+    case INTERNAL_DW_OP_tls_addr:
       size += DWARF2_ADDR_SIZE;
       break;
     case DW_OP_const1u:
@@ -2677,6 +2773,15 @@ size_of_loc_descr (loc)
     case DW_OP_xderef_size:
       size += 1;
       break;
+    case DW_OP_call2:
+      size += 2;
+      break;
+    case DW_OP_call4:
+      size += 4;
+      break;
+    case DW_OP_call_ref:
+      size += DWARF2_ADDR_SIZE;
+      break;
     default:
       break;
     }
@@ -2690,9 +2795,9 @@ static unsigned long
 size_of_locs (loc)
      dw_loc_descr_ref loc;
 {
-  unsigned long size = 0;
+  unsigned long size;
 
-  for (; loc != NULL; loc = loc->dw_loc_next)
+  for (size = 0; loc != NULL; loc = loc->dw_loc_next)
     {
       loc->dw_loc_addr = size;
       size += size_of_loc_descr (loc);
@@ -2826,6 +2931,17 @@ output_loc_operands (loc)
     case DW_OP_xderef_size:
       dw2_asm_output_data (1, val1->v.val_int, NULL);
       break;
+
+    case INTERNAL_DW_OP_tls_addr:
+#ifdef ASM_OUTPUT_DWARF_DTPREL
+      ASM_OUTPUT_DWARF_DTPREL (asm_out_file, DWARF2_ADDR_SIZE,
+                              val1->v.val_addr);
+      fputc ('\n', asm_out_file);
+#else
+      abort ();
+#endif
+      break;
+
     default:
       /* Other codes have no operands.  */
       break;
@@ -2891,6 +3007,7 @@ build_cfa_loc (cfa)
     head = new_loc_descr (DW_OP_reg0 + cfa->reg, 0, 0);
   else
     head = new_loc_descr (DW_OP_regx, cfa->reg, 0);
+
   head->dw_loc_oprnd1.val_class = dw_val_class_const;
   tmp = new_loc_descr (DW_OP_deref, 0, 0);
   add_loc_descr (&head, tmp);
@@ -2899,11 +3016,12 @@ build_cfa_loc (cfa)
       tmp = new_loc_descr (DW_OP_plus_uconst, cfa->offset, 0);
       add_loc_descr (&head, tmp);
     }
+
   return head;
 }
 
-/* This function fills in aa dw_cfa_location structure from a
-   dwarf location descriptor sequence.  */
+/* This function fills in aa dw_cfa_location structure from a dwarf location
+   descriptor sequence.  */
 
 static void
 get_cfa_from_loc_descr (cfa, loc)
@@ -2919,6 +3037,7 @@ get_cfa_from_loc_descr (cfa, loc)
   for (ptr = loc; ptr != NULL; ptr = ptr->dw_loc_next)
     {
       enum dwarf_location_atom op = ptr->dw_loc_opc;
+
       switch (op)
        {
        case DW_OP_reg0:
@@ -3004,7 +3123,7 @@ get_cfa_from_loc_descr (cfa, loc)
          cfa->offset = ptr->dw_loc_oprnd1.v.val_unsigned;
          break;
        default:
-         internal_error ("DW_LOC_OP %s not implememnted\n",
+         internal_error ("DW_LOC_OP %s not implemented\n",
                          dwarf_stack_op_name (ptr->dw_loc_opc));
        }
     }
@@ -3014,6 +3133,12 @@ get_cfa_from_loc_descr (cfa, loc)
 /* And now, the support for symbolic debugging information.  */
 #ifdef DWARF2_DEBUGGING_INFO
 
+/* .debug_str support.  */
+static hashnode indirect_string_alloc  PARAMS ((hash_table *));
+static int output_indirect_string      PARAMS ((struct cpp_reader *,
+                                                 hashnode, const PTR));
+
+
 static void dwarf2out_init             PARAMS ((const char *));
 static void dwarf2out_finish           PARAMS ((const char *));
 static void dwarf2out_define           PARAMS ((unsigned int, const char *));
@@ -3028,7 +3153,7 @@ static void dwarf2out_abstract_function PARAMS ((tree));
 
 /* The debug hooks structure.  */
 
-struct gcc_debug_hooks dwarf2_debug_hooks =
+const struct gcc_debug_hooks dwarf2_debug_hooks =
 {
   dwarf2out_init,
   dwarf2out_finish,
@@ -3041,7 +3166,7 @@ struct gcc_debug_hooks dwarf2_debug_hooks =
   dwarf2out_ignore_block,
   dwarf2out_source_line,
   dwarf2out_begin_prologue,
-  debug_nothing_int,           /* end_prologue */
+  debug_nothing_int_charstar,  /* end_prologue */
   dwarf2out_end_epilogue,
   debug_nothing_tree,          /* begin_function */
   debug_nothing_int,           /* end_function */
@@ -3145,6 +3270,7 @@ struct dw_ranges_struct
 typedef struct limbo_die_struct
 {
   dw_die_ref die;
+  tree created_for;
   struct limbo_die_struct *next;
 }
 limbo_die_node;
@@ -3154,7 +3280,7 @@ limbo_die_node;
 #define ASM_COMMENT_START ";#"
 #endif
 
-/* Define a macro which returns non-zero for a TYPE_DECL which was
+/* Define a macro which returns nonzero for a TYPE_DECL which was
    implicitly generated for a tagged type.
 
    Note that unlike the gcc front end (which generates a NULL named
@@ -3178,14 +3304,9 @@ limbo_die_node;
 /* Information concerning the compilation unit's programming
    language, and compiler version.  */
 
-extern int flag_traditional;
-
 /* Fixed size portion of the DWARF compilation unit header.  */
 #define DWARF_COMPILE_UNIT_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 3)
 
-/* Fixed size portion of debugging line information prolog.  */
-#define DWARF_LINE_PROLOG_HEADER_SIZE 5
-
 /* Fixed size portion of public names info.  */
 #define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
 
@@ -3209,22 +3330,11 @@ extern int flag_traditional;
 #endif
 #endif
 
-/* Define the architecture-dependent minimum instruction length (in bytes).
-   In this implementation of DWARF, this field is used for information
-   purposes only.  Since GCC generates assembly language, we have
-   no a priori knowledge of how many instruction bytes are generated
-   for each source line, and therefore can use only the  DW_LNE_set_address
-   and DW_LNS_fixed_advance_pc line information commands.  */
-
-#ifndef DWARF_LINE_MIN_INSTR_LENGTH
-#define DWARF_LINE_MIN_INSTR_LENGTH 4
-#endif
-
 /* Minimum line offset in a special line info. opcode.
    This value was chosen to give a reasonable range of values.  */
 #define DWARF_LINE_BASE  -10
 
-/* First special line opcde - leave room for the standard opcodes.  */
+/* First special line opcode - leave room for the standard opcodes.  */
 #define DWARF_LINE_OPCODE_BASE  10
 
 /* Range of line offsets in a special line info. opcode.  */
@@ -3243,6 +3353,10 @@ static unsigned long next_die_offset;
 /* Record the root of the DIE's built for the current compilation unit.  */
 static dw_die_ref comp_unit_die;
 
+/* We need special handling in dwarf2out_start_source_file if it is
+   first one.  */
+static int is_main_source;
+
 /* A list of DIEs with a NULL parent waiting to be relocated.  */
 static limbo_die_node *limbo_die_list = 0;
 
@@ -3262,10 +3376,6 @@ struct file_table
 /* Filenames referenced by this compilation unit.  */
 static struct file_table file_table;
 
-/* Local pointer to the name of the main input file.  Initialized in
-   dwarf2out_init.  */
-static const char *primary_filename;
-
 /* A pointer to the base of a table of references to DIE's that describe
    declarations.  The table is indexed by DECL_UID() which is a unique
    number identifying each decl.  */
@@ -3281,13 +3391,6 @@ static unsigned decl_die_table_in_use;
    decl_die_table.  */
 #define DECL_DIE_TABLE_INCREMENT 256
 
-/* 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.  */
-varray_type decl_scope_table;
-
 /* A pointer to the base of a list of references to DIE's that
    are uniquely identified by their tag, presence/absence of
    children DIE's, and list of attribute/value pairs.  */
@@ -3370,25 +3473,12 @@ static unsigned ranges_table_in_use;
 /* Whether we have location lists that need outputting */
 static unsigned have_location_lists;
 
-/* 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.  If we don't tell
-   the garbage collector about it, we can garbage collect live data.
-   Bug 4215.*/
-varray_type incomplete_types;
-
 /* Record whether the function being analyzed contains inlined functions.  */
 static int current_function_has_inlines;
 #if 0 && defined (MIPS_DEBUGGING_INFO)
 static int comp_unit_has_inlines;
 #endif
 
-/* Array of RTXes referenced by the debugging information, which therefore
-   must be kept around forever.  We do this rather than perform GC on
-   the dwarf info because almost all of the dwarf info lives forever, and
-   it's easier to support non-GC frontends this way.  */
-static varray_type used_rtx_varray;
-
 /* Forward declarations for functions defined in this file.  */
 
 static int is_pseudo_reg               PARAMS ((rtx));
@@ -3404,14 +3494,18 @@ static tree decl_ultimate_origin        PARAMS ((tree));
 static tree block_ultimate_origin      PARAMS ((tree));
 static tree decl_class_context         PARAMS ((tree));
 static void add_dwarf_attr             PARAMS ((dw_die_ref, dw_attr_ref));
+static inline dw_val_class AT_class    PARAMS ((dw_attr_ref));
 static void add_AT_flag                        PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute,
                                                 unsigned));
+static inline unsigned AT_flag         PARAMS ((dw_attr_ref));
 static void add_AT_int                 PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute, long));
+static inline long int AT_int          PARAMS ((dw_attr_ref));
 static void add_AT_unsigned            PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute,
                                                 unsigned long));
+static inline unsigned long            AT_unsigned PARAMS ((dw_attr_ref));
 static void add_AT_long_long           PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute,
                                                 unsigned long,
@@ -3422,21 +3516,29 @@ static void add_AT_float                PARAMS ((dw_die_ref,
 static void add_AT_string              PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute,
                                                 const char *));
+static inline const char *AT_string    PARAMS ((dw_attr_ref));
+static int AT_string_form              PARAMS ((dw_attr_ref));
 static void add_AT_die_ref             PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute,
                                                 dw_die_ref));
+static inline dw_die_ref AT_ref                PARAMS ((dw_attr_ref));
+static inline int AT_ref_external      PARAMS ((dw_attr_ref));
+static inline void set_AT_ref_external PARAMS ((dw_attr_ref, int));
 static void add_AT_fde_ref             PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute,
                                                 unsigned));
 static void add_AT_loc                 PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute,
                                                 dw_loc_descr_ref));
+static inline dw_loc_descr_ref AT_loc  PARAMS ((dw_attr_ref));
 static void add_AT_loc_list            PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute,
                                                 dw_loc_list_ref));
+static inline dw_loc_list_ref AT_loc_list PARAMS ((dw_attr_ref));
 static void add_AT_addr                        PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute,
                                                 rtx));
+static inline rtx AT_addr              PARAMS ((dw_attr_ref));
 static void add_AT_lbl_id              PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute,
                                                 const char *));
@@ -3446,6 +3548,10 @@ static void add_AT_lbl_offset            PARAMS ((dw_die_ref,
 static void add_AT_offset              PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute,
                                                 unsigned long));
+static void add_AT_range_list          PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                unsigned long));
+static inline const char *AT_lbl       PARAMS ((dw_attr_ref));
 static dw_attr_ref get_AT              PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute));
 static const char *get_AT_low_pc       PARAMS ((dw_die_ref));
@@ -3459,13 +3565,16 @@ static unsigned get_AT_unsigned         PARAMS ((dw_die_ref,
 static inline dw_die_ref get_AT_ref    PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute));
 static int is_c_family                 PARAMS ((void));
+static int is_cxx                      PARAMS ((void));
 static int is_java                     PARAMS ((void));
 static int is_fortran                  PARAMS ((void));
 static void remove_AT                  PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute));
+static inline void free_die            PARAMS ((dw_die_ref));
 static void remove_children            PARAMS ((dw_die_ref));
 static void add_child_die              PARAMS ((dw_die_ref, dw_die_ref));
-static dw_die_ref new_die              PARAMS ((enum dwarf_tag, dw_die_ref));
+static dw_die_ref new_die              PARAMS ((enum dwarf_tag, dw_die_ref,
+                                                tree));
 static dw_die_ref lookup_type_die      PARAMS ((tree));
 static void equate_type_number_to_die  PARAMS ((tree, dw_die_ref));
 static dw_die_ref lookup_decl_die      PARAMS ((tree));
@@ -3477,15 +3586,32 @@ static void reverse_die_lists           PARAMS ((dw_die_ref));
 static void reverse_all_dies           PARAMS ((dw_die_ref));
 static dw_die_ref push_new_compile_unit PARAMS ((dw_die_ref, dw_die_ref));
 static dw_die_ref pop_compile_unit     PARAMS ((dw_die_ref));
-static void loc_checksum        PARAMS ((dw_loc_descr_ref, struct md5_ctx *));
-static void attr_checksum            PARAMS ((dw_attr_ref, struct md5_ctx *));
-static void die_checksum              PARAMS ((dw_die_ref, struct md5_ctx *));
+static void loc_checksum               PARAMS ((dw_loc_descr_ref,
+                                                struct md5_ctx *));
+static void attr_checksum              PARAMS ((dw_attr_ref,
+                                                struct md5_ctx *,
+                                                int *));
+static void die_checksum               PARAMS ((dw_die_ref,
+                                                struct md5_ctx *,
+                                                int *));
+static int same_loc_p                  PARAMS ((dw_loc_descr_ref,
+                                                dw_loc_descr_ref, int *));
+static int same_dw_val_p               PARAMS ((dw_val_node *, dw_val_node *,
+                                                int *));
+static int same_attr_p                 PARAMS ((dw_attr_ref, dw_attr_ref, int *));
+static int same_die_p                  PARAMS ((dw_die_ref, dw_die_ref, int *));
+static int same_die_p_wrap             PARAMS ((dw_die_ref, dw_die_ref));
 static void compute_section_prefix     PARAMS ((dw_die_ref));
 static int is_type_die                 PARAMS ((dw_die_ref));
 static int is_comdat_die               PARAMS ((dw_die_ref));
 static int is_symbol_die               PARAMS ((dw_die_ref));
 static void assign_symbol_names                PARAMS ((dw_die_ref));
 static void break_out_includes         PARAMS ((dw_die_ref));
+static hashval_t htab_cu_hash          PARAMS ((const void *));
+static int htab_cu_eq                  PARAMS ((const void *, const void *));
+static void htab_cu_del                        PARAMS ((void *));
+static int check_duplicate_cu          PARAMS ((dw_die_ref, htab_t, unsigned *));
+static void record_comdat_symbol_number        PARAMS ((dw_die_ref, htab_t, unsigned));
 static void add_sibling_attributes     PARAMS ((dw_die_ref));
 static void build_abbrev_table         PARAMS ((dw_die_ref));
 static void output_location_lists      PARAMS ((dw_die_ref));
@@ -3494,6 +3620,7 @@ static unsigned long size_of_die  PARAMS ((dw_die_ref));
 static void calc_die_sizes             PARAMS ((dw_die_ref));
 static void mark_dies                  PARAMS ((dw_die_ref));
 static void unmark_dies                        PARAMS ((dw_die_ref));
+static void unmark_all_dies             PARAMS ((dw_die_ref));
 static unsigned long size_of_pubnames  PARAMS ((void));
 static unsigned long size_of_aranges   PARAMS ((void));
 static enum dwarf_form value_format    PARAMS ((dw_attr_ref));
@@ -3502,7 +3629,7 @@ static void output_abbrev_section PARAMS ((void));
 static void output_die_symbol          PARAMS ((dw_die_ref));
 static void output_die                 PARAMS ((dw_die_ref));
 static void output_compilation_unit_header PARAMS ((void));
-static void output_comp_unit           PARAMS ((dw_die_ref));
+static void output_comp_unit           PARAMS ((dw_die_ref, int));
 static const char *dwarf2_name         PARAMS ((tree, int));
 static void add_pubname                        PARAMS ((tree, dw_die_ref));
 static void output_pubnames            PARAMS ((void));
@@ -3533,7 +3660,8 @@ static unsigned int simple_decl_align_in_bits PARAMS ((tree));
 static unsigned HOST_WIDE_INT simple_type_size_in_bits PARAMS ((tree));
 static HOST_WIDE_INT field_byte_offset PARAMS ((tree));
 static void add_AT_location_description        PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute, rtx));
+                                                enum dwarf_attribute,
+                                                dw_loc_descr_ref));
 static void add_data_member_location_attribute PARAMS ((dw_die_ref, tree));
 static void add_const_value_attribute  PARAMS ((dw_die_ref, rtx));
 static rtx rtl_for_decl_location       PARAMS ((tree));
@@ -3552,8 +3680,10 @@ static void add_pure_or_virtual_attribute PARAMS ((dw_die_ref, tree));
 static void add_src_coords_attributes  PARAMS ((dw_die_ref, tree));
 static void add_name_and_src_coords_attributes PARAMS ((dw_die_ref, tree));
 static void push_decl_scope            PARAMS ((tree));
-static dw_die_ref scope_die_for                PARAMS ((tree, dw_die_ref));
 static void pop_decl_scope             PARAMS ((void));
+static dw_die_ref scope_die_for                PARAMS ((tree, dw_die_ref));
+static inline int local_scope_p                PARAMS ((dw_die_ref));
+static inline int class_scope_p                PARAMS ((dw_die_ref));
 static void add_type_attribute         PARAMS ((dw_die_ref, tree, int, int,
                                                 dw_die_ref));
 static const char *type_tag            PARAMS ((tree));
@@ -3595,13 +3725,11 @@ static int is_redundant_typedef         PARAMS ((tree));
 static void gen_decl_die               PARAMS ((tree, dw_die_ref));
 static unsigned lookup_filename                PARAMS ((const char *));
 static void init_file_table            PARAMS ((void));
-static void add_incomplete_type                PARAMS ((tree));
 static void retry_incomplete_types     PARAMS ((void));
 static void gen_type_die_for_member    PARAMS ((tree, tree, dw_die_ref));
-static rtx save_rtx                    PARAMS ((rtx));
 static void splice_child_die           PARAMS ((dw_die_ref, dw_die_ref));
 static int file_info_cmp               PARAMS ((const void *, const void *));
-static dw_loc_list_ref new_loc_list     PARAMS ((dw_loc_descr_ref, 
+static dw_loc_list_ref new_loc_list     PARAMS ((dw_loc_descr_ref,
                                                 const char *, const char *,
                                                 const char *, unsigned));
 static void add_loc_descr_to_loc_list   PARAMS ((dw_loc_list_ref *,
@@ -3609,6 +3737,7 @@ static void add_loc_descr_to_loc_list   PARAMS ((dw_loc_list_ref *,
                                                 const char *, const char *, const char *));
 static void output_loc_list            PARAMS ((dw_loc_list_ref));
 static char *gen_internal_sym          PARAMS ((const char *));
+static void mark_limbo_die_list                PARAMS ((void *));
 
 /* Section names used to hold DWARF debugging information.  */
 #ifndef DEBUG_INFO_SECTION
@@ -3670,6 +3799,9 @@ static char *gen_internal_sym             PARAMS ((const char *));
 #ifndef DEBUG_LOC_SECTION_LABEL
 #define DEBUG_LOC_SECTION_LABEL                "Ldebug_loc"
 #endif
+#ifndef DEBUG_RANGES_SECTION_LABEL
+#define DEBUG_RANGES_SECTION_LABEL     "Ldebug_ranges"
+#endif
 #ifndef DEBUG_MACINFO_SECTION_LABEL
 #define DEBUG_MACINFO_SECTION_LABEL     "Ldebug_macinfo"
 #endif
@@ -3687,27 +3819,17 @@ static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
 static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
 static char macinfo_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
 static char loc_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char ranges_section_label[2 * MAX_ARTIFICIAL_LABEL_BYTES];
+
 #ifndef TEXT_END_LABEL
 #define TEXT_END_LABEL         "Letext"
 #endif
-#ifndef DATA_END_LABEL
-#define DATA_END_LABEL         "Ledata"
-#endif
-#ifndef BSS_END_LABEL
-#define BSS_END_LABEL           "Lebss"
-#endif
 #ifndef BLOCK_BEGIN_LABEL
 #define BLOCK_BEGIN_LABEL      "LBB"
 #endif
 #ifndef BLOCK_END_LABEL
 #define BLOCK_END_LABEL                "LBE"
 #endif
-#ifndef BODY_BEGIN_LABEL
-#define BODY_BEGIN_LABEL       "Lbb"
-#endif
-#ifndef BODY_END_LABEL
-#define BODY_END_LABEL         "Lbe"
-#endif
 #ifndef LINE_CODE_LABEL
 #define LINE_CODE_LABEL                "LM"
 #endif
@@ -3726,19 +3848,6 @@ dwarf2out_set_demangle_name_func (func)
 {
   demangle_name_func = func;
 }
-\f
-/* Return an rtx like ORIG which lives forever.  If we're doing GC,
-   that means adding it to used_rtx_varray.  If not, that means making
-   a copy on the permanent_obstack.  */
-
-static rtx
-save_rtx (orig)
-     rtx orig;
-{
-  VARRAY_PUSH_RTX (used_rtx_varray, orig);
-
-  return orig;
-}
 
 /* Test if rtl node points to a pseudo register.  */
 
@@ -3760,11 +3869,11 @@ type_main_variant (type)
 {
   type = TYPE_MAIN_VARIANT (type);
 
-  /* There really should be only one main variant among any group of variants
-     of a given type (and all of the MAIN_VARIANT values for all members of
-     the group should point to that one type) but sometimes the C front-end
-     messes this up for array types, so we work around that bug here.  */
-
+  /* ??? There really should be only one main variant among any group of
+     variants of a given type (and all of the MAIN_VARIANT values for all
+     members of the group should point to that one type) but sometimes the C
+     front-end messes this up for array types, so we work around that bug
+     here.  */
   if (TREE_CODE (type) == ARRAY_TYPE)
     while (type != TYPE_MAIN_VARIANT (type))
       type = TYPE_MAIN_VARIANT (type);
@@ -3772,7 +3881,7 @@ type_main_variant (type)
   return type;
 }
 
-/* Return non-zero if the given type node represents a tagged type.  */
+/* Return nonzero if the given type node represents a tagged type.  */
 
 static inline int
 is_tagged_type (type)
@@ -4098,6 +4207,12 @@ dwarf_attr_name (attr)
       return "DW_AT_body_begin";
     case DW_AT_body_end:
       return "DW_AT_body_end";
+    case DW_AT_GNU_vector:
+      return "DW_AT_GNU_vector";
+
+    case DW_AT_VMS_rtnbeg_pd_address:
+      return "DW_AT_VMS_rtnbeg_pd_address";
+
     default:
       return "DW_AT_<unknown>";
     }
@@ -4243,9 +4358,8 @@ block_ultimate_origin (block)
       do
        {
          ret_val = lookahead;
-         lookahead = (TREE_CODE (ret_val) == BLOCK)
-           ? BLOCK_ABSTRACT_ORIGIN (ret_val)
-           : NULL;
+         lookahead = (TREE_CODE (ret_val) == BLOCK
+                      ? BLOCK_ABSTRACT_ORIGIN (ret_val) : NULL);
        }
       while (lookahead != NULL && lookahead != ret_val);
 
@@ -4290,7 +4404,6 @@ add_dwarf_attr (die, attr)
     }
 }
 
-static inline dw_val_class AT_class PARAMS ((dw_attr_ref));
 static inline dw_val_class
 AT_class (a)
      dw_attr_ref a;
@@ -4315,7 +4428,6 @@ add_AT_flag (die, attr_kind, flag)
   add_dwarf_attr (die, attr);
 }
 
-static inline unsigned AT_flag PARAMS ((dw_attr_ref));
 static inline unsigned
 AT_flag (a)
      dw_attr_ref a;
@@ -4343,7 +4455,6 @@ add_AT_int (die, attr_kind, int_val)
   add_dwarf_attr (die, attr);
 }
 
-static inline long int AT_int PARAMS ((dw_attr_ref));
 static inline long int
 AT_int (a)
      dw_attr_ref a;
@@ -4371,7 +4482,6 @@ add_AT_unsigned (die, attr_kind, unsigned_val)
   add_dwarf_attr (die, attr);
 }
 
-static inline unsigned long AT_unsigned PARAMS ((dw_attr_ref));
 static inline unsigned long
 AT_unsigned (a)
      dw_attr_ref a;
@@ -4430,7 +4540,7 @@ add_AT_string (die, attr_kind, str)
 {
   dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
   struct indirect_string_node *node;
-  
+
   if (! debug_str_hash)
     {
       debug_str_hash = ht_create (10);
@@ -4449,7 +4559,6 @@ add_AT_string (die, attr_kind, str)
   add_dwarf_attr (die, attr);
 }
 
-static inline const char *AT_string PARAMS ((dw_attr_ref));
 static inline const char *
 AT_string (a)
      dw_attr_ref a;
@@ -4463,7 +4572,6 @@ AT_string (a)
 /* Find out whether a string should be output inline in DIE
    or out-of-line in .debug_str section.  */
 
-static int AT_string_form PARAMS ((dw_attr_ref));
 static int
 AT_string_form (a)
      dw_attr_ref a;
@@ -4481,24 +4589,22 @@ AT_string_form (a)
 
       len = HT_LEN (&node->id) + 1;
 
-      /* If the string is shorter or equal to the size
-        of the reference, it is always better to put it
-        inline.  */
+      /* If the string is shorter or equal to the size of the reference, it is
+        always better to put it inline.  */
       if (len <= DWARF_OFFSET_SIZE || node->refcount == 0)
        return node->form = DW_FORM_string;
 
-      if ((DEBUG_STR_SECTION_FLAGS & SECTION_MERGE) == 0)
-       {
-         /* If we cannot expect the linker to merge strings
-            in .debug_str section, only put it into .debug_str
-            if it is worth even in this single module.  */
-         if ((len - DWARF_OFFSET_SIZE) * node->refcount <= len)
-           return node->form = DW_FORM_string;
-       }
+      /* If we cannot expect the linker to merge strings in .debug_str
+        section, only put it into .debug_str if it is worth even in this
+        single module.  */
+      if ((DEBUG_STR_SECTION_FLAGS & SECTION_MERGE) == 0
+         && (len - DWARF_OFFSET_SIZE) * node->refcount <= len)
+       return node->form = DW_FORM_string;
 
       ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
       ++const_labelno;
       node->label = xstrdup (label);
+
       return node->form = DW_FORM_strp;
     }
 
@@ -4523,7 +4629,6 @@ add_AT_die_ref (die, attr_kind, targ_die)
   add_dwarf_attr (die, attr);
 }
 
-static inline dw_die_ref AT_ref PARAMS ((dw_attr_ref));
 static inline dw_die_ref
 AT_ref (a)
      dw_attr_ref a;
@@ -4534,7 +4639,6 @@ AT_ref (a)
   abort ();
 }
 
-static inline int AT_ref_external PARAMS ((dw_attr_ref));
 static inline int
 AT_ref_external (a)
      dw_attr_ref a;
@@ -4545,7 +4649,6 @@ AT_ref_external (a)
   return 0;
 }
 
-static inline void set_AT_ref_external PARAMS ((dw_attr_ref, int));
 static inline void
 set_AT_ref_external (a, i)
      dw_attr_ref a;
@@ -4591,7 +4694,6 @@ add_AT_loc (die, attr_kind, loc)
   add_dwarf_attr (die, attr);
 }
 
-static inline dw_loc_descr_ref AT_loc PARAMS ((dw_attr_ref));
 static inline dw_loc_descr_ref
 AT_loc (a)
      dw_attr_ref a;
@@ -4618,8 +4720,6 @@ add_AT_loc_list (die, attr_kind, loc_list)
   have_location_lists = 1;
 }
 
-static inline dw_loc_list_ref AT_loc_list PARAMS ((dw_attr_ref));
-
 static inline dw_loc_list_ref
 AT_loc_list (a)
      dw_attr_ref a;
@@ -4647,7 +4747,6 @@ add_AT_addr (die, attr_kind, addr)
   add_dwarf_attr (die, attr);
 }
 
-static inline rtx AT_addr PARAMS ((dw_attr_ref));
 static inline rtx
 AT_addr (a)
      dw_attr_ref a;
@@ -4694,7 +4793,7 @@ add_AT_lbl_offset (die, attr_kind, label)
 
 /* Add an offset attribute value to a DIE.  */
 
-static void
+static inline void
 add_AT_offset (die, attr_kind, offset)
      dw_die_ref die;
      enum dwarf_attribute attr_kind;
@@ -4709,7 +4808,23 @@ add_AT_offset (die, attr_kind, offset)
   add_dwarf_attr (die, attr);
 }
 
-static inline const char *AT_lbl PARAMS ((dw_attr_ref));
+/* Add an range_list attribute value to a DIE.  */
+
+static void
+add_AT_range_list (die, attr_kind, offset)
+     dw_die_ref die;
+     enum dwarf_attribute attr_kind;
+     unsigned long offset;
+{
+  dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+
+  attr->dw_attr_next = NULL;
+  attr->dw_attr = attr_kind;
+  attr->dw_attr_val.val_class = dw_val_class_range_list;
+  attr->dw_attr_val.v.val_offset = offset;
+  add_dwarf_attr (die, attr);
+}
+
 static inline const char *
 AT_lbl (a)
      dw_attr_ref a;
@@ -4734,14 +4849,11 @@ get_AT (die, attr_kind)
   if (die != NULL)
     {
       for (a = die->die_attr; a != NULL; a = a->dw_attr_next)
-       {
-         if (a->dw_attr == attr_kind)
-           return a;
-
-         if (a->dw_attr == DW_AT_specification
-             || a->dw_attr == DW_AT_abstract_origin)
-           spec = AT_ref (a);
-       }
+       if (a->dw_attr == attr_kind)
+         return a;
+       else if (a->dw_attr == DW_AT_specification
+                || a->dw_attr == DW_AT_abstract_origin)
+         spec = AT_ref (a);
 
       if (spec)
        return get_AT (spec, attr_kind);
@@ -4750,29 +4862,29 @@ get_AT (die, attr_kind)
   return NULL;
 }
 
-/* Return the "low pc" attribute value, typically associated with
-   a subprogram DIE.  Return null if the "low pc" attribute is
-   either not prsent, or if it cannot be represented as an
-   assembler label identifier.  */
+/* Return the "low pc" attribute value, typically associated with a subprogram
+   DIE.  Return null if the "low pc" attribute is either not present, or if it
+   cannot be represented as an assembler label identifier.  */
 
 static inline const char *
 get_AT_low_pc (die)
      dw_die_ref die;
 {
   dw_attr_ref a = get_AT (die, DW_AT_low_pc);
+
   return a ? AT_lbl (a) : NULL;
 }
 
-/* Return the "high pc" attribute value, typically associated with
-   a subprogram DIE.  Return null if the "high pc" attribute is
-   either not prsent, or if it cannot be represented as an
-   assembler label identifier.  */
+/* Return the "high pc" attribute value, typically associated with a subprogram
+   DIE.  Return null if the "high pc" attribute is either not present, or if it
+   cannot be represented as an assembler label identifier.  */
 
 static inline const char *
 get_AT_hi_pc (die)
      dw_die_ref die;
 {
   dw_attr_ref a = get_AT (die, DW_AT_high_pc);
+
   return a ? AT_lbl (a) : NULL;
 }
 
@@ -4785,6 +4897,7 @@ get_AT_string (die, attr_kind)
      enum dwarf_attribute attr_kind;
 {
   dw_attr_ref a = get_AT (die, attr_kind);
+
   return a ? AT_string (a) : NULL;
 }
 
@@ -4797,6 +4910,7 @@ get_AT_flag (die, attr_kind)
      enum dwarf_attribute attr_kind;
 {
   dw_attr_ref a = get_AT (die, attr_kind);
+
   return a ? AT_flag (a) : 0;
 }
 
@@ -4809,6 +4923,7 @@ get_AT_unsigned (die, attr_kind)
      enum dwarf_attribute attr_kind;
 {
   dw_attr_ref a = get_AT (die, attr_kind);
+
   return a ? AT_unsigned (a) : 0;
 }
 
@@ -4818,6 +4933,7 @@ get_AT_ref (die, attr_kind)
      enum dwarf_attribute attr_kind;
 {
   dw_attr_ref a = get_AT (die, attr_kind);
+
   return a ? AT_ref (a) : NULL;
 }
 
@@ -4831,6 +4947,13 @@ is_c_family ()
 }
 
 static inline int
+is_cxx ()
+{
+  return (get_AT_unsigned (comp_unit_die, DW_AT_language)
+         == DW_LANG_C_plus_plus);
+}
+
+static inline int
 is_fortran ()
 {
   unsigned lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
@@ -4903,7 +5026,6 @@ remove_AT (die, attr_kind)
 
 /* Free up the memory used by DIE.  */
 
-static inline void free_die PARAMS ((dw_die_ref));
 static inline void
 free_die (die)
      dw_die_ref die;
@@ -4953,6 +5075,7 @@ add_child_die (die, child_die)
     {
       if (die == child_die)
        abort ();
+
       child_die->die_parent = die;
       child_die->die_sib = die->die_child;
       die->die_child = child_die;
@@ -4973,6 +5096,7 @@ splice_child_die (parent, child)
   if (child->die_parent != parent)
     {
       dw_die_ref tmp = get_AT_ref (child, DW_AT_specification);
+
       if (tmp)
        child = tmp;
     }
@@ -4995,9 +5119,10 @@ splice_child_die (parent, child)
 /* Return a pointer to a newly created DIE node.  */
 
 static inline dw_die_ref
-new_die (tag_value, parent_die)
+new_die (tag_value, parent_die, t)
      enum dwarf_tag tag_value;
      dw_die_ref parent_die;
+     tree t;
 {
   dw_die_ref die = (dw_die_ref) xcalloc (1, sizeof (die_node));
 
@@ -5011,6 +5136,7 @@ new_die (tag_value, parent_die)
 
       limbo_node = (limbo_die_node *) xmalloc (sizeof (limbo_die_node));
       limbo_node->die = die;
+      limbo_node->created_for = t;
       limbo_node->next = limbo_die_list;
       limbo_die_list = limbo_node;
     }
@@ -5024,9 +5150,7 @@ static inline dw_die_ref
 lookup_type_die (type)
      tree type;
 {
-  if (TREE_CODE (type) == VECTOR_TYPE)
-    type = TYPE_DEBUG_REPRESENTATION_TYPE (type);
-  return (dw_die_ref) TYPE_SYMTAB_POINTER (type);
+  return TYPE_SYMTAB_DIE (type);
 }
 
 /* Equate a DIE to a given type specifier.  */
@@ -5036,7 +5160,7 @@ equate_type_number_to_die (type, type_die)
      tree type;
      dw_die_ref type_die;
 {
-  TYPE_SYMTAB_POINTER (type) = (char *) type_die;
+  TYPE_SYMTAB_DIE (type) = type_die;
 }
 
 /* Return the DIE associated with a given declaration.  */
@@ -5047,8 +5171,7 @@ lookup_decl_die (decl)
 {
   unsigned decl_id = DECL_UID (decl);
 
-  return (decl_id < decl_die_table_in_use
-         ? decl_die_table[decl_id] : NULL);
+  return (decl_id < decl_die_table_in_use ? decl_die_table[decl_id] : NULL);
 }
 
 /* Equate a DIE to a particular declaration.  */
@@ -5058,8 +5181,8 @@ equate_decl_number_to_die (decl, decl_die)
      tree decl;
      dw_die_ref decl_die;
 {
-  unsigned decl_id = DECL_UID (decl);
-  unsigned num_allocated;
+  unsigned int decl_id = DECL_UID (decl);
+  unsigned int num_allocated;
 
   if (decl_id >= decl_die_table_allocated)
     {
@@ -5135,6 +5258,9 @@ print_die (die, outfile)
          fprintf (outfile, "location list -> label:%s",
                   AT_loc_list (a)->ll_symbol);
          break;
+       case dw_val_class_range_list:
+         fprintf (outfile, "range list");
+         break;
        case dw_val_class_const:
          fprintf (outfile, "%ld", AT_int (a));
          break;
@@ -5203,7 +5329,7 @@ print_dwarf_line_table (outfile)
   dw_line_info_ref line_info;
 
   fprintf (outfile, "\n\nDWARF source line information\n");
-  for (i = 1; i < line_info_table_in_use; ++i)
+  for (i = 1; i < line_info_table_in_use; i++)
     {
       line_info = &line_info_table[i];
       fprintf (outfile, "%5d: ", i);
@@ -5253,6 +5379,7 @@ reverse_die_lists (die)
       a->dw_attr_next = ap;
       ap = a;
     }
+
   die->die_attr = ap;
 
   for (c = die->die_child, cp = 0; c; c = cn)
@@ -5261,15 +5388,15 @@ reverse_die_lists (die)
       c->die_sib = cp;
       cp = c;
     }
+
   die->die_child = cp;
 }
 
-/* reverse_die_lists only reverses the single die you pass it. Since
-   we used to reverse all dies in add_sibling_attributes, which runs
-   through all the dies, it would reverse all the dies.  Now, however,
-   since we don't call reverse_die_lists in add_sibling_attributes, we
-   need a routine to recursively reverse all the dies. This is that
-   routine.  */
+/* reverse_die_lists only reverses the single die you pass it. Since we used to
+   reverse all dies in add_sibling_attributes, which runs through all the dies,
+   it would reverse all the dies.  Now, however, since we don't call
+   reverse_die_lists in add_sibling_attributes, we need a routine to
+   recursively reverse all the dies. This is that routine.  */
 
 static void
 reverse_all_dies (die)
@@ -5283,10 +5410,9 @@ reverse_all_dies (die)
     reverse_all_dies (c);
 }
 
-/* Start a new compilation unit DIE for an include file.  OLD_UNIT is
-   the CU for the enclosing include file, if any.  BINCL_DIE is the
-   DW_TAG_GNU_BINCL DIE that marks the start of the DIEs for this
-   include file.  */
+/* Start a new compilation unit DIE for an include file.  OLD_UNIT is the CU
+   for the enclosing include file, if any.  BINCL_DIE is the DW_TAG_GNU_BINCL
+   DIE that marks the start of the DIEs for this include file.  */
 
 static dw_die_ref
 push_new_compile_unit (old_unit, bincl_die)
@@ -5294,6 +5420,7 @@ push_new_compile_unit (old_unit, bincl_die)
 {
   const char *filename = get_AT_string (bincl_die, DW_AT_name);
   dw_die_ref new_unit = gen_compile_unit_die (filename);
+
   new_unit->die_sib = old_unit;
   return new_unit;
 }
@@ -5305,12 +5432,13 @@ pop_compile_unit (old_unit)
      dw_die_ref old_unit;
 {
   dw_die_ref new_unit = old_unit->die_sib;
+
   old_unit->die_sib = NULL;
   return new_unit;
 }
 
-#define PROCESS(FOO) md5_process_bytes (&(FOO), sizeof (FOO), ctx)
-#define PROCESS_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO), ctx)
+#define CHECKSUM(FOO) md5_process_bytes (&(FOO), sizeof (FOO), ctx)
+#define CHECKSUM_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO), ctx)
 
 /* Calculate the checksum of a location expression.  */
 
@@ -5319,22 +5447,23 @@ loc_checksum (loc, ctx)
      dw_loc_descr_ref loc;
      struct md5_ctx *ctx;
 {
-  PROCESS (loc->dw_loc_opc);
-  PROCESS (loc->dw_loc_oprnd1);
-  PROCESS (loc->dw_loc_oprnd2);
+  CHECKSUM (loc->dw_loc_opc);
+  CHECKSUM (loc->dw_loc_oprnd1);
+  CHECKSUM (loc->dw_loc_oprnd2);
 }
 
 /* Calculate the checksum of an attribute.  */
 
 static void
-attr_checksum (at, ctx)
+attr_checksum (at, ctx, mark)
      dw_attr_ref at;
      struct md5_ctx *ctx;
+     int *mark;
 {
   dw_loc_descr_ref loc;
   rtx r;
 
-  PROCESS (at->dw_attr);
+  CHECKSUM (at->dw_attr);
 
   /* We don't care about differences in file numbering.  */
   if (at->dw_attr == DW_AT_decl_file
@@ -5346,23 +5475,22 @@ attr_checksum (at, ctx)
   switch (AT_class (at))
     {
     case dw_val_class_const:
-      PROCESS (at->dw_attr_val.v.val_int);
+      CHECKSUM (at->dw_attr_val.v.val_int);
       break;
     case dw_val_class_unsigned_const:
-      PROCESS (at->dw_attr_val.v.val_unsigned);
+      CHECKSUM (at->dw_attr_val.v.val_unsigned);
       break;
     case dw_val_class_long_long:
-      PROCESS (at->dw_attr_val.v.val_long_long);
+      CHECKSUM (at->dw_attr_val.v.val_long_long);
       break;
     case dw_val_class_float:
-      PROCESS (at->dw_attr_val.v.val_float);
+      CHECKSUM (at->dw_attr_val.v.val_float);
       break;
     case dw_val_class_flag:
-      PROCESS (at->dw_attr_val.v.val_flag);
+      CHECKSUM (at->dw_attr_val.v.val_flag);
       break;
-
     case dw_val_class_str:
-      PROCESS_STRING (AT_string (at));
+      CHECKSUM_STRING (AT_string (at));
       break;
 
     case dw_val_class_addr:
@@ -5370,7 +5498,7 @@ attr_checksum (at, ctx)
       switch (GET_CODE (r))
        {
        case SYMBOL_REF:
-         PROCESS_STRING (XSTR (r, 0));
+         CHECKSUM_STRING (XSTR (r, 0));
          break;
 
        default:
@@ -5379,7 +5507,7 @@ attr_checksum (at, ctx)
       break;
 
     case dw_val_class_offset:
-      PROCESS (at->dw_attr_val.v.val_offset);
+      CHECKSUM (at->dw_attr_val.v.val_offset);
       break;
 
     case dw_val_class_loc:
@@ -5388,9 +5516,8 @@ attr_checksum (at, ctx)
       break;
 
     case dw_val_class_die_ref:
-      if (AT_ref (at)->die_offset)
-       PROCESS (AT_ref (at)->die_offset);
-      /* FIXME else use target die name or something.  */
+      die_checksum (AT_ref (at), ctx, mark);
+      break;
 
     case dw_val_class_fde_ref:
     case dw_val_class_lbl_id:
@@ -5405,24 +5532,194 @@ attr_checksum (at, ctx)
 /* Calculate the checksum of a DIE.  */
 
 static void
-die_checksum (die, ctx)
+die_checksum (die, ctx, mark)
      dw_die_ref die;
      struct md5_ctx *ctx;
+     int *mark;
 {
   dw_die_ref c;
   dw_attr_ref a;
 
-  PROCESS (die->die_tag);
+  /* To avoid infinite recursion.  */
+  if (die->die_mark)
+    {
+      CHECKSUM (die->die_mark);
+      return;
+    }
+  die->die_mark = ++(*mark);
+
+  CHECKSUM (die->die_tag);
 
   for (a = die->die_attr; a; a = a->dw_attr_next)
-    attr_checksum (a, ctx);
+    attr_checksum (a, ctx, mark);
 
   for (c = die->die_child; c; c = c->die_sib)
-    die_checksum (c, ctx);
+    die_checksum (c, ctx, mark);
+}
+
+#undef CHECKSUM
+#undef CHECKSUM_STRING
+
+/* Do the location expressions look same?  */
+static inline int
+same_loc_p (loc1, loc2, mark)
+     dw_loc_descr_ref loc1;
+     dw_loc_descr_ref loc2;
+     int *mark;
+{
+  return loc1->dw_loc_opc == loc2->dw_loc_opc
+        && same_dw_val_p (&loc1->dw_loc_oprnd1, &loc2->dw_loc_oprnd1, mark)
+        && same_dw_val_p (&loc1->dw_loc_oprnd2, &loc2->dw_loc_oprnd2, mark);
+}
+
+/* Do the values look the same?  */
+static int
+same_dw_val_p (v1, v2, mark)
+     dw_val_node *v1;
+     dw_val_node *v2;
+     int *mark;
+{
+  dw_loc_descr_ref loc1, loc2;
+  rtx r1, r2;
+  unsigned i;
+
+  if (v1->val_class != v2->val_class)
+    return 0;
+
+  switch (v1->val_class)
+    {
+    case dw_val_class_const:
+      return v1->v.val_int == v2->v.val_int;
+    case dw_val_class_unsigned_const:
+      return v1->v.val_unsigned == v2->v.val_unsigned;
+    case dw_val_class_long_long:
+      return v1->v.val_long_long.hi == v2->v.val_long_long.hi
+             && v1->v.val_long_long.low == v2->v.val_long_long.low;
+    case dw_val_class_float:
+      if (v1->v.val_float.length != v2->v.val_float.length)
+       return 0;
+      for (i = 0; i < v1->v.val_float.length; i++)
+        if (v1->v.val_float.array[i] != v2->v.val_float.array[i])
+         return 0;
+      return 1;
+    case dw_val_class_flag:
+      return v1->v.val_flag == v2->v.val_flag;
+    case dw_val_class_str:
+      return !strcmp((const char *) HT_STR (&v1->v.val_str->id),
+                    (const char *) HT_STR (&v2->v.val_str->id));
+
+    case dw_val_class_addr:
+      r1 = v1->v.val_addr;
+      r2 = v2->v.val_addr;
+      if (GET_CODE (r1) != GET_CODE (r2))
+       return 0;
+      switch (GET_CODE (r1))
+       {
+       case SYMBOL_REF:
+         return !strcmp (XSTR (r1, 0), XSTR (r2, 0));
+
+       default:
+         abort ();
+       }
+
+    case dw_val_class_offset:
+      return v1->v.val_offset == v2->v.val_offset;
+
+    case dw_val_class_loc:
+      for (loc1 = v1->v.val_loc, loc2 = v2->v.val_loc;
+          loc1 && loc2;
+          loc1 = loc1->dw_loc_next, loc2 = loc2->dw_loc_next)
+       if (!same_loc_p (loc1, loc2, mark))
+         return 0;
+      return !loc1 && !loc2;
+
+    case dw_val_class_die_ref:
+      return same_die_p (v1->v.val_die_ref.die, v2->v.val_die_ref.die, mark);
+
+    case dw_val_class_fde_ref:
+    case dw_val_class_lbl_id:
+    case dw_val_class_lbl_offset:
+      return 1;
+
+    default:
+      return 1;
+    }
+}
+
+/* Do the attributes look the same?  */
+
+static int
+same_attr_p (at1, at2, mark)
+     dw_attr_ref at1;
+     dw_attr_ref at2;
+     int *mark;
+{
+  if (at1->dw_attr != at2->dw_attr)
+    return 0;
+
+  /* We don't care about differences in file numbering.  */
+  if (at1->dw_attr == DW_AT_decl_file
+      /* Or that this was compiled with a different compiler snapshot; if
+        the output is the same, that's what matters.  */
+      || at1->dw_attr == DW_AT_producer)
+    return 1;
+
+  return same_dw_val_p (&at1->dw_attr_val, &at2->dw_attr_val, mark);
 }
 
-#undef PROCESS
-#undef PROCESS_STRING
+/* Do the dies look the same?  */
+
+static int
+same_die_p (die1, die2, mark)
+     dw_die_ref die1;
+     dw_die_ref die2;
+     int *mark;
+{
+  dw_die_ref c1, c2;
+  dw_attr_ref a1, a2;
+
+  /* To avoid infinite recursion.  */
+  if (die1->die_mark)
+    return die1->die_mark == die2->die_mark;
+  die1->die_mark = die2->die_mark = ++(*mark);
+
+  if (die1->die_tag != die2->die_tag)
+    return 0;
+
+  for (a1 = die1->die_attr, a2 = die2->die_attr;
+       a1 && a2;
+       a1 = a1->dw_attr_next, a2 = a2->dw_attr_next)
+    if (!same_attr_p (a1, a2, mark))
+      return 0;
+  if (a1 || a2)
+    return 0;
+
+  for (c1 = die1->die_child, c2 = die2->die_child;
+       c1 && c2;
+       c1 = c1->die_sib, c2 = c2->die_sib)
+    if (!same_die_p (c1, c2, mark))
+      return 0;
+  if (c1 || c2)
+    return 0;
+
+  return 1;
+}
+
+/* Do the dies look the same?  Wrapper around same_die_p.  */
+
+static int
+same_die_p_wrap (die1, die2)
+     dw_die_ref die1;
+     dw_die_ref die2;
+{
+  int mark = 0;
+  int ret = same_die_p (die1, die2, &mark);
+
+  unmark_all_dies (die1);
+  unmark_all_dies (die2);
+
+  return ret;
+}
 
 /* The prefix to attach to symbols on DIEs in the current comdat debug
    info section.  */
@@ -5438,37 +5735,38 @@ static void
 compute_section_prefix (unit_die)
      dw_die_ref unit_die;
 {
-  char *name;
-  int i;
+  const char *die_name = get_AT_string (unit_die, DW_AT_name);
+  const char *base = die_name ? lbasename (die_name) : "anonymous";
+  char *name = (char *) alloca (strlen (base) + 64);
+  char *p;
+  int i, mark;
   unsigned char checksum[16];
   struct md5_ctx ctx;
 
+  /* Compute the checksum of the DIE, then append part of it as hex digits to
+     the name filename of the unit.  */
+
   md5_init_ctx (&ctx);
-  die_checksum (unit_die, &ctx);
+  mark = 0;
+  die_checksum (unit_die, &ctx, &mark);
+  unmark_all_dies (unit_die);
   md5_finish_ctx (&ctx, checksum);
 
-  {
-    const char *p = lbasename (get_AT_string (unit_die, DW_AT_name));
-    name = (char *) alloca (strlen (p) + 64);
-    sprintf (name, "%s.", p);
-  }
-
+  sprintf (name, "%s.", base);
   clean_symbol_name (name);
 
-  {
-    char *p = name + strlen (name);
-    for (i = 0; i < 4; ++i)
-      {
-       sprintf (p, "%.2x", checksum[i]);
-       p += 2;
-      }
-  }
+  p = name + strlen (name);
+  for (i = 0; i < 4; i++)
+    {
+      sprintf (p, "%.2x", checksum[i]);
+      p += 2;
+    }
 
   comdat_symbol_id = unit_die->die_symbol = xstrdup (name);
   comdat_symbol_number = 0;
 }
 
-/* Returns nonzero iff DIE represents a type, in the sense of TYPE_P.  */
+/* Returns nonzero if DIE represents a type, in the sense of TYPE_P.  */
 
 static int
 is_type_die (die)
@@ -5493,6 +5791,7 @@ is_type_die (die)
     case DW_TAG_file_type:
     case DW_TAG_packed_type:
     case DW_TAG_volatile_type:
+    case DW_TAG_typedef:
       return 1;
     default:
       return 0;
@@ -5508,12 +5807,11 @@ static int
 is_comdat_die (c)
      dw_die_ref c;
 {
-#if 1
-  /* I think we want to leave base types and __vtbl_ptr_type in the
-     main CU, as we do for stabs.  The advantage is a greater
-     likelihood of sharing between objects that don't include headers
-     in the same order (and therefore would put the base types in a
-     different comdat).  jason 8/28/00 */
+  /* I think we want to leave base types and __vtbl_ptr_type in the main CU, as
+     we do for stabs.  The advantage is a greater likelihood of sharing between
+     objects that don't include headers in the same order (and therefore would
+     put the base types in a different comdat).  jason 8/28/00 */
+
   if (c->die_tag == DW_TAG_base_type)
     return 0;
 
@@ -5523,9 +5821,9 @@ is_comdat_die (c)
       || c->die_tag == DW_TAG_volatile_type)
     {
       dw_die_ref t = get_AT_ref (c, DW_AT_type);
+
       return t ? is_comdat_die (t) : 0;
     }
-#endif
 
   return is_type_die (c);
 }
@@ -5537,20 +5835,18 @@ static int
 is_symbol_die (c)
      dw_die_ref c;
 {
-  if (is_type_die (c))
-    return 1;
-  if (get_AT (c, DW_AT_declaration) 
-      && ! get_AT (c, DW_AT_specification))
-    return 1;
-  return 0;
+  return (is_type_die (c)
+         || (get_AT (c, DW_AT_declaration)
+             && !get_AT (c, DW_AT_specification)));
 }
 
 static char *
 gen_internal_sym (prefix)
-       const char *prefix;
+     const char *prefix;
 {
   char buf[256];
   static int label_num;
+
   ASM_GENERATE_INTERNAL_LABEL (buf, prefix, label_num++);
   return xstrdup (buf);
 }
@@ -5568,6 +5864,7 @@ assign_symbol_names (die)
       if (comdat_symbol_id)
        {
          char *p = alloca (strlen (comdat_symbol_id) + 64);
+
          sprintf (p, "%s.%s.%x", DIE_LABEL_PREFIX,
                   comdat_symbol_id, comdat_symbol_number++);
          die->die_symbol = xstrdup (p);
@@ -5580,6 +5877,104 @@ assign_symbol_names (die)
     assign_symbol_names (c);
 }
 
+struct cu_hash_table_entry
+{
+  dw_die_ref cu;
+  unsigned min_comdat_num, max_comdat_num;
+  struct cu_hash_table_entry *next;
+};
+
+/* Routines to manipulate hash table of CUs.  */
+static hashval_t
+htab_cu_hash (of)
+     const void *of;
+{
+  const struct cu_hash_table_entry *entry = of;
+
+  return htab_hash_string (entry->cu->die_symbol);
+}
+
+static int
+htab_cu_eq (of1, of2)
+     const void *of1;
+     const void *of2;
+{
+  const struct cu_hash_table_entry *entry1 = of1;
+  const struct die_struct *entry2 = of2;
+
+  return !strcmp (entry1->cu->die_symbol, entry2->die_symbol);
+}
+
+static void
+htab_cu_del (what)
+     void *what;
+{
+  struct cu_hash_table_entry *next, *entry = what;
+
+  while (entry)
+    {
+      next = entry->next;
+      free (entry);
+      entry = next;
+    }
+}
+
+/* Check whether we have already seen this CU and set up SYM_NUM
+   accordingly.  */
+static int
+check_duplicate_cu (cu, htable, sym_num)
+     dw_die_ref cu;
+     htab_t htable;
+     unsigned *sym_num;
+{
+  struct cu_hash_table_entry dummy;
+  struct cu_hash_table_entry **slot, *entry, *last = &dummy;
+
+  dummy.max_comdat_num = 0;
+
+  slot = (struct cu_hash_table_entry **)
+    htab_find_slot_with_hash (htable, cu, htab_hash_string (cu->die_symbol),
+       INSERT);
+  entry = *slot;
+
+  for (; entry; last = entry, entry = entry->next)
+    {
+      if (same_die_p_wrap (cu, entry->cu))
+       break;
+    }
+
+  if (entry)
+    {
+      *sym_num = entry->min_comdat_num;
+      return 1;
+    }
+
+  entry = xcalloc (1, sizeof (struct cu_hash_table_entry));
+  entry->cu = cu;
+  entry->min_comdat_num = *sym_num = last->max_comdat_num;
+  entry->next = *slot;
+  *slot = entry;
+
+  return 0;
+}
+
+/* Record SYM_NUM to record of CU in HTABLE.  */
+static void
+record_comdat_symbol_number (cu, htable, sym_num)
+     dw_die_ref cu;
+     htab_t htable;
+     unsigned sym_num;
+{
+  struct cu_hash_table_entry **slot, *entry;
+
+  slot = (struct cu_hash_table_entry **)
+    htab_find_slot_with_hash (htable, cu, htab_hash_string (cu->die_symbol),
+       NO_INSERT);
+  entry = *slot;
+
+  entry->max_comdat_num = sym_num;
+}
+
 /* Traverse the DIE (which is always comp_unit_die), and set up
    additional compilation units for each of the include files we see
    bracketed by BINCL/EINCL.  */
@@ -5590,14 +5985,14 @@ break_out_includes (die)
 {
   dw_die_ref *ptr;
   dw_die_ref unit = NULL;
-  limbo_die_node *node;
+  limbo_die_node *node, **pnode;
+  htab_t cu_hash_table;
 
-  for (ptr = &(die->die_child); *ptr; )
+  for (ptr = &(die->die_child); *ptr;)
     {
       dw_die_ref c = *ptr;
 
-      if (c->die_tag == DW_TAG_GNU_BINCL
-         || c->die_tag == DW_TAG_GNU_EINCL
+      if (c->die_tag == DW_TAG_GNU_BINCL || c->die_tag == DW_TAG_GNU_EINCL
          || (unit && is_comdat_die (c)))
        {
          /* This DIE is for a secondary CU; remove it from the main one.  */
@@ -5632,11 +6027,27 @@ break_out_includes (die)
 #endif
 
   assign_symbol_names (die);
-  for (node = limbo_die_list; node; node = node->next)
+  cu_hash_table = htab_create (10, htab_cu_hash, htab_cu_eq, htab_cu_del);
+  for (node = limbo_die_list, pnode = &limbo_die_list;
+       node;
+       node = node->next)
     {
+      int is_dupl;
+
       compute_section_prefix (node->die);
+      is_dupl = check_duplicate_cu (node->die, cu_hash_table,
+                       &comdat_symbol_number);
       assign_symbol_names (node->die);
+      if (is_dupl)
+       *pnode = node->next;
+      else
+        {
+         pnode = &node->next;
+         record_comdat_symbol_number (node->die, cu_hash_table,
+               comdat_symbol_number);
+       }
     }
+  htab_delete (cu_hash_table);
 }
 
 /* Traverse the DIE and add a sibling attribute if it may have the
@@ -5658,29 +6069,28 @@ add_sibling_attributes (die)
     add_sibling_attributes (c);
 }
 
-/* Output all location lists for the DIE and it's children */
+/* Output all location lists for the DIE and its children.  */
+
 static void
 output_location_lists (die)
      dw_die_ref die;
 {
   dw_die_ref c;
   dw_attr_ref d_attr;
+
   for (d_attr = die->die_attr; d_attr; d_attr = d_attr->dw_attr_next)
-    {
-      if (AT_class (d_attr) == dw_val_class_loc_list)
-       {
-         output_loc_list (AT_loc_list (d_attr));
-       }
-    }
+    if (AT_class (d_attr) == dw_val_class_loc_list)
+      output_loc_list (AT_loc_list (d_attr));
+
   for (c = die->die_child; c != NULL; c = c->die_sib)
     output_location_lists (c);
 
 }
-/* The format of each DIE (and its attribute value pairs)
-   is encoded in an abbreviation table.  This routine builds the
-   abbreviation table and assigns a unique abbreviation id for
-   each abbreviation entry.  The children of each die are visited
-   recursively.  */
+
+/* The format of each DIE (and its attribute value pairs) is encoded in an
+   abbreviation table.  This routine builds the abbreviation table and assigns
+   a unique abbreviation id for each abbreviation entry.  The children of each
+   die are visited recursively.  */
 
 static void
 build_abbrev_table (die)
@@ -5694,15 +6104,14 @@ build_abbrev_table (die)
   /* Scan the DIE references, and mark as external any that refer to
      DIEs from other CUs (i.e. those which are not marked).  */
   for (d_attr = die->die_attr; d_attr; d_attr = d_attr->dw_attr_next)
-    {
-      if (AT_class (d_attr) == dw_val_class_die_ref
-         && AT_ref (d_attr)->die_mark == 0)
-       {
-         if (AT_ref (d_attr)->die_symbol == 0)
-           abort ();
-         set_AT_ref_external (d_attr, 1);
-       }
-    }
+    if (AT_class (d_attr) == dw_val_class_die_ref
+       && AT_ref (d_attr)->die_mark == 0)
+      {
+       if (AT_ref (d_attr)->die_symbol == 0)
+         abort ();
+
+       set_AT_ref_external (d_attr, 1);
+      }
 
   for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
     {
@@ -5773,7 +6182,7 @@ constant_size (value)
   return log;
 }
 
-/* Return the size of a DIE, as it is represented in the
+/* Return the size of a DIE as it is represented in the
    .debug_info section.  */
 
 static unsigned long
@@ -5806,6 +6215,9 @@ size_of_die (die)
        case dw_val_class_loc_list:
          size += DWARF_OFFSET_SIZE;
          break;
+       case dw_val_class_range_list:
+         size += DWARF_OFFSET_SIZE;
+         break;
        case dw_val_class_const:
          size += size_of_sleb128 (AT_int (a));
          break;
@@ -5847,17 +6259,17 @@ size_of_die (die)
   return size;
 }
 
-/* Size the debugging information associated with a given DIE.
-   Visits the DIE's children recursively.  Updates the global
-   variable next_die_offset, on each time through.  Uses the
-   current value of next_die_offset to update the die_offset
-   field in each DIE.  */
+/* Size the debugging information associated with a given DIE.  Visits the
+   DIE's children recursively.  Updates the global variable next_die_offset, on
+   each time through.  Uses the current value of next_die_offset to update the
+   die_offset field in each DIE.  */
 
 static void
 calc_die_sizes (die)
      dw_die_ref die;
 {
   dw_die_ref c;
+
   die->die_offset = next_die_offset;
   next_die_offset += size_of_die (die);
 
@@ -5879,6 +6291,10 @@ mark_dies (die)
      dw_die_ref die;
 {
   dw_die_ref c;
+
+  if (die->die_mark)
+    abort ();
+  
   die->die_mark = 1;
   for (c = die->die_child; c; c = c->die_sib)
     mark_dies (c);
@@ -5891,11 +6307,36 @@ unmark_dies (die)
      dw_die_ref die;
 {
   dw_die_ref c;
+
+  if (!die->die_mark)
+    abort ();
+  
   die->die_mark = 0;
   for (c = die->die_child; c; c = c->die_sib)
     unmark_dies (c);
 }
 
+/* Clear the marks for a die, its children and referred dies.  */
+
+static void
+unmark_all_dies (die)
+     dw_die_ref die;
+{
+  dw_die_ref c;
+  dw_attr_ref a;
+
+  if (!die->die_mark)
+    return;
+  die->die_mark = 0;
+
+  for (c = die->die_child; c; c = c->die_sib)
+    unmark_all_dies (c);
+
+  for (a = die->die_attr; a; a = a->dw_attr_next)
+    if (AT_class (a) == dw_val_class_die_ref)
+      unmark_all_dies (AT_ref (a));
+}
+
 /* Return the size of the .debug_pubnames table  generated for the
    compilation unit.  */
 
@@ -5906,7 +6347,7 @@ size_of_pubnames ()
   unsigned i;
 
   size = DWARF_PUBNAMES_HEADER_SIZE;
-  for (i = 0; i < pubname_table_in_use; ++i)
+  for (i = 0; i < pubname_table_in_use; i++)
     {
       pubname_ref p = &pubname_table[i];
       size += DWARF_OFFSET_SIZE + strlen (p->name) + 1;
@@ -5944,6 +6385,7 @@ value_format (a)
     {
     case dw_val_class_addr:
       return DW_FORM_addr;
+    case dw_val_class_range_list:
     case dw_val_class_offset:
       if (DWARF_OFFSET_SIZE == 4)
        return DW_FORM_data4;
@@ -6012,6 +6454,7 @@ output_value_format (a)
      dw_attr_ref a;
 {
   enum dwarf_form form = value_format (a);
+
   dw2_asm_output_data_uleb128 (form, "(%s)", dwarf_form_name (form));
 }
 
@@ -6024,12 +6467,12 @@ output_abbrev_section ()
   unsigned long abbrev_id;
 
   dw_attr_ref a_attr;
+
   for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
     {
       dw_die_ref abbrev = abbrev_die_table[abbrev_id];
 
       dw2_asm_output_data_uleb128 (abbrev_id, "(abbrev code)");
-
       dw2_asm_output_data_uleb128 (abbrev->die_tag, "(TAG: %s)",
                                   dwarf_tag_name (abbrev->die_tag));
 
@@ -6069,14 +6512,15 @@ output_die_symbol (die)
     /* We make these global, not weak; if the target doesn't support
        .linkonce, it doesn't support combining the sections, so debugging
        will break.  */
-    ASM_GLOBALIZE_LABEL (asm_out_file, sym);
+    (*targetm.asm_out.globalize_label) (asm_out_file, sym);
+
   ASM_OUTPUT_LABEL (asm_out_file, sym);
 }
 
 /* Return a new location list, given the begin and end range, and the
-   expression. gensym tells us whether to generate a new internal
-   symbol for this location list node, which is done for the head of
-   the list only.  */ 
+   expression. gensym tells us whether to generate a new internal symbol for
+   this location list node, which is done for the head of the list only.  */
+
 static inline dw_loc_list_ref
 new_loc_list (expr, begin, end, section, gensym)
      dw_loc_descr_ref expr;
@@ -6087,16 +6531,19 @@ new_loc_list (expr, begin, end, section, gensym)
 {
   dw_loc_list_ref retlist
     = (dw_loc_list_ref) xcalloc (1, sizeof (dw_loc_list_node));
+
   retlist->begin = begin;
   retlist->end = end;
   retlist->expr = expr;
   retlist->section = section;
-  if (gensym) 
+  if (gensym)
     retlist->ll_symbol = gen_internal_sym ("LLST");
+
   return retlist;
 }
 
 /* Add a location description expression to a location list */
+
 static inline void
 add_loc_descr_to_loc_list (list_head, descr, begin, end, section)
      dw_loc_list_ref *list_head;
@@ -6106,20 +6553,23 @@ add_loc_descr_to_loc_list (list_head, descr, begin, end, section)
      const char *section;
 {
   dw_loc_list_ref *d;
-  
+
   /* Find the end of the chain.  */
   for (d = list_head; (*d) != NULL; d = &(*d)->dw_loc_next)
     ;
+
   /* Add a new location list node to the list */
   *d = new_loc_list (descr, begin, end, section, 0);
 }
 
 /* Output the location list given to us */
+
 static void
 output_loc_list (list_head)
      dw_loc_list_ref list_head;
 {
-  dw_loc_list_ref curr=list_head;
+  dw_loc_list_ref curr = list_head;
+
   ASM_OUTPUT_LABEL (asm_out_file, list_head->ll_symbol);
 
   /* ??? This shouldn't be needed now that we've forced the
@@ -6128,14 +6578,16 @@ output_loc_list (list_head)
   if (strcmp (curr->section, ".text") == 0)
     {
       /* dw2_asm_output_data will mask off any extra bits in the ~0.  */
-      dw2_asm_output_data (DWARF2_ADDR_SIZE, ~(unsigned HOST_WIDE_INT)0,
+      dw2_asm_output_data (DWARF2_ADDR_SIZE, ~(unsigned HOST_WIDE_INT) 0,
                           "Location list base address specifier fake entry");
       dw2_asm_output_offset (DWARF2_ADDR_SIZE, curr->section,
                             "Location list base address specifier base");
     }
-  for (curr = list_head; curr != NULL; curr=curr->dw_loc_next)
+
+  for (curr = list_head; curr != NULL; curr = curr->dw_loc_next)
     {
-      int size;
+      unsigned long size;
+
       dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->begin, curr->section,
                            "Location list begin address (%s)",
                            list_head->ll_symbol);
@@ -6143,13 +6595,15 @@ output_loc_list (list_head)
                            "Location list end address (%s)",
                            list_head->ll_symbol);
       size = size_of_locs (curr->expr);
-      
+
       /* Output the block length for this list of location operations.  */
-      dw2_asm_output_data (constant_size (size), size, "%s",
-                          "Location expression size");
-      
+      if (size > 0xffff)
+       abort ();
+      dw2_asm_output_data (2, size, "%s", "Location expression size");
+
       output_loc_sequence (curr->expr);
     }
+
   dw2_asm_output_data (DWARF_OFFSET_SIZE, 0,
                       "Location list terminator begin (%s)",
                       list_head->ll_symbol);
@@ -6192,6 +6646,17 @@ output_die (die)
                               "%s", name);
          break;
 
+       case dw_val_class_range_list:
+         {
+           char *p = strchr (ranges_section_label, '\0');
+
+           sprintf (p, "+0x%lx", a->dw_attr_val.v.val_offset);
+           dw2_asm_output_offset (DWARF_OFFSET_SIZE, ranges_section_label,
+                                  "%s", name);
+           *p = '\0';
+         }
+         break;
+
        case dw_val_class_loc:
          size = size_of_locs (AT_loc (a));
 
@@ -6217,8 +6682,9 @@ output_die (die)
          {
            unsigned HOST_WIDE_INT first, second;
 
-           dw2_asm_output_data (1, 2*HOST_BITS_PER_LONG/HOST_BITS_PER_CHAR,
-                                "%s", name);
+           dw2_asm_output_data (1,
+                                2 * HOST_BITS_PER_LONG / HOST_BITS_PER_CHAR,
+                                "%s", name);
 
            if (WORDS_BIG_ENDIAN)
              {
@@ -6230,9 +6696,10 @@ output_die (die)
                first = a->dw_attr_val.v.val_long_long.low;
                second = a->dw_attr_val.v.val_long_long.hi;
              }
-           dw2_asm_output_data (HOST_BITS_PER_LONG/HOST_BITS_PER_CHAR,
+
+           dw2_asm_output_data (HOST_BITS_PER_LONG / HOST_BITS_PER_CHAR,
                                 first, "long long constant");
-           dw2_asm_output_data (HOST_BITS_PER_LONG/HOST_BITS_PER_CHAR,
+           dw2_asm_output_data (HOST_BITS_PER_LONG / HOST_BITS_PER_CHAR,
                                 second, NULL);
          }
          break;
@@ -6242,9 +6709,9 @@ output_die (die)
            unsigned int i;
 
            dw2_asm_output_data (1, a->dw_attr_val.v.val_float.length * 4,
-                                "%s", name);
+                                "%s", name);
 
-           for (i = 0; i < a->dw_attr_val.v.val_float.length; ++i)
+           for (i = 0; i < a->dw_attr_val.v.val_float.length; i++)
              dw2_asm_output_data (4, a->dw_attr_val.v.val_float.array[i],
                                   "fp constant word %u", i);
            break;
@@ -6254,11 +6721,12 @@ output_die (die)
          dw2_asm_output_data (1, AT_flag (a), "%s", name);
          break;
 
-        case dw_val_class_loc_list:
+       case dw_val_class_loc_list:
          {
            char *sym = AT_loc_list (a)->ll_symbol;
+
            if (sym == 0)
-             abort();
+             abort ();
            dw2_asm_output_delta (DWARF_OFFSET_SIZE, sym,
                                  loc_section_label, "%s", name);
          }
@@ -6268,6 +6736,7 @@ output_die (die)
          if (AT_ref_external (a))
            {
              char *sym = AT_ref (a)->die_symbol;
+
              if (sym == 0)
                abort ();
              dw2_asm_output_offset (DWARF2_ADDR_SIZE, sym, "%s", name);
@@ -6282,6 +6751,7 @@ output_die (die)
        case dw_val_class_fde_ref:
          {
            char l1[20];
+
            ASM_GENERATE_INTERNAL_LABEL (l1, FDE_LABEL,
                                         a->dw_attr_val.v.val_fde_index * 2);
            dw2_asm_output_offset (DWARF_OFFSET_SIZE, l1, "%s", name);
@@ -6300,7 +6770,7 @@ output_die (die)
          if (AT_string_form (a) == DW_FORM_strp)
            dw2_asm_output_offset (DWARF_OFFSET_SIZE,
                                   a->dw_attr_val.v.val_str->label,
-                                  "%s", name);
+                                  "%s: \"%s\"", name, AT_string (a));
          else
            dw2_asm_output_nstring (AT_string (a), -1, "%s", name);
          break;
@@ -6313,12 +6783,10 @@ output_die (die)
   for (c = die->die_child; c != NULL; c = c->die_sib)
     output_die (c);
 
+  /* Add null byte to terminate sibling list.  */
   if (die->die_child != NULL)
-    {
-      /* Add null byte to terminate sibling list.  */
-      dw2_asm_output_data (1, 0, "end of children of DIE 0x%lx",
-                          die->die_offset);
-    }
+    dw2_asm_output_data (1, 0, "end of children of DIE 0x%lx",
+                        die->die_offset);
 }
 
 /* Output the compilation unit that appears at the beginning of the
@@ -6329,30 +6797,31 @@ output_compilation_unit_header ()
 {
   dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset - DWARF_OFFSET_SIZE,
                       "Length of Compilation Unit Info");
-
   dw2_asm_output_data (2, DWARF_VERSION, "DWARF version number");
-
   dw2_asm_output_offset (DWARF_OFFSET_SIZE, abbrev_section_label,
                         "Offset Into Abbrev. Section");
-
   dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
 }
 
 /* Output the compilation unit DIE and its children.  */
 
 static void
-output_comp_unit (die)
+output_comp_unit (die, output_if_empty)
      dw_die_ref die;
+     int output_if_empty;
 {
   const char *secname;
+  char *oldsym, *tmp;
 
-  /* Even if there are no children of this DIE, we must output the
-     information about the compilation unit.  Otherwise, on an empty
-     translation unit, we will generate a present, but empty,
-     .debug_info section.  IRIX 6.5 `nm' will then complain when
-     examining the file.
-     
-     Mark all the DIEs in this CU so we know which get local refs.  */
+  /* Unless we are outputting main CU, we may throw away empty ones.  */
+  if (!output_if_empty && die->die_child == NULL)
+    return;
+
+  /* Even if there are no children of this DIE, we must output the information
+     about the compilation unit.  Otherwise, on an empty translation unit, we
+     will generate a present, but empty, .debug_info section.  IRIX 6.5 `nm'
+     will then complain when examining the file.  First mark all the DIEs in
+     this CU so we know which get local refs.  */
   mark_dies (die);
 
   build_abbrev_table (die);
@@ -6361,10 +6830,12 @@ output_comp_unit (die)
   next_die_offset = DWARF_COMPILE_UNIT_HEADER_SIZE;
   calc_die_sizes (die);
 
-  if (die->die_symbol)
+  oldsym = die->die_symbol;
+  if (oldsym)
     {
-      char *tmp = (char *) alloca (strlen (die->die_symbol) + 24);
-      sprintf (tmp, ".gnu.linkonce.wi.%s", die->die_symbol);
+      tmp = (char *) alloca (strlen (oldsym) + 24);
+
+      sprintf (tmp, ".gnu.linkonce.wi.%s", oldsym);
       secname = tmp;
       die->die_symbol = NULL;
     }
@@ -6378,20 +6849,23 @@ output_comp_unit (die)
 
   /* Leave the marks on the main CU, so we can check them in
      output_pubnames.  */
-  if (die->die_symbol)
-    unmark_dies (die);
+  if (oldsym)
+    {
+      unmark_dies (die);
+      die->die_symbol = oldsym;
+    }
 }
 
-/* The DWARF2 pubname for a nested thingy looks like "A::f".  The output
-   of decl_printable_name for C++ looks like "A::f(int)".  Let's drop the
-   argument list, and maybe the scope.  */
+/* The DWARF2 pubname for a nested thingy looks like "A::f".  The
+   output of lang_hooks.decl_printable_name for C++ looks like
+   "A::f(int)".  Let's drop the argument list, and maybe the scope.  */
 
 static const char *
 dwarf2_name (decl, scope)
      tree decl;
      int scope;
 {
-  return (*decl_printable_name) (decl, scope ? 1 : 0);
+  return (*lang_hooks.decl_printable_name) (decl, scope ? 1 : 0);
 }
 
 /* Add a new entry to .debug_pubnames if appropriate.  */
@@ -6409,13 +6883,14 @@ add_pubname (decl, die)
   if (pubname_table_in_use == pubname_table_allocated)
     {
       pubname_table_allocated += PUBNAME_TABLE_INCREMENT;
-      pubname_table = (pubname_ref) xrealloc
-       (pubname_table, pubname_table_allocated * sizeof (pubname_entry));
+      pubname_table
+       = (pubname_ref) xrealloc (pubname_table,
+                                 (pubname_table_allocated
+                                  * sizeof (pubname_entry)));
     }
 
   p = &pubname_table[pubname_table_in_use++];
   p->die = die;
-
   p->name = xstrdup (dwarf2_name (decl, 1));
 }
 
@@ -6431,16 +6906,13 @@ output_pubnames ()
 
   dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length,
                       "Length of Public Names Info");
-
   dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
-
   dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
                         "Offset of Compilation Unit Info");
-
   dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset,
                       "Compilation Unit Length");
 
-  for (i = 0; i < pubname_table_in_use; ++i)
+  for (i = 0; i < pubname_table_in_use; i++)
     {
       pubname_ref pub = &pubname_table[i];
 
@@ -6489,14 +6961,10 @@ output_aranges ()
 
   dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length,
                       "Length of Address Ranges Info");
-
   dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
-
   dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
                         "Offset of Compilation Unit Info");
-
   dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Size of Address");
-
   dw2_asm_output_data (1, 0, "Size of Segment Descriptor");
 
   /* We need to align to twice the pointer size here.  */
@@ -6514,7 +6982,7 @@ output_aranges ()
   dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label,
                        text_section_label, "Length");
 
-  for (i = 0; i < arange_table_in_use; ++i)
+  for (i = 0; i < arange_table_in_use; i++)
     {
       dw_die_ref die = arange_table[i];
 
@@ -6525,7 +6993,7 @@ output_aranges ()
       if (die->die_tag == DW_TAG_subprogram)
        {
          dw2_asm_output_addr (DWARF2_ADDR_SIZE, get_AT_low_pc (die),
-                                "Address");
+                              "Address");
          dw2_asm_output_delta (DWARF2_ADDR_SIZE, get_AT_hi_pc (die),
                                get_AT_low_pc (die), "Length");
        }
@@ -6534,9 +7002,9 @@ output_aranges ()
          /* A static variable; extract the symbol from DW_AT_location.
             Note that this code isn't currently hit, as we only emit
             aranges for functions (jason 9/23/99).  */
-
          dw_attr_ref a = get_AT (die, DW_AT_location);
          dw_loc_descr_ref loc;
+
          if (! a || AT_class (a) != dw_val_class_loc)
            abort ();
 
@@ -6587,7 +7055,7 @@ output_ranges ()
   static const char *const start_fmt = "Offset 0x%x";
   const char *fmt = start_fmt;
 
-  for (i = 0; i < ranges_table_in_use; ++i)
+  for (i = 0; i < ranges_table_in_use; i++)
     {
       int block_num = ranges_table[i].block_num;
 
@@ -6610,6 +7078,7 @@ output_ranges ()
              dw2_asm_output_delta (DWARF2_ADDR_SIZE, elabel,
                                    text_section_label, NULL);
            }
+
          /* Otherwise, we add a DW_AT_entry_pc attribute to force the
             compilation unit base address to zero, which allows us to
             use absolute addresses, and not worry about whether the
@@ -6697,6 +7166,7 @@ file_info_cmp (p1, p2)
 /* Output the directory table and the file name table.  We try to minimize
    the total amount of memory needed.  A heuristic is used to avoid large
    slowdowns with many input files.  */
+
 static void
 output_file_names ()
 {
@@ -6717,7 +7187,7 @@ output_file_names ()
                                     * sizeof (struct dir_info));
 
   /* Sort the file names.  */
-  for (i = 1; i < (int) file_table.in_use; ++i)
+  for (i = 1; i < (int) file_table.in_use; i++)
     {
       char *f;
 
@@ -6735,6 +7205,7 @@ output_file_names ()
       f = strrchr (f, '/');
       files[i].fname = f == NULL ? files[i].path : f + 1;
     }
+
   qsort (files + 1, file_table.in_use - 1, sizeof (files[0]), file_info_cmp);
 
   /* Find all the different directories used.  */
@@ -6747,7 +7218,7 @@ output_file_names ()
   files[1].dir_idx = 0;
   ndirs = 1;
 
-  for (i = 2; i < (int) file_table.in_use; ++i)
+  for (i = 2; i < (int) file_table.in_use; i++)
     if (files[i].fname - files[i].path == dirs[ndirs - 1].length
        && memcmp (dirs[ndirs - 1].path, files[i].path,
                   dirs[ndirs - 1].length) == 0)
@@ -6770,7 +7241,7 @@ output_file_names ()
 
        /* Search for a prefix.  */
        dirs[ndirs].prefix = -1;
-       for (j = 0; j < ndirs; ++j)
+       for (j = 0; j < ndirs; j++)
          if (dirs[j].length < dirs[ndirs].length
              && dirs[j].length > 1
              && (dirs[ndirs].prefix == -1
@@ -6781,32 +7252,29 @@ output_file_names ()
        ++ndirs;
       }
 
-  /* Now to the actual work.  We have to find a subset of the
-     directories which allow expressing the file name using references
-     to the directory table with the least amount of characters.  We
-     do not do an exhaustive search where we would have to check out
-     every combination of every single possible prefix.  Instead we
-     use a heuristic which provides nearly optimal results in most
-     cases and never is much off.  */
+  /* Now to the actual work.  We have to find a subset of the directories which
+     allow expressing the file name using references to the directory table
+     with the least amount of characters.  We do not do an exhaustive search
+     where we would have to check out every combination of every single
+     possible prefix.  Instead we use a heuristic which provides nearly optimal
+     results in most cases and never is much off.  */
   saved = (int *) alloca (ndirs * sizeof (int));
   savehere = (int *) alloca (ndirs * sizeof (int));
 
   memset (saved, '\0', ndirs * sizeof (saved[0]));
-  for (i = 0; i < ndirs; ++i)
+  for (i = 0; i < ndirs; i++)
     {
       int j;
       int total;
 
-      /* We can always save some space for the current directory.  But
-        this does not mean it will be enough to justify adding the
-        directory.  */
+      /* We can always save some space for the current directory.  But this
+        does not mean it will be enough to justify adding the directory.  */
       savehere[i] = dirs[i].length;
       total = (savehere[i] - saved[i]) * dirs[i].count;
 
-      for (j = i + 1; j < ndirs; ++j)
+      for (j = i + 1; j < ndirs; j++)
        {
          savehere[j] = 0;
-
          if (saved[j] < dirs[i].length)
            {
              /* Determine whether the dirs[i] path is a prefix of the
@@ -6833,7 +7301,7 @@ output_file_names ()
       if (total > dirs[i].length + 1)
        {
          /* It's worthwhile adding.  */
-          for (j = i; j < ndirs; ++j)
+         for (j = i; j < ndirs; j++)
            if (savehere[j] > 0)
              {
                /* Remember how much we saved for this directory so far.  */
@@ -6845,33 +7313,33 @@ output_file_names ()
        }
     }
 
-  /* We have to emit them in the order they appear in the file_table
-     array since the index is used in the debug info generation.  To
-     do this efficiently we generate a back-mapping of the indices
-     first.  */
+  /* We have to emit them in the order they appear in the file_table array
+     since the index is used in the debug info generation.  To do this
+     efficiently we generate a back-mapping of the indices first.  */
   backmap = (int *) alloca (file_table.in_use * sizeof (int));
-  for (i = 1; i < (int) file_table.in_use; ++i)
+  for (i = 1; i < (int) file_table.in_use; i++)
     {
       backmap[files[i].file_idx] = i;
+
       /* Mark this directory as used.  */
       dirs[dirs[files[i].dir_idx].dir_idx].used = 1;
     }
 
-  /* That was it.  We are ready to emit the information.  First the
-     directory name table.  Here we have to make sure that the first
-     actually emitted directory name has the index one.  Zero is
-     reserved for the current working directory.  Make sure we do not
-     confuse these indices with the one for the constructed table
-     (even though most of the time they are identical).  */
+  /* That was it.  We are ready to emit the information.  First emit the
+     directory name table.  We have to make sure the first actually emitted
+     directory name has index one; zero is reserved for the current working
+     directory.  Make sure we do not confuse these indices with the one for the
+     constructed table (even though most of the time they are identical).  */
   idx = 1;
   idx_offset = dirs[0].length > 0 ? 1 : 0;
-  for (i = 1 - idx_offset; i < ndirs; ++i)
+  for (i = 1 - idx_offset; i < ndirs; i++)
     if (dirs[i].used != 0)
       {
        dirs[i].used = idx++;
        dw2_asm_output_nstring (dirs[i].path, dirs[i].length - 1,
                                "Directory Entry: 0x%x", dirs[i].used);
       }
+
   dw2_asm_output_data (1, 0, "End directory table");
 
   /* Correct the index for the current working directory entry if it
@@ -6880,7 +7348,7 @@ output_file_names ()
     dirs[0].used = 0;
 
   /* Now write all the file names.  */
-  for (i = 1; i < (int) file_table.in_use; ++i)
+  for (i = 1; i < (int) file_table.in_use; i++)
     {
       int file_idx = backmap[i];
       int dir_idx = dirs[files[file_idx].dir_idx].dir_idx;
@@ -6897,6 +7365,7 @@ output_file_names ()
       /* File length in bytes.  */
       dw2_asm_output_data_uleb128 (0, NULL);
     }
+
   dw2_asm_output_data (1, 0, "End file name table");
 }
 
@@ -6929,26 +7398,30 @@ output_line_info ()
   ASM_OUTPUT_LABEL (asm_out_file, l1);
 
   dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
-
   dw2_asm_output_delta (DWARF_OFFSET_SIZE, p2, p1, "Prolog Length");
   ASM_OUTPUT_LABEL (asm_out_file, p1);
 
-  dw2_asm_output_data (1, DWARF_LINE_MIN_INSTR_LENGTH,
+  /* Define the architecture-dependent minimum instruction length (in
+   bytes).  In this implementation of DWARF, this field is used for
+   information purposes only.  Since GCC generates assembly language,
+   we have no a priori knowledge of how many instruction bytes are
+   generated for each source line, and therefore can use only the
+   DW_LNE_set_address and DW_LNS_fixed_advance_pc line information
+   commands.  Accordingly, we fix this as `1', which is "correct
+   enough" for all architectures, and don't let the target override.  */
+  dw2_asm_output_data (1, 1,
                       "Minimum Instruction Length");
 
   dw2_asm_output_data (1, DWARF_LINE_DEFAULT_IS_STMT_START,
                       "Default is_stmt_start flag");
-
   dw2_asm_output_data (1, DWARF_LINE_BASE,
                       "Line Base Value (Special Opcodes)");
-
   dw2_asm_output_data (1, DWARF_LINE_RANGE,
                       "Line Range Value (Special Opcodes)");
-
   dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE,
                       "Special Opcode Base");
 
-  for (opc = 1; opc < DWARF_LINE_OPCODE_BASE; ++opc)
+  for (opc = 1; opc < DWARF_LINE_OPCODE_BASE; opc++)
     {
       switch (opc)
        {
@@ -7001,7 +7474,7 @@ output_line_info ()
       /* Emit debug info for the address of the current line.
 
         Unfortunately, we have little choice here currently, and must always
-        use the most general form.  Gcc does not know the address delta
+        use the most general form.  GCC does not know the address delta
         itself, so we can't use DW_LNS_advance_pc.  Many ports do have length
         attributes which will give an upper bound on the address range.  We
         could perhaps use length attributes to determine when it is safe to
@@ -7024,6 +7497,7 @@ output_line_info ()
          dw2_asm_output_data (1, DW_LNE_set_address, NULL);
          dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL);
        }
+
       strcpy (prev_line_label, line_label);
 
       /* Emit debug info for the source file of the current line, if
@@ -7044,13 +7518,11 @@ output_line_info ()
          line_delta = line_offset - DWARF_LINE_BASE;
          current_line = line_info->dw_line_num;
          if (line_delta >= 0 && line_delta < (DWARF_LINE_RANGE - 1))
-           {
-             /* This can handle deltas from -10 to 234, using the current
-                definitions of DWARF_LINE_BASE and DWARF_LINE_RANGE.  This
-                takes 1 byte.  */
-             dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE + line_delta,
-                                  "line %lu", current_line);
-           }
+           /* This can handle deltas from -10 to 234, using the current
+              definitions of DWARF_LINE_BASE and DWARF_LINE_RANGE.  This
+              takes 1 byte.  */
+           dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE + line_delta,
+                                "line %lu", current_line);
          else
            {
              /* This can handle any delta.  This takes at least 4 bytes,
@@ -7062,10 +7534,8 @@ output_line_info ()
            }
        }
       else
-       {
-         /* We still need to start a new row, so output a copy insn.  */
-         dw2_asm_output_data (1, DW_LNS_copy, "DW_LNS_copy");
-       }
+       /* We still need to start a new row, so output a copy insn.  */
+       dw2_asm_output_data (1, DW_LNS_copy, "DW_LNS_copy");
     }
 
   /* Emit debug info for the address of the end of the function.  */
@@ -7135,6 +7605,7 @@ output_line_info ()
              dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL);
            }
        }
+
       strcpy (prev_line_label, line_label);
 
       /* Emit debug info for the source file of the current line, if
@@ -7171,7 +7642,8 @@ output_line_info ()
 #if 0
     cont:
 #endif
-      ++lt_index;
+
+      lt_index++;
 
       /* If we're done with a function, end its sequence.  */
       if (lt_index == separate_line_info_table_in_use
@@ -7222,8 +7694,7 @@ base_type_die (type)
   enum dwarf_type encoding;
   tree name = TYPE_NAME (type);
 
-  if (TREE_CODE (type) == ERROR_MARK
-      || TREE_CODE (type) == VOID_TYPE)
+  if (TREE_CODE (type) == ERROR_MARK || TREE_CODE (type) == VOID_TYPE)
     return 0;
 
   if (name)
@@ -7283,10 +7754,11 @@ base_type_die (type)
       break;
 
     default:
-      abort (); /* No other TREE_CODEs are Dwarf fundamental types.  */
+      /* No other TREE_CODEs are Dwarf fundamental types.  */
+      abort ();
     }
 
-  base_type_result = new_die (DW_TAG_base_type, comp_unit_die);
+  base_type_result = new_die (DW_TAG_base_type, comp_unit_die, type);
   if (demangle_name_func)
     type_name = (*demangle_name_func) (type_name);
 
@@ -7328,7 +7800,7 @@ root_type (type)
     }
 }
 
-/* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
+/* Given a pointer to an arbitrary ..._TYPE tree node, return nonzero if the
    given input type is a Dwarf "fundamental" type.  Otherwise return null.  */
 
 static inline int
@@ -7369,6 +7841,27 @@ is_base_type (type)
   return 0;
 }
 
+/* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
+   node, return the size in bits for the type if it is a constant, or else
+   return the alignment for the type if the type's size is not constant, or
+   else return BITS_PER_WORD if the type actually turns out to be an
+   ERROR_MARK node.  */
+
+static inline unsigned HOST_WIDE_INT
+simple_type_size_in_bits (type)
+     tree type;
+{
+
+  if (TREE_CODE (type) == ERROR_MARK)
+    return BITS_PER_WORD;
+  else if (TYPE_SIZE (type) == NULL_TREE)
+    return 0;
+  else if (host_integerp (TYPE_SIZE (type), 1))
+    return tree_low_cst (TYPE_SIZE (type), 1);
+  else
+    return TYPE_ALIGN (type);
+}
+
 /* Given a pointer to an arbitrary ..._TYPE tree node, return a debugging
    entry that chains various modifiers in front of the given type.  */
 
@@ -7390,11 +7883,12 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
 
       /* See if we already have the appropriately qualified variant of
         this type.  */
-      qualified_type 
+      qualified_type
        = get_qualified_type (type,
                              ((is_const_type ? TYPE_QUAL_CONST : 0)
-                              | (is_volatile_type 
+                              | (is_volatile_type
                                  ? TYPE_QUAL_VOLATILE : 0)));
+
       /* If we do, then we can just use its DIE, if it exists.  */
       if (qualified_type)
        {
@@ -7404,19 +7898,19 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
        }
 
       /* Handle C typedef types.  */
-      if (qualified_type && TYPE_NAME (qualified_type) 
+      if (qualified_type && TYPE_NAME (qualified_type)
          && TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL
          && DECL_ORIGINAL_TYPE (TYPE_NAME (qualified_type)))
        {
          tree type_name = TYPE_NAME (qualified_type);
          tree dtype = TREE_TYPE (type_name);
+
          if (qualified_type == dtype)
            {
              /* For a named type, use the typedef.  */
              gen_type_die (qualified_type, context_die);
              mod_type_die = lookup_type_die (qualified_type);
            }
-
          else if (is_const_type < TYPE_READONLY (dtype)
                   || is_volatile_type < TYPE_VOLATILE (dtype))
            /* cv-unqualified version of named type.  Just use the unnamed
@@ -7425,6 +7919,7 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
              = modified_type_die (DECL_ORIGINAL_TYPE (type_name),
                                   is_const_type, is_volatile_type,
                                   context_die);
+
          /* Else cv-qualified version of named type; fall through.  */
        }
 
@@ -7433,18 +7928,19 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
        ;
       else if (is_const_type)
        {
-         mod_type_die = new_die (DW_TAG_const_type, comp_unit_die);
+         mod_type_die = new_die (DW_TAG_const_type, comp_unit_die, type);
          sub_die = modified_type_die (type, 0, is_volatile_type, context_die);
        }
       else if (is_volatile_type)
        {
-         mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die);
+         mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die, type);
          sub_die = modified_type_die (type, 0, 0, context_die);
        }
       else if (code == POINTER_TYPE)
        {
-         mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die);
-         add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
+         mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die, type);
+         add_AT_unsigned (mod_type_die, DW_AT_byte_size,
+                          simple_type_size_in_bits (type) / BITS_PER_UNIT);
 #if 0
          add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
 #endif
@@ -7452,8 +7948,9 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
        }
       else if (code == REFERENCE_TYPE)
        {
-         mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die);
-         add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
+         mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die, type);
+         add_AT_unsigned (mod_type_die, DW_AT_byte_size,
+                          simple_type_size_in_bits (type) / BITS_PER_UNIT);
 #if 0
          add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
 #endif
@@ -7471,17 +7968,22 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
             copy was created to help us keep track of typedef names) and
             that copy might have a different TYPE_UID from the original
             ..._TYPE node.  */
-         mod_type_die = lookup_type_die (type_main_variant (type));
+         if (TREE_CODE (type) != VECTOR_TYPE)
+           mod_type_die = lookup_type_die (type_main_variant (type));
+         else
+           /* Vectors have the debugging information in the type,
+              not the main variant.  */
+           mod_type_die = lookup_type_die (type);
          if (mod_type_die == NULL)
            abort ();
        }
 
       /* We want to equate the qualified type to the die below.  */
-      if (qualified_type)
-       type = qualified_type;
+      type = qualified_type;
     }
 
-  equate_type_number_to_die (type, mod_type_die);
+  if (type)
+    equate_type_number_to_die (type, mod_type_die);
   if (item_type)
     /* We must do this after the equate_type_number_to_die call, in case
        this is a recursive type.  This ensures that the modified_type_die
@@ -7615,10 +8117,10 @@ static inline int
 is_based_loc (rtl)
      rtx rtl;
 {
-    return (GET_CODE (rtl) == PLUS
-           && ((GET_CODE (XEXP (rtl, 0)) == REG
-                && REGNO (XEXP (rtl, 0)) < FIRST_PSEUDO_REGISTER
-                && GET_CODE (XEXP (rtl, 1)) == CONST_INT)));
+  return (GET_CODE (rtl) == PLUS
+         && ((GET_CODE (XEXP (rtl, 0)) == REG
+              && REGNO (XEXP (rtl, 0)) < FIRST_PSEUDO_REGISTER
+              && GET_CODE (XEXP (rtl, 1)) == CONST_INT)));
 }
 
 /* The following routine converts the RTL for a variable or parameter
@@ -7660,7 +8162,7 @@ mem_loc_descriptor (rtl, mode)
       /* POST_INC and POST_DEC can be handled just like a SUBREG.  So we
         just fall into the SUBREG code.  */
 
-      /* Fall through.  */
+      /* ... fall through ...  */
 
     case SUBREG:
       /* The case of a subreg may arise when we have a local (register)
@@ -7670,7 +8172,7 @@ mem_loc_descriptor (rtl, mode)
          contains the given subreg.  */
       rtl = SUBREG_REG (rtl);
 
-      /* Fall through.  */
+      /* ... fall through ...  */
 
     case REG:
       /* Whenever a register number forms a part of the description of the
@@ -7704,17 +8206,32 @@ mem_loc_descriptor (rtl, mode)
     case SYMBOL_REF:
       /* Alternatively, the symbol in the constant pool might be referenced
         by a different symbol.  */
-      if (GET_CODE (rtl) == SYMBOL_REF
-         && CONSTANT_POOL_ADDRESS_P (rtl))
+      if (GET_CODE (rtl) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (rtl))
        {
-         rtx tmp = get_pool_constant (rtl);
+         bool marked;
+         rtx tmp = get_pool_constant_mark (rtl, &marked);
+
          if (GET_CODE (tmp) == SYMBOL_REF)
-           rtl = tmp;
+           {
+             rtl = tmp;
+             if (CONSTANT_POOL_ADDRESS_P (tmp))
+               get_pool_constant_mark (tmp, &marked);
+             else
+               marked = true;
+           }
+
+         /* If all references to this pool constant were optimized away,
+            it was not output and thus we can't represent it.
+            FIXME: might try to use DW_OP_const_value here, though
+            DW_OP_piece complicates it.  */
+         if (!marked)
+           return 0;
        }
 
       mem_loc_result = new_loc_descr (DW_OP_addr, 0, 0);
       mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_addr;
-      mem_loc_result->dw_loc_oprnd1.v.val_addr = save_rtx (rtl);
+      mem_loc_result->dw_loc_oprnd1.v.val_addr = rtl;
+      VARRAY_PUSH_RTX (used_rtx_varray, rtl);
       break;
 
     case PRE_MODIFY:
@@ -7732,7 +8249,7 @@ mem_loc_descriptor (rtl, mode)
                                   ? GET_MODE_UNIT_SIZE (mode)
                                   : -GET_MODE_UNIT_SIZE (mode)));
 
-      /* Fall through.  */
+      /* ... fall through ...  */
 
     case PLUS:
     plus:
@@ -7780,6 +8297,14 @@ mem_loc_descriptor (rtl, mode)
       mem_loc_result = int_loc_descriptor (INTVAL (rtl));
       break;
 
+    case ADDRESSOF:
+      /* If this is a MEM, return its address.  Otherwise, we can't
+        represent this.  */
+      if (GET_CODE (XEXP (rtl, 0)) == MEM)
+       return mem_loc_descriptor (XEXP (XEXP (rtl, 0), 0), mode);
+      else
+       return 0;
+
     default:
       abort ();
     }
@@ -7838,7 +8363,7 @@ loc_descriptor (rtl)
          contains the given subreg.  */
       rtl = SUBREG_REG (rtl);
 
-      /* Fall through.  */
+      /* ... fall through ...  */
 
     case REG:
       loc_result = reg_loc_descriptor (rtl);
@@ -7859,10 +8384,10 @@ loc_descriptor (rtl)
   return loc_result;
 }
 
-/* Similar, but generate the descriptor from trees instead of rtl.
-   This comes up particularly with variable length arrays.  If ADDRESSP
-   is nonzero, we are looking for an address.  Otherwise, we return a
-   value.  If we can't find a value, return 0.  */
+/* Similar, but generate the descriptor from trees instead of rtl.  This comes
+   up particularly with variable length arrays.  If ADDRESSP is nonzero, we are
+   looking for an address.  Otherwise, we return a value.  If we can't make a
+   descriptor, return 0.  */
 
 static dw_loc_descr_ref
 loc_descriptor_from_tree (loc, addressp)
@@ -7891,11 +8416,64 @@ loc_descriptor_from_tree (loc, addressp)
         the names of types.  */
       return 0;
 
+    case CALL_EXPR:
+      return 0;
+
+    case ADDR_EXPR:
+      /* We can support this only if we can look through conversions and
+        find an INDIRECT_EXPR.  */
+      for (loc = TREE_OPERAND (loc, 0);
+          TREE_CODE (loc) == CONVERT_EXPR || TREE_CODE (loc) == NOP_EXPR
+          || TREE_CODE (loc) == NON_LVALUE_EXPR
+          || TREE_CODE (loc) == VIEW_CONVERT_EXPR
+          || TREE_CODE (loc) == SAVE_EXPR;
+          loc = TREE_OPERAND (loc, 0))
+       ;
+
+       return (TREE_CODE (loc) == INDIRECT_REF
+              ? loc_descriptor_from_tree (TREE_OPERAND (loc, 0), addressp)
+              : 0);
+
     case VAR_DECL:
+      if (DECL_THREAD_LOCAL (loc))
+       {
+         rtx rtl;
+
+#ifndef ASM_OUTPUT_DWARF_DTPREL
+         /* If this is not defined, we have no way to emit the data.  */
+         return 0;
+#endif
+
+         /* The way DW_OP_GNU_push_tls_address is specified, we can only
+            look up addresses of objects in the current module.  */
+         if (DECL_EXTERNAL (loc))
+           return 0;
+
+         rtl = rtl_for_decl_location (loc);
+         if (rtl == NULL_RTX)
+           return 0;
+
+         if (GET_CODE (rtl) != MEM)
+           return 0;
+         rtl = XEXP (rtl, 0);
+         if (! CONSTANT_P (rtl))
+           return 0;
+
+         ret = new_loc_descr (INTERNAL_DW_OP_tls_addr, 0, 0);
+         ret->dw_loc_oprnd1.val_class = dw_val_class_addr;
+         ret->dw_loc_oprnd1.v.val_addr = rtl;
+
+         ret1 = new_loc_descr (DW_OP_GNU_push_tls_address, 0, 0);
+         add_loc_descr (&ret, ret1);
+
+         indirect_p = 1;
+         break;
+       }
+      /* FALLTHRU */
+
     case PARM_DECL:
       {
        rtx rtl = rtl_for_decl_location (loc);
-       enum machine_mode mode = GET_MODE (rtl);
 
        if (rtl == NULL_RTX)
          return 0;
@@ -7908,11 +8486,14 @@ loc_descriptor_from_tree (loc, addressp)
          }
        else
          {
+           enum machine_mode mode = GET_MODE (rtl);
+
            if (GET_CODE (rtl) == MEM)
              {
                indirect_p = 1;
                rtl = XEXP (rtl, 0);
              }
+
            ret = mem_loc_descriptor (rtl, mode);
          }
       }
@@ -7929,6 +8510,7 @@ loc_descriptor_from_tree (loc, addressp)
     case NOP_EXPR:
     case CONVERT_EXPR:
     case NON_LVALUE_EXPR:
+    case VIEW_CONVERT_EXPR:
     case SAVE_EXPR:
       return loc_descriptor_from_tree (TREE_OPERAND (loc, 0), addressp);
 
@@ -7941,18 +8523,16 @@ loc_descriptor_from_tree (loc, addressp)
        HOST_WIDE_INT bitsize, bitpos, bytepos;
        enum machine_mode mode;
        int volatilep;
-       unsigned int alignment;
 
        obj = get_inner_reference (loc, &bitsize, &bitpos, &offset, &mode,
-                                  &unsignedp, &volatilep, &alignment);
+                                  &unsignedp, &volatilep);
 
        if (obj == loc)
          return 0;
 
        ret = loc_descriptor_from_tree (obj, 1);
        if (ret == 0
-           || bitpos % BITS_PER_UNIT != 0
-           || bitsize % BITS_PER_UNIT != 0)
+           || bitpos % BITS_PER_UNIT != 0 || bitsize % BITS_PER_UNIT != 0)
          return 0;
 
        if (offset != NULL_TREE)
@@ -7983,14 +8563,19 @@ loc_descriptor_from_tree (loc, addressp)
        return 0;
       break;
 
+    case TRUTH_AND_EXPR:
+    case TRUTH_ANDIF_EXPR:
     case BIT_AND_EXPR:
       op = DW_OP_and;
       goto do_binop;
 
+    case TRUTH_XOR_EXPR:
     case BIT_XOR_EXPR:
       op = DW_OP_xor;
       goto do_binop;
 
+    case TRUTH_OR_EXPR:
+    case TRUTH_ORIF_EXPR:
     case BIT_IOR_EXPR:
       op = DW_OP_or;
       goto do_binop;
@@ -8037,6 +8622,7 @@ loc_descriptor_from_tree (loc, addressp)
 
       op = DW_OP_plus;
       goto do_binop;
+
     case LE_EXPR:
       if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
        return 0;
@@ -8083,6 +8669,7 @@ loc_descriptor_from_tree (loc, addressp)
       add_loc_descr (&ret, new_loc_descr (op, 0, 0));
       break;
 
+    case TRUTH_NOT_EXPR:
     case BIT_NOT_EXPR:
       op = DW_OP_not;
       goto do_unop;
@@ -8108,7 +8695,8 @@ loc_descriptor_from_tree (loc, addressp)
                   build (LT_EXPR, integer_type_node,
                          TREE_OPERAND (loc, 0), TREE_OPERAND (loc, 1)),
                   TREE_OPERAND (loc, 1), TREE_OPERAND (loc, 0));
-      /* FALLTHRU */
+
+      /* ... fall through ...  */
 
     case COND_EXPR:
       {
@@ -8156,7 +8744,7 @@ loc_descriptor_from_tree (loc, addressp)
 
       if (size > DWARF2_ADDR_SIZE || size == -1)
        return 0;
-      if (size == DWARF2_ADDR_SIZE)
+      else if (size == DWARF2_ADDR_SIZE)
        op = DW_OP_deref;
       else
        op = DW_OP_deref_size;
@@ -8217,35 +8805,12 @@ simple_decl_align_in_bits (decl)
   return (TREE_CODE (decl) != ERROR_MARK) ? DECL_ALIGN (decl) : BITS_PER_WORD;
 }
 
-/* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
-   node, return the size in bits for the type if it is a constant, or else
-   return the alignment for the type if the type's size is not constant, or
-   else return BITS_PER_WORD if the type actually turns out to be an
-   ERROR_MARK node.  */
-
-static inline unsigned HOST_WIDE_INT
-simple_type_size_in_bits (type)
-     tree type;
-{
-  tree type_size_tree;
-
-  if (TREE_CODE (type) == ERROR_MARK)
-    return BITS_PER_WORD;
-  type_size_tree = TYPE_SIZE (type);
-
-  if (type_size_tree == NULL_TREE)
-    return 0;
-  if (! host_integerp (type_size_tree, 1))
-    return TYPE_ALIGN (type);
-  return tree_low_cst (type_size_tree, 1);
-}
-
-/* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
-   return the byte offset of the lowest addressed byte of the "containing
-   object" for the given FIELD_DECL, or return 0 if we are unable to
-   determine what that offset is, either because the argument turns out to
-   be a pointer to an ERROR_MARK node, or because the offset is actually
-   variable.  (We can't handle the latter case just yet).  */
+/* Given a pointer to a FIELD_DECL, compute and return the byte offset of the
+   lowest addressed byte of the "containing object" for the given FIELD_DECL,
+   or return 0 if we are unable to determine what that offset is, either
+   because the argument turns out to be a pointer to an ERROR_MARK node, or
+   because the offset is actually variable.  (We can't handle the latter case
+   just yet).  */
 
 static HOST_WIDE_INT
 field_byte_offset (decl)
@@ -8255,7 +8820,6 @@ field_byte_offset (decl)
   unsigned int decl_align_in_bits;
   unsigned HOST_WIDE_INT type_size_in_bits;
   HOST_WIDE_INT object_offset_in_bits;
-  HOST_WIDE_INT object_offset_in_bytes;
   tree type;
   tree field_size_tree;
   HOST_WIDE_INT bitpos_int;
@@ -8264,8 +8828,7 @@ field_byte_offset (decl)
 
   if (TREE_CODE (decl) == ERROR_MARK)
     return 0;
-
-  if (TREE_CODE (decl) != FIELD_DECL)
+  else if (TREE_CODE (decl) != FIELD_DECL)
     abort ();
 
   type = field_type (decl);
@@ -8294,44 +8857,44 @@ field_byte_offset (decl)
   type_align_in_bits = simple_type_align_in_bits (type);
   decl_align_in_bits = simple_decl_align_in_bits (decl);
 
-  /* Note that the GCC front-end doesn't make any attempt to keep track of
-     the starting bit offset (relative to the start of the containing
-     structure type) of the hypothetical "containing object" for a bit-
-     field.  Thus, when computing the byte offset value for the start of the
-     "containing object" of a bit-field, we must deduce this information on
-     our own. This can be rather tricky to do in some cases.  For example,
-     handling the following structure type definition when compiling for an
-     i386/i486 target (which only aligns long long's to 32-bit boundaries)
-     can be very tricky:
+  /* The GCC front-end doesn't make any attempt to keep track of the starting
+     bit offset (relative to the start of the containing structure type) of the
+     hypothetical "containing object" for a bit-field.  Thus, when computing
+     the byte offset value for the start of the "containing object" of a
+     bit-field, we must deduce this information on our own. This can be rather
+     tricky to do in some cases.  For example, handling the following structure
+     type definition when compiling for an i386/i486 target (which only aligns
+     long long's to 32-bit boundaries) can be very tricky:
 
         struct S { int field1; long long field2:31; };
 
-     Fortunately, there is a simple rule-of-thumb which can be
-     used in such cases.  When compiling for an i386/i486, GCC will allocate
-     8 bytes for the structure shown above.  It decides to do this based upon
-     one simple rule for bit-field allocation.  Quite simply, GCC allocates
-     each "containing object" for each bit-field at the first (i.e. lowest
-     addressed) legitimate alignment boundary (based upon the required
-     minimum alignment for the declared type of the field) which it can
-     possibly use, subject to the condition that there is still enough
-     available space remaining in the containing object (when allocated at
-     the selected point) to fully accommodate all of the bits of the
-     bit-field itself.  This simple rule makes it obvious why GCC allocates
-     8 bytes for each object of the structure type shown above.  When looking
-     for a place to allocate the "containing object" for `field2', the
-     compiler simply tries to allocate a 64-bit "containing object" at each
-     successive 32-bit boundary (starting at zero) until it finds a place to
-     allocate that 64- bit field such that at least 31 contiguous (and
-     previously unallocated) bits remain within that selected 64 bit field.
-     (As it turns out, for the example above, the compiler finds that it is
-     OK to allocate the "containing object" 64-bit field at bit-offset zero
-     within the structure type.) Here we attempt to work backwards from the
-     limited set of facts we're given, and we try to deduce from those facts,
-     where GCC must have believed that the containing object started (within
-     the structure type). The value we deduce is then used (by the callers of
-     this routine) to generate DW_AT_location and DW_AT_bit_offset attributes
-     for fields (both bit-fields and, in the case of DW_AT_location, regular
-     fields as well).  */
+     Fortunately, there is a simple rule-of-thumb which can be used in such
+     cases.  When compiling for an i386/i486, GCC will allocate 8 bytes for the
+     structure shown above.  It decides to do this based upon one simple rule
+     for bit-field allocation.  GCC allocates each "containing object" for each
+     bit-field at the first (i.e. lowest addressed) legitimate alignment
+     boundary (based upon the required minimum alignment for the declared type
+     of the field) which it can possibly use, subject to the condition that
+     there is still enough available space remaining in the containing object
+     (when allocated at the selected point) to fully accommodate all of the
+     bits of the bit-field itself.
+
+     This simple rule makes it obvious why GCC allocates 8 bytes for each
+     object of the structure type shown above.  When looking for a place to
+     allocate the "containing object" for `field2', the compiler simply tries
+     to allocate a 64-bit "containing object" at each successive 32-bit
+     boundary (starting at zero) until it finds a place to allocate that 64-
+     bit field such that at least 31 contiguous (and previously unallocated)
+     bits remain within that selected 64 bit field.  (As it turns out, for the
+     example above, the compiler finds it is OK to allocate the "containing
+     object" 64-bit field at bit-offset zero within the structure type.)
+
+     Here we attempt to work backwards from the limited set of facts we're
+     given, and we try to deduce from those facts, where GCC must have believed
+     that the containing object started (within the structure type). The value
+     we deduce is then used (by the callers of this routine) to generate
+     DW_AT_location and DW_AT_bit_offset attributes for fields (both bit-fields
+     and, in the case of DW_AT_location, regular fields as well).  */
 
   /* Figure out the bit-distance from the start of the structure to the
      "deepest" bit of the bit-field.  */
@@ -8357,9 +8920,7 @@ field_byte_offset (decl)
       object_offset_in_bits *= decl_align_in_bits;
     }
 
-  object_offset_in_bytes = object_offset_in_bits / BITS_PER_UNIT;
-
-  return object_offset_in_bytes;
+  return object_offset_in_bits / BITS_PER_UNIT;
 }
 \f
 /* The following routines define various Dwarf attributes and any data
@@ -8371,64 +8932,111 @@ field_byte_offset (decl)
    whole parameters.  Note that the location attributes for struct fields are
    generated by the routine `data_member_location_attribute' below.  */
 
-static void
-add_AT_location_description (die, attr_kind, rtl)
+static inline void
+add_AT_location_description (die, attr_kind, descr)
      dw_die_ref die;
      enum dwarf_attribute attr_kind;
-     rtx rtl;
+     dw_loc_descr_ref descr;
 {
-  dw_loc_descr_ref descr = loc_descriptor (rtl);
-
   if (descr != 0)
     add_AT_loc (die, attr_kind, descr);
 }
 
-/* Attach the specialized form of location attribute used for data
-   members of struct and union types.  In the special case of a
-   FIELD_DECL node which represents a bit-field, the "offset" part
-   of this special location descriptor must indicate the distance
-   in bytes from the lowest-addressed byte of the containing struct
-   or union type to the lowest-addressed byte of the "containing
-   object" for the bit-field.  (See the `field_byte_offset' function
-   above).. For any given bit-field, the "containing object" is a
-   hypothetical object (of some integral or enum type) within which
-   the given bit-field lives.  The type of this hypothetical
-   "containing object" is always the same as the declared type of
-   the individual bit-field itself (for GCC anyway... the DWARF
-   spec doesn't actually mandate this).  Note that it is the size
-   (in bytes) of the hypothetical "containing object" which will
-   be given in the DW_AT_byte_size attribute for this bit-field.
-   (See the `byte_size_attribute' function below.)  It is also used
-   when calculating the value of the DW_AT_bit_offset attribute.
-   (See the `bit_offset_attribute' function below).  */
+/* Attach the specialized form of location attribute used for data members of
+   struct and union types.  In the special case of a FIELD_DECL node which
+   represents a bit-field, the "offset" part of this special location
+   descriptor must indicate the distance in bytes from the lowest-addressed
+   byte of the containing struct or union type to the lowest-addressed byte of
+   the "containing object" for the bit-field.  (See the `field_byte_offset'
+   function above).
+
+   For any given bit-field, the "containing object" is a hypothetical object
+   (of some integral or enum type) within which the given bit-field lives.  The
+   type of this hypothetical "containing object" is always the same as the
+   declared type of the individual bit-field itself (for GCC anyway... the
+   DWARF spec doesn't actually mandate this).  Note that it is the size (in
+   bytes) of the hypothetical "containing object" which will be given in the
+   DW_AT_byte_size attribute for this bit-field.  (See the
+   `byte_size_attribute' function below.)  It is also used when calculating the
+   value of the DW_AT_bit_offset attribute.  (See the `bit_offset_attribute'
+   function below.)  */
 
 static void
 add_data_member_location_attribute (die, decl)
      dw_die_ref die;
      tree decl;
 {
-  unsigned long offset;
-  dw_loc_descr_ref loc_descr;
-  enum dwarf_location_atom op;
+  long offset;
+  dw_loc_descr_ref loc_descr = 0;
 
   if (TREE_CODE (decl) == TREE_VEC)
-    offset = tree_low_cst (BINFO_OFFSET (decl), 0);
+    {
+      /* We're working on the TAG_inheritance for a base class.  */
+      if (TREE_VIA_VIRTUAL (decl) && is_cxx ())
+       {
+         /* For C++ virtual bases we can't just use BINFO_OFFSET, as they
+            aren't at a fixed offset from all (sub)objects of the same
+            type.  We need to extract the appropriate offset from our
+            vtable.  The following dwarf expression means
+
+              BaseAddr = ObAddr + *((*ObAddr) - Offset)
+
+            This is specific to the V3 ABI, of course.  */
+
+         dw_loc_descr_ref tmp;
+
+         /* Make a copy of the object address.  */
+         tmp = new_loc_descr (DW_OP_dup, 0, 0);
+         add_loc_descr (&loc_descr, tmp);
+
+         /* Extract the vtable address.  */
+         tmp = new_loc_descr (DW_OP_deref, 0, 0);
+         add_loc_descr (&loc_descr, tmp);
+
+         /* Calculate the address of the offset.  */
+         offset = tree_low_cst (BINFO_VPTR_FIELD (decl), 0);
+         if (offset >= 0)
+           abort ();
+
+         tmp = int_loc_descriptor (-offset);
+         add_loc_descr (&loc_descr, tmp);
+         tmp = new_loc_descr (DW_OP_minus, 0, 0);
+         add_loc_descr (&loc_descr, tmp);
+
+         /* Extract the offset.  */
+         tmp = new_loc_descr (DW_OP_deref, 0, 0);
+         add_loc_descr (&loc_descr, tmp);
+
+         /* Add it to the object address.  */
+         tmp = new_loc_descr (DW_OP_plus, 0, 0);
+         add_loc_descr (&loc_descr, tmp);
+       }
+      else
+       offset = tree_low_cst (BINFO_OFFSET (decl), 0);
+    }
   else
     offset = field_byte_offset (decl);
 
-  /* The DWARF2 standard says that we should assume that the structure address
-     is already on the stack, so we can specify a structure field address
-     by using DW_OP_plus_uconst.  */
+  if (! loc_descr)
+    {
+      enum dwarf_location_atom op;
+
+      /* The DWARF2 standard says that we should assume that the structure
+        address is already on the stack, so we can specify a structure field
+        address by using DW_OP_plus_uconst.  */
 
 #ifdef MIPS_DEBUGGING_INFO
-  /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst operator
-     correctly.  It works only if we leave the offset on the stack.  */
-  op = DW_OP_constu;
+      /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst
+        operator correctly.  It works only if we leave the offset on the
+        stack.  */
+      op = DW_OP_constu;
 #else
-  op = DW_OP_plus_uconst;
+      op = DW_OP_plus_uconst;
 #endif
 
-  loc_descr = new_loc_descr (op, offset, 0);
+      loc_descr = new_loc_descr (op, offset, 0);
+    }
+
   add_AT_loc (die, DW_AT_data_member_location, loc_descr);
 }
 
@@ -8453,7 +9061,7 @@ add_const_value_attribute (die, rtl)
         out, and the CONST_INT rtx is assigned VOIDmode.  */
       {
        HOST_WIDE_INT val = INTVAL (rtl);
-       
+
        /* ??? We really should be using HOST_WIDE_INT throughout.  */
        if (val < 0 && (long) val == val)
          add_AT_int (die, DW_AT_const_value, (long) val);
@@ -8482,7 +9090,7 @@ add_const_value_attribute (die, rtl)
        if (GET_MODE_CLASS (mode) == MODE_FLOAT)
          {
            unsigned length = GET_MODE_SIZE (mode) / 4;
-           long *array = (long *) xmalloc (sizeof (long) * length);
+           long *array = (long *) xmalloc (sizeof (long) * length);
            REAL_VALUE_TYPE rv;
 
            REAL_VALUE_FROM_CONST_DOUBLE (rv, rtl);
@@ -8512,6 +9120,7 @@ add_const_value_attribute (die, rtl)
            /* ??? We really should be using HOST_WIDE_INT throughout.  */
            if (HOST_BITS_PER_LONG != HOST_BITS_PER_WIDE_INT)
              abort ();
+
            add_AT_long_long (die, DW_AT_const_value,
                              CONST_DOUBLE_HIGH (rtl), CONST_DOUBLE_LOW (rtl));
          }
@@ -8525,7 +9134,8 @@ add_const_value_attribute (die, rtl)
     case SYMBOL_REF:
     case LABEL_REF:
     case CONST:
-      add_AT_addr (die, DW_AT_const_value, save_rtx (rtl));
+      add_AT_addr (die, DW_AT_const_value, rtl);
+      VARRAY_PUSH_RTX (used_rtx_varray, rtl);
       break;
 
     case PLUS:
@@ -8604,36 +9214,50 @@ rtl_for_decl_location (decl)
      the correct data, so we allow for such exceptional cases below.
 
      Note that our goal here is to describe the place where the given formal
-     parameter lives during most of the function's activation (i.e. between
-     the end of the prologue and the start of the epilogue).  We'll do that
-     as best as we can. Note however that if the given formal parameter is
-     modified sometime during the execution of the function, then a stack
-     backtrace (at debug-time) will show the function as having been
-     called with the *new* value rather than the value which was
-     originally passed in.  This happens rarely enough that it is not
-     a major problem, but it *is* a problem, and I'd like to fix it.
-
-     A future version of dwarf2out.c may generate two additional
-     attributes for any given DW_TAG_formal_parameter DIE which will
-     describe the "passed type" and the "passed location" for the
-     given formal parameter in addition to the attributes we now
-     generate to indicate the "declared type" and the "active
-     location" for each parameter.  This additional set of attributes
-     could be used by debuggers for stack backtraces. Separately, note
-     that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL can be
-     NULL also.  This happens (for example) for inlined-instances of
-     inline function formal parameters which are never referenced.
-     This really shouldn't be happening.  All PARM_DECL nodes should
-     get valid non-NULL DECL_INCOMING_RTL values, but integrate.c
-     doesn't currently generate these values for inlined instances of
-     inline function parameters, so when we see such cases, we are
-     just out-of-luck for the time being (until integrate.c
+     parameter lives during most of the function's activation (i.e. between the
+     end of the prologue and the start of the epilogue).  We'll do that as best
+     as we can. Note however that if the given formal parameter is modified
+     sometime during the execution of the function, then a stack backtrace (at
+     debug-time) will show the function as having been called with the *new*
+     value rather than the value which was originally passed in.  This happens
+     rarely enough that it is not a major problem, but it *is* a problem, and
+     I'd like to fix it.
+
+     A future version of dwarf2out.c may generate two additional attributes for
+     any given DW_TAG_formal_parameter DIE which will describe the "passed
+     type" and the "passed location" for the given formal parameter in addition
+     to the attributes we now generate to indicate the "declared type" and the
+     "active location" for each parameter.  This additional set of attributes
+     could be used by debuggers for stack backtraces. Separately, note that
+     sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL can be NULL also.
+     This happens (for example) for inlined-instances of inline function formal
+     parameters which are never referenced.  This really shouldn't be
+     happening.  All PARM_DECL nodes should get valid non-NULL
+     DECL_INCOMING_RTL values, but integrate.c doesn't currently generate these
+     values for inlined instances of inline function parameters, so when we see
+     such cases, we are just out-of-luck for the time being (until integrate.c
      gets fixed).  */
 
   /* Use DECL_RTL as the "location" unless we find something better.  */
   rtl = DECL_RTL_IF_SET (decl);
 
-  if (TREE_CODE (decl) == PARM_DECL)
+  /* When generating abstract instances, ignore everything except
+     constants and symbols living in memory.  */
+  if (! reload_completed)
+    {
+      if (rtl
+         && (CONSTANT_P (rtl)
+             || (GET_CODE (rtl) == MEM
+                 && CONSTANT_P (XEXP (rtl, 0)))))
+       {
+#ifdef ASM_SIMPLIFY_DWARF_ADDR
+         rtl = ASM_SIMPLIFY_DWARF_ADDR (rtl);
+#endif
+         return rtl;
+       }
+      rtl = NULL_RTX;
+    }
+  else if (TREE_CODE (decl) == PARM_DECL)
     {
       if (rtl == NULL_RTX || is_pseudo_reg (rtl))
        {
@@ -8642,7 +9266,7 @@ rtl_for_decl_location (decl)
 
          /* This decl represents a formal parameter which was optimized out.
             Note that DECL_INCOMING_RTL may be NULL in here, but we handle
-            all* cases where (rtl == NULL_RTX) just below.  */
+            all cases where (rtl == NULL_RTX) just below.  */
          if (declared_type == passed_type)
            rtl = DECL_INCOMING_RTL (decl);
          else if (! BYTES_BIG_ENDIAN
@@ -8680,6 +9304,7 @@ rtl_for_decl_location (decl)
        {
          int offset = (UNITS_PER_WORD
                        - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl))));
+
          rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (decl)),
                             plus_constant (XEXP (rtl, 0), offset));
        }
@@ -8694,16 +9319,56 @@ rtl_for_decl_location (decl)
 #endif
     }
 
-  /* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time
-     constant, and will have been substituted directly into all 
-     expressions that use it.  C does not have such a concept, but
-     C++ and other languages do.  */
-  else if (DECL_INITIAL (decl))
+  /* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time constant,
+     and will have been substituted directly into all expressions that use it.
+     C does not have such a concept, but C++ and other languages do.  */
+  else if (TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl))
     {
-      rtl = expand_expr (DECL_INITIAL (decl), NULL_RTX, VOIDmode,
-                        EXPAND_INITIALIZER);
+      /* If a variable is initialized with a string constant without embedded
+        zeros, build CONST_STRING.  */
+      if (TREE_CODE (DECL_INITIAL (decl)) == STRING_CST
+         && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+       {
+         tree arrtype = TREE_TYPE (decl);
+         tree enttype = TREE_TYPE (arrtype);
+         tree domain = TYPE_DOMAIN (arrtype);
+         tree init = DECL_INITIAL (decl);
+         enum machine_mode mode = TYPE_MODE (enttype);
+
+         if (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) == 1
+             && domain
+             && integer_zerop (TYPE_MIN_VALUE (domain))
+             && compare_tree_int (TYPE_MAX_VALUE (domain),
+                                  TREE_STRING_LENGTH (init) - 1) == 0
+             && ((size_t) TREE_STRING_LENGTH (init)
+                 == strlen (TREE_STRING_POINTER (init)) + 1))
+           rtl = gen_rtx_CONST_STRING (VOIDmode, TREE_STRING_POINTER (init));
+       }
+      /* If the initializer is something that we know will expand into an
+        immediate RTL constant, expand it now.  Expanding anything else
+        tends to produce unresolved symbols; see debug/5770 and c++/6381.  */
+      else if (TREE_CODE (DECL_INITIAL (decl)) == INTEGER_CST
+              || TREE_CODE (DECL_INITIAL (decl)) == REAL_CST)
+       {
+         rtl = expand_expr (DECL_INITIAL (decl), NULL_RTX, VOIDmode,
+                            EXPAND_INITIALIZER);
+         /* If expand_expr returns a MEM, it wasn't immediate.  */
+         if (rtl && GET_CODE (rtl) == MEM)
+           abort ();
+       }
     }
 
+#ifdef ASM_SIMPLIFY_DWARF_ADDR
+  if (rtl)
+    rtl = ASM_SIMPLIFY_DWARF_ADDR (rtl);
+#endif
+
+  /* If we don't look past the constant pool, we risk emitting a
+     reference to a constant pool entry that isn't referenced from
+     code, and thus is not emitted.  */
+  if (rtl)
+    rtl = avoid_constant_pool_reference (rtl);
+
   return rtl;
 }
 
@@ -8724,27 +9389,22 @@ add_location_or_const_value_attribute (die, decl)
      tree decl;
 {
   rtx rtl;
+  dw_loc_descr_ref descr;
 
   if (TREE_CODE (decl) == ERROR_MARK)
     return;
-
-  if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
+  else if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
     abort ();
 
   rtl = rtl_for_decl_location (decl);
   if (rtl == NULL_RTX)
     return;
 
-  /* If we don't look past the constant pool, we risk emitting a
-     reference to a constant pool entry that isn't referenced from
-     code, and thus is not emitted.  */
-  rtl = avoid_constant_pool_reference (rtl);
-
   switch (GET_CODE (rtl))
     {
     case ADDRESSOF:
-      /* The address of a variable that was optimized away; don't emit
-        anything.  */
+      /* The address of a variable that was optimized away;
+        don't emit anything.  */
       break;
 
     case CONST_INT:
@@ -8759,12 +9419,24 @@ add_location_or_const_value_attribute (die, decl)
       break;
 
     case MEM:
-    case REG:
-    case SUBREG:
-    case CONCAT:
-      add_AT_location_description (die, DW_AT_location, rtl);
+      if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
+       {
+         /* Need loc_descriptor_from_tree since that's where we know
+            how to handle TLS variables.  Want the object's address
+            since the top-level DW_AT_location assumes such.  See
+            the confusion in loc_descriptor for reference.  */
+         descr = loc_descriptor_from_tree (decl, 1);
+       }
+      else
+       {
+       case REG:
+       case SUBREG:
+       case CONCAT:
+         descr = loc_descriptor (rtl);
+       }
+      add_AT_location_description (die, DW_AT_location, descr);
       break;
-
+       
     default:
       abort ();
     }
@@ -8793,7 +9465,7 @@ tree_add_const_value_attribute (var_die, decl)
     case INTEGER_TYPE:
       if (host_integerp (init, 0))
        add_AT_unsigned (var_die, DW_AT_const_value,
-                        TREE_INT_CST_LOW (init));
+                        tree_low_cst (init, 0));
       else
        add_AT_long_long (var_die, DW_AT_const_value,
                          TREE_INT_CST_HIGH (init),
@@ -8835,7 +9507,7 @@ add_bound_info (subrange_die, bound_attr, bound)
     case ERROR_MARK:
       return;
 
-    /* All fixed-bounds are represented by INTEGER_CST nodes.        */
+    /* All fixed-bounds are represented by INTEGER_CST nodes.  */
     case INTEGER_CST:
       if (! host_integerp (bound, 0)
          || (bound_attr == DW_AT_lower_bound
@@ -8850,6 +9522,7 @@ add_bound_info (subrange_die, bound_attr, bound)
     case CONVERT_EXPR:
     case NOP_EXPR:
     case NON_LVALUE_EXPR:
+    case VIEW_CONVERT_EXPR:
       add_bound_info (subrange_die, bound_attr, TREE_OPERAND (bound, 0));
       break;
 
@@ -8880,12 +9553,11 @@ add_bound_info (subrange_die, bound_attr, bound)
          && (! optimize || GET_CODE (SAVE_EXPR_RTL (bound)) == MEM))
        {
          dw_die_ref ctx = lookup_decl_die (current_function_decl);
-         dw_die_ref decl_die = new_die (DW_TAG_variable, ctx);
+         dw_die_ref decl_die = new_die (DW_TAG_variable, ctx, bound);
          rtx loc = SAVE_EXPR_RTL (bound);
 
          /* If the RTL for the SAVE_EXPR is memory, handle the case where
             it references an outer function's frame.  */
-
          if (GET_CODE (loc) == MEM)
            {
              rtx new_addr = fix_lexical_addr (XEXP (loc, 0), bound);
@@ -8896,7 +9568,8 @@ add_bound_info (subrange_die, bound_attr, bound)
 
          add_AT_flag (decl_die, DW_AT_artificial, 1);
          add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
-         add_AT_location_description (decl_die, DW_AT_location, loc);
+         add_AT_location_description (decl_die, DW_AT_location,
+                                      loc_descriptor (loc));
          add_AT_die_ref (subrange_die, bound_attr, decl_die);
        }
 
@@ -8935,7 +9608,16 @@ add_bound_info (subrange_die, bound_attr, bound)
        else
          ctx = lookup_decl_die (current_function_decl);
 
-       decl_die = new_die (DW_TAG_variable, ctx);
+       /* If we weren't able to find a context, it's most likely the case
+          that we are processing the return type of the function.  So
+          make a SAVE_EXPR to point to it and have the limbo DIE code
+          find the proper die.  The save_expr function doesn't always
+          make a SAVE_EXPR, so do it ourselves.  */
+       if (ctx == 0)
+         bound = build (SAVE_EXPR, TREE_TYPE (bound), bound,
+                        current_function_decl, NULL_TREE);
+
+       decl_die = new_die (DW_TAG_variable, ctx, bound);
        add_AT_flag (decl_die, DW_AT_artificial, 1);
        add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
        add_AT_loc (decl_die, DW_AT_location, loc);
@@ -8977,14 +9659,14 @@ add_subscript_info (type_die, type)
   for (dimension_number = 0;
        TREE_CODE (type) == ARRAY_TYPE;
        type = TREE_TYPE (type), dimension_number++)
-    {
 #endif
+    {
       tree domain = TYPE_DOMAIN (type);
 
       /* Arrays come in three flavors: Unspecified bounds, fixed bounds,
         and (in GNU C only) variable bounds.  Handle all three forms
          here.  */
-      subrange_die = new_die (DW_TAG_subrange_type, type_die);
+      subrange_die = new_die (DW_TAG_subrange_type, type_die, NULL);
       if (domain)
        {
          /* We have an array type with specified bounds.  */
@@ -9018,15 +9700,11 @@ add_subscript_info (type_die, type)
          if (upper)
            add_bound_info (subrange_die, DW_AT_upper_bound, upper);
        }
-      else
-       /* We have an array type with an unspecified length.  The DWARF-2
-            spec does not say how to handle this; let's just leave out the
-            bounds.  */
-        {;}
 
-#ifndef MIPS_DEBUGGING_INFO
+      /* Otherwise we have an array type with an unspecified length.  The
+        DWARF-2 spec does not say how to handle this; let's just leave out the
+        bounds.  */
     }
-#endif
 }
 
 static void
@@ -9062,7 +9740,6 @@ add_byte_size_attribute (die, tree_node)
      indicates that the byte size of the entity in question is variable.  We
      have no good way of expressing this fact in Dwarf at the present time,
      so just let the -1 pass on through.  */
-
   add_AT_unsigned (die, DW_AT_byte_size, size);
 }
 
@@ -9071,13 +9748,12 @@ add_byte_size_attribute (die, tree_node)
    "containing object" for the bit-field to the highest order bit of the
    bit-field itself.
 
-   For any given bit-field, the "containing object" is a hypothetical
-   object (of some integral or enum type) within which the given bit-field
-   lives.  The type of this hypothetical "containing object" is always the
-   same as the declared type of the individual bit-field itself.  The
-   determination of the exact location of the "containing object" for a
-   bit-field is rather complicated.  It's handled by the
-   `field_byte_offset' function (above).
+   For any given bit-field, the "containing object" is a hypothetical object
+   (of some integral or enum type) within which the given bit-field lives.  The
+   type of this hypothetical "containing object" is always the same as the
+   declared type of the individual bit-field itself.  The determination of the
+   exact location of the "containing object" for a bit-field is rather
+   complicated.  It's handled by the `field_byte_offset' function (above).
 
    Note that it is the size (in bytes) of the hypothetical "containing object"
    which will be given in the DW_AT_byte_size attribute for this bit-field.
@@ -9181,8 +9857,10 @@ add_abstract_origin_attribute (die, origin)
          Doing this for nested functions is wrong, however; functions are
         distinct units, and our context might not even be inline.  */
       tree fn = origin;
+
       if (TYPE_P (fn))
        fn = TYPE_STUB_DECL (fn);
+
       fn = decl_function_context (fn);
       if (fn)
        dwarf2out_abstract_function (fn);
@@ -9260,6 +9938,17 @@ add_name_and_src_coords_attributes (die, decl)
        add_AT_string (die, DW_AT_MIPS_linkage_name,
                       IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
     }
+
+#ifdef VMS_DEBUGGING_INFO
+  /* Get the function's name, as described by its RTL.  This may be different
+     from the DECL_NAME name used in the source file.  */
+  if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl))
+    {
+      add_AT_addr (die, DW_AT_VMS_rtnbeg_pd_address,
+                  XEXP (DECL_RTL (decl), 0));
+      VARRAY_PUSH_RTX (used_rtx_varray, XEXP (DECL_RTL (decl), 0));
+    }
+#endif
 }
 
 /* Push a new declaration scope.  */
@@ -9272,11 +9961,13 @@ push_decl_scope (scope)
 }
 
 /* Pop a declaration scope.  */
+
 static inline void
 pop_decl_scope ()
 {
   if (VARRAY_ACTIVE_SIZE (decl_scope_table) <= 0)
     abort ();
+
   VARRAY_POP (decl_scope_table);
 }
 
@@ -9318,7 +10009,6 @@ scope_die_for (t, 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)
          break;
@@ -9341,9 +10031,8 @@ scope_die_for (t, context_die)
   return scope_die;
 }
 
-/* Returns nonzero iff CONTEXT_DIE is internal to a function.  */
+/* Returns nonzero if CONTEXT_DIE is internal to a function.  */
 
-static inline int local_scope_p PARAMS ((dw_die_ref));
 static inline int
 local_scope_p (context_die)
      dw_die_ref context_die;
@@ -9352,12 +10041,12 @@ local_scope_p (context_die)
     if (context_die->die_tag == DW_TAG_inlined_subroutine
        || context_die->die_tag == DW_TAG_subprogram)
       return 1;
+
   return 0;
 }
 
-/* Returns nonzero iff CONTEXT_DIE is a class.  */
+/* Returns nonzero if CONTEXT_DIE is a class.  */
 
-static inline int class_scope_p PARAMS ((dw_die_ref));
 static inline int
 class_scope_p (context_die)
      dw_die_ref context_die;
@@ -9390,19 +10079,18 @@ add_type_attribute (object_die, type, decl_const, decl_volatile, context_die)
       && TREE_TYPE (type) != 0 && TYPE_NAME (type) == 0)
     type = TREE_TYPE (type), code = TREE_CODE (type);
 
-  if (code == ERROR_MARK)
-    return;
-
-  /* Handle a special case.  For functions whose return type is void, we
-     generate *no* type attribute.  (Note that no object may have type
-     `void', so this only applies to function return types).  */
-  if (code == VOID_TYPE)
+  if (code == ERROR_MARK
+      /* Handle a special case.  For functions whose return type is void, we
+        generate *no* type attribute.  (Note that no object may have type
+        `void', so this only applies to function return types).  */
+      || code == VOID_TYPE)
     return;
 
   type_die = modified_type_die (type,
                                decl_const || TYPE_READONLY (type),
                                decl_volatile || TYPE_VOLATILE (type),
                                context_die);
+
   if (type_die != NULL)
     add_AT_die_ref (object_die, DW_AT_type, type_die);
 }
@@ -9448,8 +10136,7 @@ member_declared_type (member)
      tree member;
 {
   return (DECL_BIT_FIELD_TYPE (member)
-         ? DECL_BIT_FIELD_TYPE (member)
-         : TREE_TYPE (member));
+         ? DECL_BIT_FIELD_TYPE (member) : TREE_TYPE (member));
 }
 
 /* Get the decl's label, as described by its RTL. This may be different
@@ -9462,6 +10149,7 @@ decl_start_label (decl)
 {
   rtx x;
   const char *fnname;
+
   x = DECL_RTL (decl);
   if (GET_CODE (x) != MEM)
     abort ();
@@ -9495,7 +10183,17 @@ gen_array_type_die (type, context_die)
   gen_type_die (TREE_TYPE (type), context_die);
 #endif
 
-  array_die = new_die (DW_TAG_array_type, scope_die);
+  array_die = new_die (DW_TAG_array_type, scope_die, type);
+  add_name_attribute (array_die, type_tag (type));
+  equate_type_number_to_die (type, array_die);
+
+  if (TREE_CODE (type) == VECTOR_TYPE)
+    {
+      /* The frontend feeds us a representation for the vector as a struct
+        containing an array.  Pull out the array type.  */
+      type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
+      add_AT_flag (array_die, DW_AT_GNU_vector, 1);
+    }
 
 #if 0
   /* We default the array ordering.  SDB will probably do
@@ -9517,9 +10215,6 @@ gen_array_type_die (type, context_die)
 #endif
     add_subscript_info (array_die, type);
 
-  add_name_attribute (array_die, type_tag (type));
-  equate_type_number_to_die (type, array_die);
-
   /* Add representation of the type of the elements of this array type.  */
   element_type = TREE_TYPE (type);
 
@@ -9543,7 +10238,7 @@ gen_set_type_die (type, context_die)
      dw_die_ref context_die;
 {
   dw_die_ref type_die
-    = new_die (DW_TAG_set_type, scope_die_for (type, context_die));
+    = new_die (DW_TAG_set_type, scope_die_for (type, context_die), type);
 
   equate_type_number_to_die (type, type_die);
   add_type_attribute (type_die, TREE_TYPE (type), 0, 0, context_die);
@@ -9556,7 +10251,8 @@ gen_entry_point_die (decl, context_die)
      dw_die_ref context_die;
 {
   tree origin = decl_ultimate_origin (decl);
-  dw_die_ref decl_die = new_die (DW_TAG_entry_point, context_die);
+  dw_die_ref decl_die = new_die (DW_TAG_entry_point, context_die, decl);
+
   if (origin != NULL)
     add_abstract_origin_attribute (decl_die, origin);
   else
@@ -9573,14 +10269,6 @@ gen_entry_point_die (decl, context_die)
 }
 #endif
 
-/* Remember a type in the incomplete_types_list.  */
-static void
-add_incomplete_type (type)
-     tree type;
-{
-  VARRAY_PUSH_TREE (incomplete_types, type);
-}
-
 /* Walk through the list of incomplete types again, trying once more to
    emit full debugging info for them.  */
 
@@ -9588,10 +10276,9 @@ static void
 retry_incomplete_types ()
 {
   int i;
+
   for (i = VARRAY_ACTIVE_SIZE (incomplete_types) - 1; i >= 0; i--)
-    {
-      gen_type_die (VARRAY_TREE (incomplete_types, i), comp_unit_die);
-    }
+    gen_type_die (VARRAY_TREE (incomplete_types, i), comp_unit_die);
 }
 
 /* Generate a DIE to represent an inlined instance of an enumeration type.  */
@@ -9601,7 +10288,8 @@ gen_inlined_enumeration_type_die (type, context_die)
      tree type;
      dw_die_ref context_die;
 {
-  dw_die_ref type_die = new_die (DW_TAG_enumeration_type, context_die);
+  dw_die_ref type_die = new_die (DW_TAG_enumeration_type, context_die, type);
+
   /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
      be incomplete and such types are not marked.  */
   add_abstract_origin_attribute (type_die, type);
@@ -9614,7 +10302,7 @@ gen_inlined_structure_type_die (type, context_die)
      tree type;
      dw_die_ref context_die;
 {
-  dw_die_ref type_die = new_die (DW_TAG_structure_type, context_die);
+  dw_die_ref type_die = new_die (DW_TAG_structure_type, context_die, type);
 
   /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
      be incomplete and such types are not marked.  */
@@ -9628,7 +10316,7 @@ gen_inlined_union_type_die (type, context_die)
      tree type;
      dw_die_ref context_die;
 {
-  dw_die_ref type_die = new_die (DW_TAG_union_type, context_die);
+  dw_die_ref type_die = new_die (DW_TAG_union_type, context_die, type);
 
   /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
      be incomplete and such types are not marked.  */
@@ -9650,7 +10338,7 @@ gen_enumeration_type_die (type, context_die)
   if (type_die == NULL)
     {
       type_die = new_die (DW_TAG_enumeration_type,
-                         scope_die_for (type, context_die));
+                         scope_die_for (type, context_die), type);
       equate_type_number_to_die (type, type_die);
       add_name_attribute (type_die, type_tag (type));
     }
@@ -9679,7 +10367,7 @@ gen_enumeration_type_die (type, context_die)
       for (link = TYPE_FIELDS (type);
           link != NULL; link = TREE_CHAIN (link))
        {
-         dw_die_ref enum_die = new_die (DW_TAG_enumerator, type_die);
+         dw_die_ref enum_die = new_die (DW_TAG_enumerator, type_die, link);
 
          add_name_attribute (enum_die,
                              IDENTIFIER_POINTER (TREE_PURPOSE (link)));
@@ -9718,7 +10406,7 @@ gen_formal_parameter_die (node, context_die)
      dw_die_ref context_die;
 {
   dw_die_ref parm_die
-    = new_die (DW_TAG_formal_parameter, context_die);
+    = new_die (DW_TAG_formal_parameter, context_die, node);
   tree origin;
 
   switch (TREE_CODE_CLASS (TREE_CODE (node)))
@@ -9761,10 +10449,10 @@ gen_formal_parameter_die (node, context_die)
 
 static void
 gen_unspecified_parameters_die (decl_or_type, context_die)
-     tree decl_or_type ATTRIBUTE_UNUSED;
+     tree decl_or_type;
      dw_die_ref context_die;
 {
-  new_die (DW_TAG_unspecified_parameters, context_die);
+  new_die (DW_TAG_unspecified_parameters, context_die, decl_or_type);
 }
 
 /* Generate a list of nameless DW_TAG_formal_parameter DIEs (and perhaps a
@@ -9789,7 +10477,7 @@ gen_formal_types_die (function_or_method_type, context_die)
     }
   else
     arg = NULL_TREE;
-  
+
   first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
 
   /* Make our first pass over the list of formal parameter types and output a
@@ -9822,15 +10510,9 @@ gen_formal_types_die (function_or_method_type, context_die)
   /* Make our second (and final) pass over the list of formal parameter types
      and output DIEs to represent those types (as necessary).  */
   for (link = TYPE_ARG_TYPES (function_or_method_type);
-       link;
+       link && TREE_VALUE (link);
        link = TREE_CHAIN (link))
-    {
-      formal_type = TREE_VALUE (link);
-      if (formal_type == void_type_node)
-       break;
-
-      gen_type_die (formal_type, context_die);
-    }
+    gen_type_die (TREE_VALUE (link), context_die);
 }
 
 /* We want to generate the DIE for TYPE so that we can generate the
@@ -9859,13 +10541,13 @@ gen_type_die_for_member (type, member, context_die)
        gen_subprogram_die (member, lookup_type_die (type));
       else
        gen_variable_die (member, lookup_type_die (type));
+
       pop_decl_scope ();
     }
 }
 
-/* Generate the DWARF2 info for the "abstract" instance
-   of a function which we may later generate inlined and/or
-   out-of-line instances of.  */
+/* Generate the DWARF2 info for the "abstract" instance of a function which we
+   may later generate inlined and/or out-of-line instances of.  */
 
 static void
 dwarf2out_abstract_function (decl)
@@ -9879,7 +10561,7 @@ dwarf2out_abstract_function (decl)
   /* Make sure we have the actual abstract inline, not a clone.  */
   decl = DECL_ORIGIN (decl);
 
-  old_die = lookup_decl_die (decl);  
+  old_die = lookup_decl_die (decl);
   if (old_die && get_AT_unsigned (old_die, DW_AT_inline))
     /* We've already generated the abstract instance.  */
     return;
@@ -9893,7 +10575,7 @@ dwarf2out_abstract_function (decl)
        gen_type_die_for_member
          (context, decl, decl_function_context (decl) ? NULL : comp_unit_die);
     }
+
   /* Pretend we've just finished compiling this function.  */
   save_fn = current_function_decl;
   current_function_decl = decl;
@@ -9924,12 +10606,11 @@ gen_subprogram_die (decl, context_die)
   int declaration = (current_function_decl != decl
                     || class_scope_p (context_die));
 
-  /* Note that it is possible to have both DECL_ABSTRACT and `declaration'
-     be true, if we started to generate the abstract instance of an inline,
-     decided to output its containing class, and proceeded to emit the
-     declaration of the inline from the member list for the class.  In that
-     case, `declaration' takes priority; we'll get back to the abstract
-     instance when we're done with the class.  */
+  /* It is possible to have both DECL_ABSTRACT and DECLARATION be true if we
+     started to generate the abstract instance of an inline, decided to output
+     its containing class, and proceeded to emit the declaration of the inline
+     from the member list for the class.  If so, DECLARATION takes priority;
+     we'll get back to the abstract instance when done with the class.  */
 
   /* The class-scope declaration DIE must be the primary DIE.  */
   if (origin && declaration && class_scope_p (context_die))
@@ -9949,7 +10630,7 @@ gen_subprogram_die (decl, context_die)
       if (old_die && old_die->die_parent == NULL)
        add_child_die (context_die, old_die);
 
-      subr_die = new_die (DW_TAG_subprogram, context_die);
+      subr_die = new_die (DW_TAG_subprogram, context_die, decl);
       add_abstract_origin_attribute (subr_die, origin);
     }
   else if (old_die)
@@ -9993,7 +10674,7 @@ gen_subprogram_die (decl, context_die)
        }
       else
        {
-         subr_die = new_die (DW_TAG_subprogram, context_die);
+         subr_die = new_die (DW_TAG_subprogram, context_die, decl);
          add_AT_die_ref (subr_die, DW_AT_specification, old_die);
          if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index)
            add_AT_unsigned (subr_die, DW_AT_decl_file, file_index);
@@ -10005,7 +10686,7 @@ gen_subprogram_die (decl, context_die)
     }
   else
     {
-      subr_die = new_die (DW_TAG_subprogram, context_die);
+      subr_die = new_die (DW_TAG_subprogram, context_die, decl);
 
       if (TREE_PUBLIC (decl))
        add_AT_flag (subr_die, DW_AT_external, 1);
@@ -10013,15 +10694,15 @@ gen_subprogram_die (decl, context_die)
       add_name_and_src_coords_attributes (subr_die, decl);
       if (debug_info_level > DINFO_LEVEL_TERSE)
        {
-         tree type = TREE_TYPE (decl);
-
-         add_prototyped_attribute (subr_die, type);
-         add_type_attribute (subr_die, TREE_TYPE (type), 0, 0, context_die);
+         add_prototyped_attribute (subr_die, TREE_TYPE (decl));
+         add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)),
+                             0, 0, context_die);
        }
 
       add_pure_or_virtual_attribute (subr_die, decl);
       if (DECL_ARTIFICIAL (decl))
        add_AT_flag (subr_die, DW_AT_artificial, 1);
+
       if (TREE_PROTECTED (decl))
        add_AT_unsigned (subr_die, DW_AT_accessibility, DW_ACCESS_protected);
       else if (TREE_PRIVATE (decl))
@@ -10030,7 +10711,7 @@ gen_subprogram_die (decl, context_die)
 
   if (declaration)
     {
-      if (!(old_die && get_AT_unsigned (old_die, DW_AT_inline)))
+      if (!old_die || !get_AT_unsigned (old_die, DW_AT_inline))
        {
          add_AT_flag (subr_die, DW_AT_declaration, 1);
 
@@ -10063,14 +10744,14 @@ gen_subprogram_die (decl, context_die)
     }
   else if (!DECL_EXTERNAL (decl))
     {
-      if (!(old_die && get_AT_unsigned (old_die, DW_AT_inline)))
+      if (!old_die || !get_AT_unsigned (old_die, DW_AT_inline))
        equate_decl_number_to_die (decl, subr_die);
 
       ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_BEGIN_LABEL,
-                                  current_funcdef_number);
+                                  current_function_funcdef_no);
       add_AT_lbl_id (subr_die, DW_AT_low_pc, label_id);
       ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL,
-                                  current_funcdef_number);
+                                  current_function_funcdef_no);
       add_AT_lbl_id (subr_die, DW_AT_high_pc, label_id);
 
       add_pubname (decl, subr_die);
@@ -10093,7 +10774,7 @@ gen_subprogram_die (decl, context_die)
         is not part of the state saved/restored for inline functions.  */
       if (current_function_needs_context)
        add_AT_location_description (subr_die, DW_AT_static_link,
-                                    lookup_static_chain (decl));
+                            loc_descriptor (lookup_static_chain (decl)));
 #endif
     }
 
@@ -10154,19 +10835,19 @@ gen_subprogram_die (decl, context_die)
      (if it has one - it may be just a declaration).  */
   outer_scope = DECL_INITIAL (decl);
 
-  /* Note that here, `outer_scope' is a pointer to the outermost BLOCK
-     node created to represent a function. This outermost BLOCK actually
-     represents the outermost binding contour for the function, i.e. the
-     contour in which the function's formal parameters and labels get
-     declared. Curiously, it appears that the front end doesn't actually
-     put the PARM_DECL nodes for the current function onto the BLOCK_VARS
-     list for this outer scope.  (They are strung off of the DECL_ARGUMENTS
-     list for the function instead.) The BLOCK_VARS list for the
-     `outer_scope' does provide us with a list of the LABEL_DECL nodes for
-     the function however, and we output DWARF info for those in
-     decls_for_scope.  Just within the `outer_scope' there will be a BLOCK
-     node representing the function's outermost pair of curly braces, and
-     any blocks used for the base and member initializers of a C++
+  /* OUTER_SCOPE is a pointer to the outermost BLOCK node created to represent
+     a function.  This BLOCK actually represents the outermost binding contour
+     for the function, i.e. the contour in which the function's formal
+     parameters and labels get declared. Curiously, it appears that the front
+     end doesn't actually put the PARM_DECL nodes for the current function onto
+     the BLOCK_VARS list for this outer scope, but are strung off of the
+     DECL_ARGUMENTS list for the function instead.
+
+     The BLOCK_VARS list for the `outer_scope' does provide us with a list of
+     the LABEL_DECL nodes for the function however, and we output DWARF info
+     for those in decls_for_scope.  Just within the `outer_scope' there will be
+     a BLOCK node representing the function's outermost pair of curly braces,
+     and any blocks used for the base and member initializers of a C++
      constructor function.  */
   if (! declaration && TREE_CODE (outer_scope) != ERROR_MARK)
     {
@@ -10195,7 +10876,7 @@ gen_variable_die (decl, context_die)
      dw_die_ref context_die;
 {
   tree origin = decl_ultimate_origin (decl);
-  dw_die_ref var_die = new_die (DW_TAG_variable, context_die);
+  dw_die_ref var_die = new_die (DW_TAG_variable, context_die, decl);
 
   dw_die_ref old_die = lookup_decl_die (decl);
   int declaration = (DECL_EXTERNAL (decl)
@@ -10203,14 +10884,17 @@ gen_variable_die (decl, context_die)
 
   if (origin != NULL)
     add_abstract_origin_attribute (var_die, origin);
+
   /* Loop unrolling can create multiple blocks that refer to the same
-     static variable, so we must test for the DW_AT_declaration flag.  */
-  /* ??? Loop unrolling/reorder_blocks should perhaps be rewritten to
+     static variable, so we must test for the DW_AT_declaration flag.
+
+     ??? Loop unrolling/reorder_blocks should perhaps be rewritten to
      copy decls and set the DECL_ABSTRACT flag on them instead of
-     sharing them.  */
-  /* ??? Duplicated blocks have been rewritten to use .debug_ranges.  */
+     sharing them.
+
+     ??? Duplicated blocks have been rewritten to use .debug_ranges.  */
   else if (old_die && TREE_STATIC (decl)
-          && get_AT_flag (old_die, DW_AT_declaration) == 1)
+          && get_AT_flag (old_die, DW_AT_declaration) == 1)
     {
       /* This is a definition of a C++ class level static.  */
       add_AT_die_ref (var_die, DW_AT_specification, old_die);
@@ -10231,8 +10915,7 @@ gen_variable_die (decl, context_die)
   else
     {
       add_name_and_src_coords_attributes (var_die, decl);
-      add_type_attribute (var_die, TREE_TYPE (decl),
-                         TREE_READONLY (decl),
+      add_type_attribute (var_die, TREE_TYPE (decl), TREE_READONLY (decl),
                          TREE_THIS_VOLATILE (decl), context_die);
 
       if (TREE_PUBLIC (decl))
@@ -10243,7 +10926,6 @@ gen_variable_die (decl, context_die)
 
       if (TREE_PROTECTED (decl))
        add_AT_unsigned (var_die, DW_AT_accessibility, DW_ACCESS_protected);
-
       else if (TREE_PRIVATE (decl))
        add_AT_unsigned (var_die, DW_AT_accessibility, DW_ACCESS_private);
     }
@@ -10271,7 +10953,7 @@ gen_label_die (decl, context_die)
      dw_die_ref context_die;
 {
   tree origin = decl_ultimate_origin (decl);
-  dw_die_ref lbl_die = new_die (DW_TAG_label, context_die);
+  dw_die_ref lbl_die = new_die (DW_TAG_label, context_die, decl);
   rtx insn;
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -10315,7 +10997,7 @@ gen_lexical_block_die (stmt, context_die, depth)
      dw_die_ref context_die;
      int depth;
 {
-  dw_die_ref stmt_die = new_die (DW_TAG_lexical_block, context_die);
+  dw_die_ref stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
   if (! BLOCK_ABSTRACT (stmt))
@@ -10324,7 +11006,7 @@ gen_lexical_block_die (stmt, context_die, depth)
        {
          tree chain;
 
-         add_AT_offset (stmt_die, DW_AT_ranges, add_ranges (stmt));
+         add_AT_range_list (stmt_die, DW_AT_ranges, add_ranges (stmt));
 
          chain = BLOCK_FRAGMENT_CHAIN (stmt);
          do
@@ -10360,7 +11042,7 @@ gen_inlined_subroutine_die (stmt, context_die, depth)
   if (! BLOCK_ABSTRACT (stmt))
     {
       dw_die_ref subr_die
-       = new_die (DW_TAG_inlined_subroutine, context_die);
+       = new_die (DW_TAG_inlined_subroutine, context_die, stmt);
       tree decl = block_ultimate_origin (stmt);
       char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -10377,6 +11059,20 @@ gen_inlined_subroutine_die (stmt, context_die, depth)
       decls_for_scope (stmt, subr_die, depth);
       current_function_has_inlines = 1;
     }
+  else
+    /* We may get here if we're the outer block of function A that was
+       inlined into function B that was inlined into function C.  When
+       generating debugging info for C, dwarf2out_abstract_function(B)
+       would mark all inlined blocks as abstract, including this one.
+       So, we wouldn't (and shouldn't) expect labels to be generated
+       for this one.  Instead, just emit debugging info for
+       declarations within the block.  This is particularly important
+       in the case of initializers of arguments passed from B to us:
+       if they're statement expressions containing declarations, we
+       wouldn't generate dies for their abstract variables, and then,
+       when generating dies for the real variables, we'd die (pun
+       intended :-)  */
+    gen_lexical_block_die (stmt, context_die, depth);
 }
 
 /* Generate a DIE for a field in a record, or structure.  */
@@ -10386,14 +11082,13 @@ gen_field_die (decl, context_die)
      tree decl;
      dw_die_ref context_die;
 {
-  dw_die_ref decl_die = new_die (DW_TAG_member, context_die);
+  dw_die_ref decl_die = new_die (DW_TAG_member, context_die, decl);
 
   add_name_and_src_coords_attributes (decl_die, decl);
   add_type_attribute (decl_die, member_declared_type (decl),
                      TREE_READONLY (decl), TREE_THIS_VOLATILE (decl),
                      context_die);
 
-  /* If this is a bit field...  */
   if (DECL_BIT_FIELD_TYPE (decl))
     {
       add_byte_size_attribute (decl_die, decl);
@@ -10409,7 +11104,6 @@ gen_field_die (decl, context_die)
 
   if (TREE_PROTECTED (decl))
     add_AT_unsigned (decl_die, DW_AT_accessibility, DW_ACCESS_protected);
-
   else if (TREE_PRIVATE (decl))
     add_AT_unsigned (decl_die, DW_AT_accessibility, DW_ACCESS_private);
 }
@@ -10419,13 +11113,14 @@ gen_field_die (decl, context_die)
    Use modified_type_die instead.
    We keep this code here just in case these types of DIEs may be needed to
    represent certain things in other languages (e.g. Pascal) someday.  */
+
 static void
 gen_pointer_type_die (type, context_die)
      tree type;
      dw_die_ref context_die;
 {
   dw_die_ref ptr_die
-    = new_die (DW_TAG_pointer_type, scope_die_for (type, context_die));
+    = new_die (DW_TAG_pointer_type, scope_die_for (type, context_die), type);
 
   equate_type_number_to_die (type, ptr_die);
   add_type_attribute (ptr_die, TREE_TYPE (type), 0, 0, context_die);
@@ -10436,13 +11131,14 @@ gen_pointer_type_die (type, context_die)
    Use modified_type_die instead.
    We keep this code here just in case these types of DIEs may be needed to
    represent certain things in other languages (e.g. Pascal) someday.  */
+
 static void
 gen_reference_type_die (type, context_die)
      tree type;
      dw_die_ref context_die;
 {
   dw_die_ref ref_die
-    = new_die (DW_TAG_reference_type, scope_die_for (type, context_die));
+    = new_die (DW_TAG_reference_type, scope_die_for (type, context_die), type);
 
   equate_type_number_to_die (type, ref_die);
   add_type_attribute (ref_die, TREE_TYPE (type), 0, 0, context_die);
@@ -10451,13 +11147,15 @@ gen_reference_type_die (type, context_die)
 #endif
 
 /* Generate a DIE for a pointer to a member type.  */
+
 static void
 gen_ptr_to_mbr_type_die (type, context_die)
      tree type;
      dw_die_ref context_die;
 {
   dw_die_ref ptr_die
-    = new_die (DW_TAG_ptr_to_member_type, scope_die_for (type, context_die));
+    = new_die (DW_TAG_ptr_to_member_type,
+              scope_die_for (type, context_die), type);
 
   equate_type_number_to_die (type, ptr_die);
   add_AT_die_ref (ptr_die, DW_AT_containing_type,
@@ -10477,7 +11175,7 @@ gen_compile_unit_die (filename)
   const char *language_string = lang_hooks.name;
   int language;
 
-  die = new_die (DW_TAG_compile_unit, NULL);
+  die = new_die (DW_TAG_compile_unit, NULL, NULL);
   add_name_attribute (die, filename);
 
   if (wd != NULL && filename[0] != DIR_SEPARATOR)
@@ -10508,13 +11206,10 @@ gen_compile_unit_die (filename)
     language = DW_LANG_Pascal83;
   else if (strcmp (language_string, "GNU Java") == 0)
     language = DW_LANG_Java;
-  else if (flag_traditional)
-    language = DW_LANG_C;
   else
     language = DW_LANG_C89;
 
   add_AT_unsigned (die, DW_AT_language, language);
-
   return die;
 }
 
@@ -10526,15 +11221,16 @@ gen_string_type_die (type, context_die)
      dw_die_ref context_die;
 {
   dw_die_ref type_die
-    = new_die (DW_TAG_string_type, scope_die_for (type, context_die));
+    = new_die (DW_TAG_string_type, scope_die_for (type, context_die), type);
 
   equate_type_number_to_die (type, type_die);
 
-  /* Fudge the string length attribute for now.  */
-
-  /* TODO: add string length info.
-   string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
-                             bound_representation (upper_bound, 0, 'u'); */
+  /* ??? Fudge the string length attribute for now.
+     TODO: add string length info.  */
+#if 0
+  string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
+  bound_representation (upper_bound, 0, 'u');
+#endif
 }
 
 /* Generate the DIE for a base class.  */
@@ -10544,13 +11240,14 @@ gen_inheritance_die (binfo, context_die)
      tree binfo;
      dw_die_ref context_die;
 {
-  dw_die_ref die = new_die (DW_TAG_inheritance, context_die);
+  dw_die_ref die = new_die (DW_TAG_inheritance, context_die, binfo);
 
   add_type_attribute (die, BINFO_TYPE (binfo), 0, 0, context_die);
   add_data_member_location_attribute (die, binfo);
 
   if (TREE_VIA_VIRTUAL (binfo))
     add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
+
   if (TREE_VIA_PUBLIC (binfo))
     add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public);
   else if (TREE_VIA_PROTECTED (binfo))
@@ -10575,10 +11272,9 @@ gen_member_die (type, context_die)
      types *within* the list of member DIEs for this (containing) type except
      for those types (of members) which are explicitly marked as also being
      members of this (containing) type themselves.  The g++ front- end can
-     force any given type to be treated as a member of some other
-     (containing) type by setting the TYPE_CONTEXT of the given (member) type
-     to point to the TREE node representing the appropriate (containing)
-     type.  */
+     force any given type to be treated as a member of some other (containing)
+     type by setting the TYPE_CONTEXT of the given (member) type to point to
+     the TREE node representing the appropriate (containing) type.  */
 
   /* First output info about the base classes.  */
   if (TYPE_BINFO (type) && TYPE_BINFO_BASETYPES (type))
@@ -10653,7 +11349,7 @@ gen_struct_or_union_type_die (type, context_die)
 
       type_die = new_die (TREE_CODE (type) == RECORD_TYPE
                          ? DW_TAG_structure_type : DW_TAG_union_type,
-                         scope_die);
+                         scope_die, type);
       equate_type_number_to_die (type, type_die);
       if (old_die)
        add_AT_die_ref (type_die, DW_AT_specification, old_die);
@@ -10698,8 +11394,9 @@ gen_struct_or_union_type_die (type, context_die)
       add_AT_flag (type_die, DW_AT_declaration, 1);
 
       /* We don't need to do this for function-local types.  */
-      if (! decl_function_context (TYPE_STUB_DECL (type)))
-       add_incomplete_type (type);
+      if (TYPE_STUB_DECL (type)
+         && ! decl_function_context (TYPE_STUB_DECL (type)))
+       VARRAY_PUSH_TREE (incomplete_types, type);
     }
 }
 
@@ -10712,7 +11409,8 @@ gen_subroutine_type_die (type, context_die)
 {
   tree return_type = TREE_TYPE (type);
   dw_die_ref subr_die
-    = new_die (DW_TAG_subroutine_type, scope_die_for (type, context_die));
+    = new_die (DW_TAG_subroutine_type,
+              scope_die_for (type, context_die), type);
 
   equate_type_number_to_die (type, subr_die);
   add_prototyped_attribute (subr_die, type);
@@ -10732,15 +11430,16 @@ gen_typedef_die (decl, context_die)
 
   if (TREE_ASM_WRITTEN (decl))
     return;
-  TREE_ASM_WRITTEN (decl) = 1;
 
-  type_die = new_die (DW_TAG_typedef, context_die);
+  TREE_ASM_WRITTEN (decl) = 1;
+  type_die = new_die (DW_TAG_typedef, context_die, decl);
   origin = decl_ultimate_origin (decl);
   if (origin != NULL)
     add_abstract_origin_attribute (type_die, origin);
   else
     {
       tree type;
+
       add_name_and_src_coords_attributes (type_die, decl);
       if (DECL_ORIGINAL_TYPE (decl))
        {
@@ -10753,6 +11452,7 @@ gen_typedef_die (decl, context_die)
        }
       else
        type = TREE_TYPE (decl);
+
       add_type_attribute (type_die, type, TREE_READONLY (decl),
                          TREE_THIS_VOLATILE (decl), context_die);
     }
@@ -10773,10 +11473,13 @@ gen_type_die (type, context_die)
   if (type == NULL_TREE || type == error_mark_node)
     return;
 
-  /* We are going to output a DIE to represent the unqualified version of
-     this type (i.e. without any const or volatile qualifiers) so get the
-     main variant (i.e. the unqualified version) of this type now.  */
-  type = type_main_variant (type);
+  /* We are going to output a DIE to represent the unqualified version
+     of this type (i.e. without any const or volatile qualifiers) so
+     get the main variant (i.e. the unqualified version) of this type
+     now.  (Vectors are special because the debugging info is in the
+     cloned type itself).  */
+  if (TREE_CODE (type) != VECTOR_TYPE)
+    type = type_main_variant (type);
 
   if (TREE_ASM_WRITTEN (type))
     return;
@@ -10784,6 +11487,10 @@ gen_type_die (type, context_die)
   if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
       && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
     {
+      /* Prevent broken recursion; we can't hand off to the same type.  */
+      if (DECL_ORIGINAL_TYPE (TYPE_NAME (type)) == type)
+       abort ();
+
       TREE_ASM_WRITTEN (type) = 1;
       gen_decl_die (TYPE_NAME (type), context_die);
       return;
@@ -10854,20 +11561,19 @@ gen_type_die (type, context_die)
       break;
 
     case VECTOR_TYPE:
-      gen_type_die (TYPE_DEBUG_REPRESENTATION_TYPE (type), context_die);
+      gen_array_type_die (type, context_die);
       break;
 
     case ENUMERAL_TYPE:
     case RECORD_TYPE:
     case UNION_TYPE:
     case QUAL_UNION_TYPE:
-      /* If this is a nested type whose containing class hasn't been
-        written out yet, writing it out will cover this one, too.
-         This does not apply to instantiations of member class templates;
-        they need to be added to the containing class as they are
-        generated.  FIXME: This hurts the idea of combining type decls
-         from multiple TUs, since we can't predict what set of template
-         instantiations we'll get.  */
+      /* If this is a nested type whose containing class hasn't been written
+         out yet, writing it out will cover this one, too.  This does not apply
+         to instantiations of member class templates; they need to be added to
+         the containing class as they are generated.  FIXME: This hurts the
+         idea of combining type decls from multiple TUs, since we can't predict
+         what set of template instantiations we'll get.  */
       if (TYPE_CONTEXT (type)
          && AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
          && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
@@ -10987,8 +11693,9 @@ gen_block_die (stmt, context_die, depth)
     {
       tree sub;
 
-      for (sub= BLOCK_SUBBLOCKS (stmt); sub; sub = BLOCK_CHAIN (sub))
+      for (sub = BLOCK_SUBBLOCKS (stmt); sub; sub = BLOCK_CHAIN (sub))
        gen_block_die (sub, context_die, depth + 1);
+
       return;
     }
 
@@ -11010,12 +11717,11 @@ gen_block_die (stmt, context_die, depth)
     {
       /* In the case where the current block represents an inlining of the
          "body block" of an inline function, we must *NOT* output any DIE for
-         this block because we have already output a DIE to represent the
-         whole inlined function scope and the "body block" of any function
-         doesn't really represent a different scope according to ANSI C
-         rules.  So we check here to make sure that this block does not
-         represent a "body block inlining" before trying to set the
-         `must_output_die' flag.  */
+         this block because we have already output a DIE to represent the whole
+         inlined function scope and the "body block" of any function doesn't
+         really represent a different scope according to ANSI C rules.  So we
+         check here to make sure that this block does not represent a "body
+         block inlining" before trying to set the MUST_OUTPUT_DIE flag.  */
       if (! is_body_block (origin ? origin : stmt))
        {
          /* Determine if this block directly contains any "significant"
@@ -11076,8 +11782,7 @@ decls_for_scope (stmt, context_die, depth)
      declared directly within this block but not within any nested
      sub-blocks.  Also, nested function and tag DIEs have been
      generated with a parent of NULL; fix that up now.  */
-  for (decl = BLOCK_VARS (stmt);
-       decl != NULL; decl = TREE_CHAIN (decl))
+  for (decl = BLOCK_VARS (stmt); decl != NULL; decl = TREE_CHAIN (decl))
     {
       dw_die_ref die;
 
@@ -11131,15 +11836,14 @@ gen_decl_die (decl, context_die)
 {
   tree origin;
 
-  if (TREE_CODE (decl) == ERROR_MARK)
-    return;
-
-  /* If this ..._DECL node is marked to be ignored, then ignore it.  */
-  if (DECL_IGNORED_P (decl))
+  if (DECL_P (decl) && DECL_IGNORED_P (decl))
     return;
 
   switch (TREE_CODE (decl))
     {
+    case ERROR_MARK:
+      break;
+
     case CONST_DECL:
       /* The individual enumerators of an enum type get output when we output
          the Dwarf representation of the relevant enum type itself.  */
@@ -11155,6 +11859,7 @@ gen_decl_die (decl, context_die)
       /* If we're emitting a clone, emit info for the abstract instance.  */
       if (DECL_ORIGIN (decl) != decl)
        dwarf2out_abstract_function (DECL_ABSTRACT_ORIGIN (decl));
+
       /* If we're emitting an out-of-line copy of an inline function,
         emit info for the abstract instance and set up to refer to it.  */
       else if (DECL_INLINE (decl) && ! DECL_ABSTRACT (decl)
@@ -11167,6 +11872,7 @@ gen_decl_die (decl, context_die)
          dwarf2out_abstract_function (decl);
          set_decl_origin_self (decl);
        }
+
       /* Otherwise we're emitting the primary DIE for this decl.  */
       else if (debug_info_level > DINFO_LEVEL_TERSE)
        {
@@ -11194,13 +11900,12 @@ gen_decl_die (decl, context_die)
       if (debug_info_level <= DINFO_LEVEL_TERSE)
        break;
 
-      /* In the special case of a TYPE_DECL node representing the
-         declaration of some type tag, if the given TYPE_DECL is marked as
-         having been instantiated from some other (original) TYPE_DECL node
-         (e.g. one which was generated within the original definition of an
-         inline function) we have to generate a special (abbreviated)
-         DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type
-         DIE here.  */
+      /* In the special case of a TYPE_DECL node representing the declaration
+         of some type tag, if the given TYPE_DECL is marked as having been
+         instantiated from some other (original) TYPE_DECL node (e.g. one which
+         was generated within the original definition of an inline function) we
+         have to generate a special (abbreviated) DW_TAG_structure_type,
+         DW_TAG_union_type, or DW_TAG_enumeration_type DIE here.  */
       if (TYPE_DECL_IS_STUB (decl) && decl_ultimate_origin (decl) != NULL_TREE)
        {
          gen_tagged_type_instantiation_die (TREE_TYPE (decl), context_die);
@@ -11246,8 +11951,8 @@ gen_decl_die (decl, context_die)
       break;
 
     case FIELD_DECL:
-      /* Ignore the nameless fields that are used to skip bits, but
-        handle C++ anonymous unions.  */
+      /* Ignore the nameless fields that are used to skip bits but handle C++
+        anonymous unions.  */
       if (DECL_NAME (decl) != NULL_TREE
          || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE)
        {
@@ -11269,6 +11974,15 @@ gen_decl_die (decl, context_die)
       abort ();
     }
 }
+
+static void
+mark_limbo_die_list (ptr)
+     void *ptr ATTRIBUTE_UNUSED;
+{
+  limbo_die_node *node;
+  for (node = limbo_die_list; node; node = node->next)
+    ggc_mark_tree (node->created_for);
+}
 \f
 /* Add Ada "use" clause information for SGI Workshop debugger.  */
 
@@ -11281,7 +11995,7 @@ dwarf2out_add_library_unit_info (filename, context_list)
 
   if (filename != NULL)
     {
-      dw_die_ref unit_die = new_die (DW_TAG_module, comp_unit_die);
+      dw_die_ref unit_die = new_die (DW_TAG_module, comp_unit_die, NULL);
       tree context_list_decl
        = build_decl (LABEL_DECL, get_identifier (context_list),
                      void_type_node);
@@ -11294,17 +12008,17 @@ dwarf2out_add_library_unit_info (filename, context_list)
     }
 }
 
-/* Debug information for a global DECL.  Called from toplev.c after
+/* Output debug information for global decl DECL.  Called from toplev.c after
    compilation proper has finished.  */
+
 static void
 dwarf2out_global_decl (decl)
      tree decl;
 {
   /* Output DWARF2 information for file-scope tentative data object
-     declarations, file-scope (extern) function declarations (which
-     had no corresponding body) and file-scope tagged type
-     declarations and definitions which have not yet been forced out.  */
-
+     declarations, file-scope (extern) function declarations (which had no
+     corresponding body) and file-scope tagged type declarations and
+     definitions which have not yet been forced out.  */
   if (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))
     dwarf2out_decl (decl);
 }
@@ -11317,15 +12031,11 @@ dwarf2out_decl (decl)
 {
   dw_die_ref context_die = comp_unit_die;
 
-  if (TREE_CODE (decl) == ERROR_MARK)
-    return;
-
-  /* If this ..._DECL node is marked to be ignored, then ignore it.  */
-  if (DECL_IGNORED_P (decl))
-    return;
-
   switch (TREE_CODE (decl))
     {
+    case ERROR_MARK:
+      return;
+
     case FUNCTION_DECL:
       /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a
          builtin function.  Explicit programmer-supplied declarations of
@@ -11342,22 +12052,24 @@ dwarf2out_decl (decl)
          file-scope function declarations which are not also definitions.  If
          and when the debugger needs to know something about these functions,
          it will have to hunt around and find the DWARF information associated
-         with the definition of the function.  Note that we can't just check
-         `DECL_EXTERNAL' to find out which FUNCTION_DECL nodes represent
-         definitions and which ones represent mere declarations.  We have to
-         check `DECL_INITIAL' instead. That's because the C front-end
-         supports some weird semantics for "extern inline" function
-         definitions.  These can get inlined within the current translation
-         unit (an thus, we need to generate DWARF info for their abstract
-         instances so that the DWARF info for the concrete inlined instances
-         can have something to refer to) but the compiler never generates any
-         out-of-lines instances of such things (despite the fact that they
-         *are* definitions).  The important point is that the C front-end
-         marks these "extern inline" functions as DECL_EXTERNAL, but we need
-         to generate DWARF for them anyway. Note that the C++ front-end also
-         plays some similar games for inline function definitions appearing
-         within include files which also contain
-        `#pragma interface' pragmas.  */
+         with the definition of the function.
+
+        We can't just check DECL_EXTERNAL to find out which FUNCTION_DECL
+         nodes represent definitions and which ones represent mere
+         declarations.  We have to check DECL_INITIAL instead. That's because
+         the C front-end supports some weird semantics for "extern inline"
+         function definitions.  These can get inlined within the current
+         translation unit (an thus, we need to generate Dwarf info for their
+         abstract instances so that the Dwarf info for the concrete inlined
+         instances can have something to refer to) but the compiler never
+         generates any out-of-lines instances of such things (despite the fact
+         that they *are* definitions).
+
+        The important point is that the C front-end marks these "extern
+        inline" functions as DECL_EXTERNAL, but we need to generate DWARF for
+        them anyway. Note that the C++ front-end also plays some similar games
+        for inline function definitions appearing within include files which
+        also contain `#pragma interface' pragmas.  */
       if (DECL_INITIAL (decl) == NULL_TREE)
        return;
 
@@ -11366,7 +12078,6 @@ dwarf2out_decl (decl)
         we're a method, it will be ignored, since we already have a DIE.  */
       if (decl_function_context (decl))
        context_die = NULL;
-
       break;
 
     case VAR_DECL:
@@ -11400,7 +12111,8 @@ dwarf2out_decl (decl)
              comparisons have.  */
          if ((get_AT_unsigned (comp_unit_die, DW_AT_language)
               == DW_LANG_C_plus_plus)
-             && TREE_CODE (TREE_TYPE (decl)) == BOOLEAN_TYPE)
+             && TREE_CODE (TREE_TYPE (decl)) == BOOLEAN_TYPE
+             && ! DECL_IGNORED_P (decl))
            modified_type_die (TREE_TYPE (decl), 0, 0, NULL);
 
          return;
@@ -11460,23 +12172,25 @@ dwarf2out_ignore_block (block)
      tree block;
 {
   tree decl;
+
   for (decl = BLOCK_VARS (block); decl; decl = TREE_CHAIN (decl))
     if (TREE_CODE (decl) == FUNCTION_DECL
        || (TREE_CODE (decl) == TYPE_DECL && TYPE_DECL_IS_STUB (decl)))
       return 0;
+
   return 1;
 }
 
-/* Lookup a filename (in the list of filenames that we know about here in
+/* Lookup FILE_NAME (in the list of filenames that we know about here in
    dwarf2out.c) and return its "index".  The index of each (known) filename is
-   just a unique number which is associated with only that one filename.
-   We need such numbers for the sake of generating labels
-   (in the .debug_sfnames section) and references to those
-   files  numbers (in the .debug_srcinfo and.debug_macinfo sections).
-   If the filename given as an argument is not found in our current list,
-   add it to the list and assign it the next available unique index number.
-   In order to speed up searches, we remember the index of the filename
-   was looked up last.  This handles the majority of all searches.  */
+   just a unique number which is associated with only that one filename.  We
+   need such numbers for the sake of generating labels (in the .debug_sfnames
+   section) and references to those files numbers (in the .debug_srcinfo
+   and.debug_macinfo sections).  If the filename given as an argument is not
+   found in our current list, add it to the list and assign it the next
+   available unique index number.  In order to speed up searches, we remember
+   the index of the filename was looked up last.  This handles the majority of
+   all searches.  */
 
 static unsigned
 lookup_filename (file_name)
@@ -11492,11 +12206,12 @@ lookup_filename (file_name)
   /* Check to see if the file name that was searched on the previous
      call matches this file name.  If so, return the index.  */
   if (file_table.last_lookup_index != 0)
-    if (strcmp (file_name, file_table.table[file_table.last_lookup_index]) == 0)
+    if (0 == strcmp (file_name,
+                    file_table.table[file_table.last_lookup_index]))
       return file_table.last_lookup_index;
 
   /* Didn't match the previous lookup, search the table */
-  for (i = 1; i < file_table.in_use; ++i)
+  for (i = 1; i < file_table.in_use; i++)
     if (strcmp (file_name, file_table.table[i]) == 0)
       {
        file_table.last_lookup_index = i;
@@ -11518,7 +12233,11 @@ lookup_filename (file_name)
   file_table.last_lookup_index = i;
 
   if (DWARF2_ASM_LINE_DEBUG_INFO)
-    fprintf (asm_out_file, "\t.file %u \"%s\"\n", i, file_name);
+    {
+      fprintf (asm_out_file, "\t.file %u ", i);
+      output_quoted_string (asm_out_file, file_name);
+      fputc ('\n', asm_out_file);
+    }
 
   return i;
 }
@@ -11561,16 +12280,16 @@ dwarf2out_source_line (line, filename)
          fprintf (asm_out_file, "\t.loc %d %d 0\n", file_num, line);
 
          /* Indicate that line number info exists.  */
-         ++line_info_table_in_use;
+         line_info_table_in_use++;
 
          /* Indicate that multiple line number tables exist.  */
          if (DECL_SECTION_NAME (current_function_decl))
-           ++separate_line_info_table_in_use;
+           separate_line_info_table_in_use++;
        }
       else if (DECL_SECTION_NAME (current_function_decl))
        {
          dw_separate_line_info_ref line_info;
-         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, SEPARATE_LINE_CODE_LABEL,
+         (*targetm.asm_out.internal_label) (asm_out_file, SEPARATE_LINE_CODE_LABEL,
                                     separate_line_info_table_in_use);
 
          /* expand the line info table if necessary */
@@ -11590,13 +12309,13 @@ dwarf2out_source_line (line, filename)
            = &separate_line_info_table[separate_line_info_table_in_use++];
          line_info->dw_file_num = lookup_filename (filename);
          line_info->dw_line_num = line;
-         line_info->function = current_funcdef_number;
+         line_info->function = current_function_funcdef_no;
        }
       else
        {
          dw_line_info_ref line_info;
 
-         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, LINE_CODE_LABEL,
+         (*targetm.asm_out.internal_label) (asm_out_file, LINE_CODE_LABEL,
                                     line_info_table_in_use);
 
          /* Expand the line info table if necessary.  */
@@ -11625,12 +12344,17 @@ dwarf2out_start_source_file (lineno, filename)
      unsigned int lineno;
      const char *filename;
 {
-  if (flag_eliminate_dwarf2_dups)
+  if (flag_eliminate_dwarf2_dups && !is_main_source)
     {
       /* Record the beginning of the file for break_out_includes.  */
-      dw_die_ref bincl_die = new_die (DW_TAG_GNU_BINCL, comp_unit_die);
+      dw_die_ref bincl_die;
+
+      bincl_die = new_die (DW_TAG_GNU_BINCL, comp_unit_die, NULL);
       add_AT_string (bincl_die, DW_AT_name, filename);
     }
+
+  is_main_source = 0;
+
   if (debug_info_level >= DINFO_LEVEL_VERBOSE)
     {
       named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
@@ -11649,10 +12373,9 @@ dwarf2out_end_source_file (lineno)
      unsigned int lineno ATTRIBUTE_UNUSED;
 {
   if (flag_eliminate_dwarf2_dups)
-    {
-      /* Record the end of the file for break_out_includes.  */
-      new_die (DW_TAG_GNU_EINCL, comp_unit_die);
-    }
+    /* Record the end of the file for break_out_includes.  */
+    new_die (DW_TAG_GNU_EINCL, comp_unit_die, NULL);
+
   if (debug_info_level >= DINFO_LEVEL_VERBOSE)
     {
       named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
@@ -11669,12 +12392,6 @@ dwarf2out_define (lineno, buffer)
      unsigned lineno ATTRIBUTE_UNUSED;
      const char *buffer ATTRIBUTE_UNUSED;
 {
-  static int initialized = 0;
-  if (!initialized)
-    {
-      dwarf2out_start_source_file (0, primary_filename);
-      initialized = 1;
-    }
   if (debug_info_level >= DINFO_LEVEL_VERBOSE)
     {
       named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
@@ -11710,12 +12427,9 @@ dwarf2out_init (main_input_filename)
 {
   init_file_table ();
 
-  /* Remember the name of the primary input file.  */
-  primary_filename = main_input_filename;
-
-  /* Add it to the file table first, under the assumption that we'll
-     be emitting line number data for it first, which avoids having
-     to add an initial DW_LNS_set_file.  */
+  /* Add the name of the primary input file to the file table first,
+     under the assumption that we'll be emitting line number data for
+     it first, which avoids having to add an initial DW_LNS_set_file.  */
   lookup_filename (main_input_filename);
 
   /* Allocate the initial hunk of the decl_die_table.  */
@@ -11726,7 +12440,6 @@ dwarf2out_init (main_input_filename)
 
   /* Allocate the initial hunk of the decl_scope_table.  */
   VARRAY_TREE_INIT (decl_scope_table, 256, "decl_scope_table");
-  ggc_add_tree_varray_root (&decl_scope_table, 1);
 
   /* Allocate the initial hunk of the abbrev_die_table.  */
   abbrev_die_table
@@ -11741,6 +12454,7 @@ dwarf2out_init (main_input_filename)
     = (dw_line_info_ref) xcalloc (LINE_INFO_TABLE_INCREMENT,
                                  sizeof (dw_line_info_entry));
   line_info_table_allocated = LINE_INFO_TABLE_INCREMENT;
+
   /* Zero-th entry is allocated, but unused */
   line_info_table_in_use = 1;
 
@@ -11750,12 +12464,13 @@ dwarf2out_init (main_input_filename)
      taken as being relative to the directory from which the compiler was
      invoked when the given (base) source file was compiled.  */
   comp_unit_die = gen_compile_unit_die (main_input_filename);
+  is_main_source = 1;
 
   VARRAY_TREE_INIT (incomplete_types, 64, "incomplete_types");
-  ggc_add_tree_varray_root (&incomplete_types, 1);
 
   VARRAY_RTX_INIT (used_rtx_varray, 32, "used_rtx_varray");
-  ggc_add_rtx_varray_root (&used_rtx_varray, 1);
+
+  ggc_add_root (&limbo_die_list, 1, 1, mark_limbo_die_list);
 
   ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0);
   ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label,
@@ -11764,16 +12479,20 @@ dwarf2out_init (main_input_filename)
     ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
   else
     strcpy (text_section_label, stripattributes (TEXT_SECTION_NAME));
+
   ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label,
                               DEBUG_INFO_SECTION_LABEL, 0);
   ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label,
                               DEBUG_LINE_SECTION_LABEL, 0);
+  ASM_GENERATE_INTERNAL_LABEL (ranges_section_label,
+                              DEBUG_RANGES_SECTION_LABEL, 0);
   named_section_flags (DEBUG_ABBREV_SECTION, SECTION_DEBUG);
   ASM_OUTPUT_LABEL (asm_out_file, abbrev_section_label);
   named_section_flags (DEBUG_INFO_SECTION, SECTION_DEBUG);
   ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label);
   named_section_flags (DEBUG_LINE_SECTION, SECTION_DEBUG);
   ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label);
+
   if (debug_info_level >= DINFO_LEVEL_VERBOSE)
     {
       named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
@@ -11801,6 +12520,7 @@ indirect_string_alloc (tab)
   node->refcount = 0;
   node->form = 0;
   node->label = NULL;
+
   return (hashnode) node;
 }
 
@@ -11813,9 +12533,8 @@ output_indirect_string (pfile, h, v)
      hashnode h;
      const PTR v ATTRIBUTE_UNUSED;
 {
-  struct indirect_string_node *node;
+  struct indirect_string_node *node = (struct indirect_string_node *) h;
 
-  node = (struct indirect_string_node *) h;
   if (node->form == DW_FORM_strp)
     {
       named_section_flags (DEBUG_STR_SECTION, DEBUG_STR_SECTION_FLAGS);
@@ -11823,6 +12542,7 @@ output_indirect_string (pfile, h, v)
       assemble_string ((const char *) HT_STR (&node->id),
                       HT_LEN (&node->id) + 1);
     }
+
   return 1;
 }
 
@@ -11849,15 +12569,48 @@ dwarf2out_finish (input_filename)
       if (die->die_parent == NULL)
        {
          dw_die_ref origin = get_AT_ref (die, DW_AT_abstract_origin);
+         tree context;
+
          if (origin)
            add_child_die (origin->die_parent, die);
          else if (die == comp_unit_die)
            ;
+         /* If this was an expression for a bound involved in a function
+            return type, it may be a SAVE_EXPR for which we weren't able
+            to find a DIE previously.  So try now.  */
+         else if (node->created_for
+                  && TREE_CODE (node->created_for) == SAVE_EXPR
+                  && 0 != (origin = (lookup_decl_die
+                                     (SAVE_EXPR_CONTEXT
+                                      (node->created_for)))))
+           add_child_die (origin, die);
+         else if (errorcount > 0 || sorrycount > 0)
+           /* It's OK to be confused by errors in the input.  */
+           add_child_die (comp_unit_die, die);
+         else if (node->created_for
+                  && ((DECL_P (node->created_for)
+                       && (context = DECL_CONTEXT (node->created_for)))
+                      || (TYPE_P (node->created_for)
+                          && (context = TYPE_CONTEXT (node->created_for))))
+                  && TREE_CODE (context) == FUNCTION_DECL)
+           {
+             /* In certain situations, the lexical block containing a
+                nested function can be optimized away, which results
+                in the nested function die being orphaned.  Likewise
+                with the return type of that nested function.  Force
+                this to be a child of the containing function.  */
+             origin = lookup_decl_die (context);
+             if (! origin)
+               abort ();
+             add_child_die (origin, die);
+           }
          else
            abort ();
        }
+
       free (node);
     }
+
   limbo_die_list = NULL;
 
   /* Walk through the list of incomplete types again, trying once more to
@@ -11881,7 +12634,7 @@ dwarf2out_finish (input_filename)
 
   /* Output a terminator label for the .text section.  */
   text_section ();
-  ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, TEXT_END_LABEL, 0);
+  (*targetm.asm_out.internal_label) (asm_out_file, TEXT_END_LABEL, 0);
 
   /* Output the source line correspondence table.  We must do this
      even if there is no line information.  Otherwise, on an empty
@@ -11913,9 +12666,9 @@ dwarf2out_finish (input_filename)
       add_AT_lbl_id (comp_unit_die, DW_AT_low_pc, text_section_label);
       add_AT_lbl_id (comp_unit_die, DW_AT_high_pc, text_end_label);
     }
-  /* And if it wasn't, we need to give .debug_loc and .debug_ranges
-     an appropriate "base address".  Use zero so that these addresses
-     become absolute.  */
+
+  /* If it wasn't, we need to give .debug_loc and .debug_ranges an appropriate
+     "base address".  Use zero so that these addresses become absolute.  */
   else if (have_location_lists || ranges_table_in_use)
     add_AT_addr (comp_unit_die, DW_AT_entry_pc, const0_rtx);
 
@@ -11929,25 +12682,25 @@ dwarf2out_finish (input_filename)
   /* Output all of the compilation units.  We put the main one last so that
      the offsets are available to output_pubnames.  */
   for (node = limbo_die_list; node; node = node->next)
-    output_comp_unit (node->die);
-  output_comp_unit (comp_unit_die);
+    output_comp_unit (node->die, 0);
+
+  output_comp_unit (comp_unit_die, 0);
 
   /* Output the abbreviation table.  */
   named_section_flags (DEBUG_ABBREV_SECTION, SECTION_DEBUG);
   output_abbrev_section ();
 
+  /* Output public names table if necessary.  */
   if (pubname_table_in_use)
     {
-      /* Output public names table.  */
       named_section_flags (DEBUG_PUBNAMES_SECTION, SECTION_DEBUG);
       output_pubnames ();
     }
 
-  /* We only put functions in the arange table, so don't write it out if
-     we don't have any.  */
+  /* Output the address range information.  We only put functions in the arange
+     table, so don't write it out if we don't have any.  */
   if (fde_table_in_use)
     {
-      /* Output the address range information.  */
       named_section_flags (DEBUG_ARANGES_SECTION, SECTION_DEBUG);
       output_aranges ();
     }
@@ -11956,19 +12709,28 @@ dwarf2out_finish (input_filename)
   if (ranges_table_in_use)
     {
       named_section_flags (DEBUG_RANGES_SECTION, SECTION_DEBUG);
+      ASM_OUTPUT_LABEL (asm_out_file, ranges_section_label);
       output_ranges ();
     }
 
   /* Have to end the primary source file.  */
   if (debug_info_level >= DINFO_LEVEL_VERBOSE)
-    { 
+    {
       named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
       dw2_asm_output_data (1, DW_MACINFO_end_file, "End file");
+      dw2_asm_output_data (1, 0, "End compilation unit");
     }
 
-  /* If we emitted any DW_FORM_strp form attribute, output string
+  /* If we emitted any DW_FORM_strp form attribute, output the string
      table too.  */
   if (debug_str_hash)
     ht_forall (debug_str_hash, output_indirect_string, NULL);
 }
-#endif /* DWARF2_DEBUGGING_INFO || DWARF2_UNWIND_INFO */
+#else
+
+/* This should never be used, but its address is needed for comparisons.  */
+const struct gcc_debug_hooks dwarf2_debug_hooks;
+
+#endif /* DWARF2_DEBUGGING_INFO */
+
+#include "gt-dwarf2out.h"