OSDN Git Service

2002-05-27 H.J. Lu (hjl@gnu.org)
[pf3gnuchains/gcc-fork.git] / gcc / dwarf2out.c
index a5acdb5..f6ef2fa 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).
@@ -22,8 +22,7 @@ along with GCC; see the file COPYING.  If not, write to the Free
 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
-/* TODO: Implement .debug_str handling, and share entries somehow.
-        Emit .debug_line header even when there are no functions, since
+/* TODO: Emit .debug_line header even when there are no functions, since
           the file numbers are used by .debug_info.  Alternately, leave
           out locations for types and decls.
         Avoid talking about ctors and op= for PODs.
@@ -60,6 +59,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "diagnostic.h"
 #include "debug.h"
 #include "target.h"
+#include "langhooks.h"
+#include "hashtable.h"
 
 #ifdef DWARF2_DEBUGGING_INFO
 static void dwarf2out_source_line      PARAMS ((unsigned int, const char *));
@@ -90,6 +91,7 @@ int
 dwarf2out_do_frame ()
 {
   return (write_symbols == DWARF2_DEBUG
+         || write_symbols == VMS_AND_DWARF2_DEBUG
 #ifdef DWARF2_FRAME_INFO
          || DWARF2_FRAME_INFO
 #endif
@@ -230,7 +232,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.  */
@@ -255,6 +257,16 @@ static dw_cfi_ref cie_cfi_head;
    associated with the current function (body) definition.  */
 static unsigned current_funcdef_fde;
 
+struct ht *debug_str_hash;
+
+struct indirect_string_node
+{
+  struct ht_identifier id;
+  unsigned int refcount;
+  unsigned int form;
+  char *label;
+};
+
 /* Forward declarations for functions defined in this file.  */
 
 static char *stripattributes           PARAMS ((const char *));
@@ -262,7 +274,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));
@@ -282,7 +295,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 *));
+static void def_cfa_1                  PARAMS ((const char *,
+                                                dw_cfa_location *));
 
 /* How to start an assembler comment.  */
 #ifndef ASM_COMMENT_START
@@ -305,9 +319,11 @@ static void def_cfa_1                      PARAMS ((const char *, dw_cfa_location *));
 #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"
@@ -328,17 +344,19 @@ static void def_cfa_1                     PARAMS ((const char *, dw_cfa_location *));
 
 #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)
+#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
-#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
@@ -357,6 +375,12 @@ static void def_cfa_1                      PARAMS ((const char *, dw_cfa_location *));
 #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
@@ -365,12 +389,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).  */
 
@@ -399,12 +417,12 @@ 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)
+  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]);
+      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;
@@ -457,8 +475,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:
@@ -517,7 +545,6 @@ dwarf2out_cfi_label ()
 
   ASM_GENERATE_INTERNAL_LABEL (label, "LCFI", label_num++);
   ASM_OUTPUT_LABEL (asm_out_file, label);
-
   return label;
 }
 
@@ -641,6 +668,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;
@@ -658,15 +686,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 ();
 
@@ -706,6 +730,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;
@@ -755,10 +780,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)
@@ -785,6 +808,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);
 }
@@ -801,6 +825,7 @@ dwarf2out_args_size (label, size)
 
   if (size == old_args_size)
     return;
+
   old_args_size = size;
 
   cfi = new_cfi ();
@@ -851,7 +876,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))
     {
@@ -859,6 +884,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);
@@ -869,20 +895,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
@@ -891,6 +922,7 @@ initial_return_save (rtl)
        abort ();
       initial_return_save (XEXP (rtl, 0));
       return;
+
     default:
       abort ();
     }
@@ -903,11 +935,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)
@@ -920,6 +952,8 @@ stack_adjust_offset (pattern)
        return 0;
 
       offset = INTVAL (XEXP (src, 1));
+      if (code == PLUS)
+       offset = -offset;
     }
   else if (GET_CODE (dest) == MEM)
     {
@@ -927,28 +961,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;
 }
 
@@ -960,14 +1013,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);
@@ -975,14 +1027,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)
@@ -997,23 +1049,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;
@@ -1027,6 +1071,7 @@ dwarf2out_stack_adjust (insn)
 #ifndef STACK_GROWS_DOWNWARD
   offset = -offset;
 #endif
+
   args_size += offset;
   if (args_size < 0)
     args_size = 0;
@@ -1071,7 +1116,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;
@@ -1088,13 +1133,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
@@ -1145,7 +1190,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
@@ -1175,7 +1220,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}
@@ -1235,7 +1281,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
 
@@ -1256,28 +1304,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;
     }
 
@@ -1393,6 +1437,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
@@ -1405,6 +1450,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)
@@ -1429,6 +1475,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));
@@ -1443,6 +1490,7 @@ dwarf2out_frame_debug_expr (expr, label)
        default:
          abort ();
        }
+
       def_cfa_1 (label, &cfa);
       break;
 
@@ -1459,18 +1507,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:
@@ -1481,6 +1531,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;
@@ -1541,7 +1592,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;
@@ -1550,13 +1600,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);
@@ -1593,6 +1644,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;
@@ -1606,12 +1658,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);
@@ -1630,12 +1682,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
@@ -1645,12 +1695,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,
@@ -1668,51 +1716,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;
        }
@@ -1738,12 +1816,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)
@@ -1819,7 +1902,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.  */
@@ -1844,13 +1927,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])
@@ -1863,9 +1944,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));
@@ -1875,17 +1958,18 @@ 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->uses_eh_lsda)
        continue;
 
       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, FDE_LABEL, for_eh + i * 2);
@@ -1907,15 +1991,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");
        }
 
@@ -1952,8 +2036,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
@@ -1967,7 +2052,7 @@ 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);
     }
@@ -2012,8 +2097,7 @@ dwarf2out_begin_prologue (line, file)
     return;
 #endif
 
-  ++current_funcdef_number;
-
+  current_funcdef_number++;
   function_section (current_function_decl);
   ASM_GENERATE_INTERNAL_LABEL (label, FUNC_BEGIN_LABEL,
                               current_funcdef_number);
@@ -2051,8 +2135,8 @@ dwarf2out_begin_prologue (line, file)
 
   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);
@@ -2070,7 +2154,7 @@ dwarf2out_end_epilogue ()
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
   /* Output a label to mark the endpoint of the code generated for this
-     function.        */
+     function.  */
   ASM_GENERATE_INTERNAL_LABEL (label, FUNC_END_LABEL, current_funcdef_number);
   ASM_OUTPUT_LABEL (asm_out_file, label);
   fde = &fde_table[fde_table_in_use - 1];
@@ -2099,8 +2183,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);
 }
@@ -2123,6 +2208,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,
@@ -2171,12 +2257,13 @@ 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;
-      char *val_str;
+      struct indirect_string_node *val_str;
       char *val_lbl_id;
       unsigned char val_flag;
     }
@@ -2205,7 +2292,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;
@@ -2674,9 +2762,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);
@@ -2875,6 +2963,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);
@@ -2883,11 +2972,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)
@@ -2903,6 +2993,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:
@@ -2988,7 +3079,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));
        }
     }
@@ -2998,6 +3089,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 *));
@@ -3012,7 +3109,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,
@@ -3129,6 +3226,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;
@@ -3162,8 +3260,6 @@ 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)
 
@@ -3193,22 +3289,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.  */
@@ -3356,9 +3441,7 @@ 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.*/
+   because we want to tell the garbage collector about it.  */
 varray_type incomplete_types;
 
 /* Record whether the function being analyzed contains inlined functions.  */
@@ -3368,9 +3451,7 @@ 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.  */
+   must be kept around forever.  This is a GC root.  */
 static varray_type used_rtx_varray;
 
 /* Forward declarations for functions defined in this file.  */
@@ -3388,14 +3469,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,
@@ -3406,21 +3491,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 *));
@@ -3430,6 +3523,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));
@@ -3443,13 +3540,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));
@@ -3461,9 +3561,12 @@ 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 *));
+static void die_checksum               PARAMS ((dw_die_ref,
+                                                struct md5_ctx *));
 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));
@@ -3473,7 +3576,6 @@ static void break_out_includes            PARAMS ((dw_die_ref));
 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));
-static unsigned long size_of_string    PARAMS ((const char *));
 static int constant_size               PARAMS ((long unsigned));
 static unsigned long size_of_die       PARAMS ((dw_die_ref));
 static void calc_die_sizes             PARAMS ((dw_die_ref));
@@ -3537,8 +3639,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));
@@ -3580,13 +3684,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 *,
@@ -3594,6 +3696,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
@@ -3629,6 +3732,14 @@ static char *gen_internal_sym            PARAMS ((const char *));
 #define TEXT_SECTION_NAME      ".text"
 #endif
 
+/* Section flags for .debug_str section.  */
+#ifdef HAVE_GAS_SHF_MERGE
+#define DEBUG_STR_SECTION_FLAGS \
+  (SECTION_DEBUG | SECTION_MERGE | SECTION_STRINGS | 1)
+#else
+#define DEBUG_STR_SECTION_FLAGS        SECTION_DEBUG
+#endif
+
 /* Labels we insert at beginning sections we can reference instead of
    the section names themselves.  */
 
@@ -3647,6 +3758,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
@@ -3664,6 +3778,8 @@ 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
@@ -3703,19 +3819,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.  */
 
@@ -3737,11 +3840,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);
@@ -4075,6 +4178,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>";
     }
@@ -4220,9 +4329,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);
 
@@ -4267,7 +4375,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;
@@ -4292,7 +4399,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;
@@ -4320,7 +4426,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;
@@ -4348,7 +4453,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;
@@ -4406,21 +4510,74 @@ add_AT_string (die, attr_kind, str)
      const char *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);
+      debug_str_hash->alloc_node = indirect_string_alloc;
+    }
+
+  node = (struct indirect_string_node *)
+        ht_lookup (debug_str_hash, (const unsigned char *) str,
+                   strlen (str), HT_ALLOC);
+  node->refcount++;
 
   attr->dw_attr_next = NULL;
   attr->dw_attr = attr_kind;
   attr->dw_attr_val.val_class = dw_val_class_str;
-  attr->dw_attr_val.v.val_str = xstrdup (str);
+  attr->dw_attr_val.v.val_str = node;
   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;
 {
   if (a && AT_class (a) == dw_val_class_str)
-    return a->dw_attr_val.v.val_str;
+    return (const char *) HT_STR (&a->dw_attr_val.v.val_str->id);
+
+  abort ();
+}
+
+/* Find out whether a string should be output inline in DIE
+   or out-of-line in .debug_str section.  */
+
+static int
+AT_string_form (a)
+     dw_attr_ref a;
+{
+  if (a && AT_class (a) == dw_val_class_str)
+    {
+      struct indirect_string_node *node;
+      unsigned int len;
+      extern int const_labelno;
+      char label[32];
+
+      node = a->dw_attr_val.v.val_str;
+      if (node->form)
+       return node->form;
+
+      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 (len <= DWARF_OFFSET_SIZE || node->refcount == 0)
+       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;
+    }
 
   abort ();
 }
@@ -4443,7 +4600,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;
@@ -4454,7 +4610,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;
@@ -4465,7 +4620,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;
@@ -4511,7 +4665,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;
@@ -4538,8 +4691,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;
@@ -4567,7 +4718,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;
@@ -4614,7 +4764,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;
@@ -4629,7 +4779,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;
@@ -4654,14 +4820,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);
@@ -4670,29 +4833,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;
 }
 
@@ -4705,6 +4868,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;
 }
 
@@ -4717,6 +4881,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;
 }
 
@@ -4729,6 +4894,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;
 }
 
@@ -4738,6 +4904,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;
 }
 
@@ -4751,6 +4918,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);
@@ -4776,9 +4950,13 @@ free_AT (a)
   switch (AT_class (a))
     {
     case dw_val_class_str:
+      if (a->dw_attr_val.v.val_str->refcount)
+       a->dw_attr_val.v.val_str->refcount--;
+      break;
+
     case dw_val_class_lbl_id:
     case dw_val_class_lbl_offset:
-      free (a->dw_attr_val.v.val_str);
+      free (a->dw_attr_val.v.val_lbl_id);
       break;
 
     case dw_val_class_float:
@@ -4819,7 +4997,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;
@@ -4869,6 +5046,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;
@@ -4889,6 +5067,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;
     }
@@ -4911,9 +5090,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));
 
@@ -4927,6 +5107,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;
     }
@@ -4940,8 +5121,6 @@ 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);
 }
 
@@ -4963,8 +5142,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.  */
@@ -4974,8 +5152,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)
     {
@@ -5051,6 +5229,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;
@@ -5119,7 +5300,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);
@@ -5169,6 +5350,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)
@@ -5177,15 +5359,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)
@@ -5199,10 +5381,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)
@@ -5210,6 +5391,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;
 }
@@ -5221,12 +5403,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.  */
 
@@ -5235,9 +5418,9 @@ 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.  */
@@ -5250,7 +5433,7 @@ attr_checksum (at, ctx)
   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
@@ -5262,23 +5445,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:
@@ -5286,7 +5468,7 @@ attr_checksum (at, ctx)
       switch (GET_CODE (r))
        {
        case SYMBOL_REF:
-         PROCESS_STRING (XSTR (r, 0));
+         CHECKSUM_STRING (XSTR (r, 0));
          break;
 
        default:
@@ -5295,7 +5477,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:
@@ -5305,7 +5487,7 @@ attr_checksum (at, ctx)
 
     case dw_val_class_die_ref:
       if (AT_ref (at)->die_offset)
-       PROCESS (AT_ref (at)->die_offset);
+       CHECKSUM (AT_ref (at)->die_offset);
       /* FIXME else use target die name or something.  */
 
     case dw_val_class_fde_ref:
@@ -5328,7 +5510,7 @@ die_checksum (die, ctx)
   dw_die_ref c;
   dw_attr_ref a;
 
-  PROCESS (die->die_tag);
+  CHECKSUM (die->die_tag);
 
   for (a = die->die_attr; a; a = a->dw_attr_next)
     attr_checksum (a, ctx);
@@ -5337,8 +5519,8 @@ die_checksum (die, ctx)
     die_checksum (c, ctx);
 }
 
-#undef PROCESS
-#undef PROCESS_STRING
+#undef CHECKSUM
+#undef CHECKSUM_STRING
 
 /* The prefix to attach to symbols on DIEs in the current comdat debug
    info section.  */
@@ -5354,37 +5536,35 @@ static void
 compute_section_prefix (unit_die)
      dw_die_ref unit_die;
 {
-  char *name;
+  const char *base = lbasename (get_AT_string (unit_die, DW_AT_name));
+  char *name = (char *) alloca (strlen (base) + 64);
+  char *p;
   int i;
   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);
   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)
@@ -5424,12 +5604,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;
 
@@ -5439,9 +5618,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);
 }
@@ -5453,20 +5632,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);
 }
@@ -5484,6 +5661,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);
@@ -5508,12 +5686,11 @@ break_out_includes (die)
   dw_die_ref unit = NULL;
   limbo_die_node *node;
 
-  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.  */
@@ -5574,29 +5751,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)
@@ -5610,15 +5786,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)
     {
@@ -5670,20 +5845,6 @@ build_abbrev_table (die)
     build_abbrev_table (c);
 }
 \f
-/* Return the size of a string, including the null byte.
-
-   This used to treat backslashes as escapes, and hence they were not included
-   in the count.  However, that conflicts with what ASM_OUTPUT_ASCII does,
-   which treats a backslash as a backslash, escaping it if necessary, and hence
-   we must include them in the count.  */
-
-static unsigned long
-size_of_string (str)
-     const char *str;
-{
-  return strlen (str) + 1;
-}
-
 /* Return the power-of-two number of bytes necessary to represent VALUE.  */
 
 static int
@@ -5703,7 +5864,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
@@ -5736,6 +5897,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;
@@ -5764,7 +5928,10 @@ size_of_die (die)
          size += DWARF_OFFSET_SIZE;
          break;
        case dw_val_class_str:
-         size += size_of_string (AT_string (a));
+         if (AT_string_form (a) == DW_FORM_strp)
+           size += DWARF_OFFSET_SIZE;
+         else
+           size += HT_LEN (&a->dw_attr_val.v.val_str->id) + 1;
          break;
        default:
          abort ();
@@ -5774,17 +5941,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);
 
@@ -5806,6 +5973,7 @@ mark_dies (die)
      dw_die_ref die;
 {
   dw_die_ref c;
+
   die->die_mark = 1;
   for (c = die->die_child; c; c = c->die_sib)
     mark_dies (c);
@@ -5818,6 +5986,7 @@ unmark_dies (die)
      dw_die_ref die;
 {
   dw_die_ref c;
+
   die->die_mark = 0;
   for (c = die->die_child; c; c = c->die_sib)
     unmark_dies (c);
@@ -5833,10 +6002,10 @@ 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 + size_of_string (p->name);
+      size += DWARF_OFFSET_SIZE + strlen (p->name) + 1;
     }
 
   size += DWARF_OFFSET_SIZE;
@@ -5871,6 +6040,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;
@@ -5925,7 +6095,7 @@ value_format (a)
     case dw_val_class_lbl_offset:
       return DW_FORM_data;
     case dw_val_class_str:
-      return DW_FORM_string;
+      return AT_string_form (a);
 
     default:
       abort ();
@@ -5939,6 +6109,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));
 }
 
@@ -5951,12 +6122,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));
 
@@ -5997,13 +6168,14 @@ output_die_symbol (die)
        .linkonce, it doesn't support combining the sections, so debugging
        will break.  */
     ASM_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;
@@ -6014,16 +6186,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;
@@ -6033,20 +6208,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
@@ -6055,14 +6233,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);
@@ -6070,13 +6250,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);
@@ -6084,6 +6266,7 @@ output_loc_list (list_head)
                       "Location list terminator end (%s)",
                       list_head->ll_symbol);
 }
+
 /* Output the DIE and its attributes.  Called recursively to generate
    the definitions of each child DIE.  */
 
@@ -6118,6 +6301,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));
 
@@ -6143,8 +6337,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)
              {
@@ -6156,9 +6351,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;
@@ -6168,9 +6364,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;
@@ -6180,11 +6376,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);
          }
@@ -6194,6 +6391,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);
@@ -6208,6 +6406,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);
@@ -6223,7 +6422,12 @@ output_die (die)
          break;
 
        case dw_val_class_str:
-         dw2_asm_output_nstring (AT_string (a), -1, "%s", name);
+         if (AT_string_form (a) == DW_FORM_strp)
+           dw2_asm_output_offset (DWARF_OFFSET_SIZE,
+                                  a->dw_attr_val.v.val_str->label,
+                                  "%s: \"%s\"", name, AT_string (a));
+         else
+           dw2_asm_output_nstring (AT_string (a), -1, "%s", name);
          break;
 
        default:
@@ -6234,12 +6438,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
@@ -6250,12 +6452,9 @@ 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)");
 }
 
@@ -6267,13 +6466,11 @@ output_comp_unit (die)
 {
   const char *secname;
 
-  /* 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.  */
+  /* 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);
@@ -6285,6 +6482,7 @@ output_comp_unit (die)
   if (die->die_symbol)
     {
       char *tmp = (char *) alloca (strlen (die->die_symbol) + 24);
+
       sprintf (tmp, ".gnu.linkonce.wi.%s", die->die_symbol);
       secname = tmp;
       die->die_symbol = NULL;
@@ -6303,16 +6501,16 @@ output_comp_unit (die)
     unmark_dies (die);
 }
 
-/* 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.  */
@@ -6330,13 +6528,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));
 }
 
@@ -6352,16 +6551,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];
 
@@ -6410,14 +6606,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.  */
@@ -6435,7 +6627,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];
 
@@ -6446,7 +6638,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");
        }
@@ -6455,9 +6647,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 ();
 
@@ -6508,7 +6700,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;
 
@@ -6531,6 +6723,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
@@ -6618,6 +6811,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 ()
 {
@@ -6638,7 +6832,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;
 
@@ -6656,6 +6850,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.  */
@@ -6668,7 +6863,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)
@@ -6691,7 +6886,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
@@ -6702,32 +6897,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
@@ -6754,7 +6946,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.  */
@@ -6766,33 +6958,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
@@ -6801,7 +6993,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;
@@ -6818,6 +7010,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");
 }
 
@@ -6850,26 +7043,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)
        {
@@ -6922,7 +7119,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
@@ -6945,6 +7142,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
@@ -6965,13 +7163,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,
@@ -6983,10 +7179,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.  */
@@ -7056,6 +7250,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
@@ -7092,7 +7287,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
@@ -7143,8 +7339,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)
@@ -7204,10 +7399,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);
 
@@ -7311,11 +7507,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)
        {
@@ -7325,19 +7522,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
@@ -7346,6 +7543,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.  */
        }
 
@@ -7354,17 +7552,17 @@ 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);
+         mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die, type);
          add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
 #if 0
          add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
@@ -7373,7 +7571,7 @@ 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);
+         mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die, type);
          add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
 #if 0
          add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
@@ -7392,7 +7590,12 @@ 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 ();
        }
@@ -7438,24 +7641,25 @@ reg_number (rtl)
   unsigned regno = REGNO (rtl);
 
   if (regno >= FIRST_PSEUDO_REGISTER)
-    {
-      warning ("internal regno botch: regno = %d\n", regno);
-      regno = 0;
-    }
+    abort ();
 
-  regno = DBX_REGISTER_NUMBER (regno);
-  return regno;
+  return DBX_REGISTER_NUMBER (regno);
 }
 
-/* Return a location descriptor that designates a machine register.  */
+/* Return a location descriptor that designates a machine register or
+   zero if there is no such.  */
 
 static dw_loc_descr_ref
 reg_loc_descriptor (rtl)
      rtx rtl;
 {
   dw_loc_descr_ref loc_result = NULL;
-  unsigned reg = reg_number (rtl);
+  unsigned reg;
+
+  if (REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
+    return 0;
 
+  reg = reg_number (rtl);
   if (reg <= 31)
     loc_result = new_loc_descr (DW_OP_reg0 + reg, 0, 0);
   else
@@ -7535,9 +7739,10 @@ static inline int
 is_based_loc (rtl)
      rtx rtl;
 {
-    return (GET_CODE (rtl) == PLUS
-           && ((GET_CODE (XEXP (rtl, 0)) == REG
-                && 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
@@ -7551,7 +7756,9 @@ is_based_loc (rtl)
    it into Dwarf postfix code as it goes.
 
    MODE is the mode of the memory reference, needed to handle some
-   autoincrement addressing modes.  */
+   autoincrement addressing modes.
+
+   Return 0 if we can't represent the location.  */
 
 static dw_loc_descr_ref
 mem_loc_descriptor (rtl, mode)
@@ -7559,6 +7766,7 @@ mem_loc_descriptor (rtl, mode)
      enum machine_mode mode;
 {
   dw_loc_descr_ref mem_loc_result = NULL;
+
   /* Note that for a dynamically sized array, the location we will generate a
      description of here will be the lowest numbered location which is
      actually within the array.  That's *not* necessarily the same as the
@@ -7576,7 +7784,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)
@@ -7586,7 +7794,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
@@ -7602,12 +7810,14 @@ mem_loc_descriptor (rtl, mode)
          the object in question was allocated to a register (rather than in
          memory) so DWARF consumers need to be aware of the subtle
          distinction between OP_REG and OP_BASEREG.  */
-      mem_loc_result = based_loc_descr (reg_number (rtl), 0);
+      if (REGNO (rtl) < FIRST_PSEUDO_REGISTER)
+       mem_loc_result = based_loc_descr (reg_number (rtl), 0);
       break;
 
     case MEM:
       mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
-      add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
+      if (mem_loc_result != 0)
+       add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
       break;
 
     case LABEL_REF:
@@ -7618,17 +7828,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:
@@ -7646,7 +7871,7 @@ mem_loc_descriptor (rtl, mode)
                                   ? GET_MODE_UNIT_SIZE (mode)
                                   : -GET_MODE_UNIT_SIZE (mode)));
 
-      /* Fall through.  */
+      /* ... fall through ...  */
 
     case PLUS:
     plus:
@@ -7656,14 +7881,14 @@ mem_loc_descriptor (rtl, mode)
       else
        {
          mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode);
+         if (mem_loc_result == 0)
+           break;
 
          if (GET_CODE (XEXP (rtl, 1)) == CONST_INT
              && INTVAL (XEXP (rtl, 1)) >= 0)
-           {
-             add_loc_descr (&mem_loc_result,
-                            new_loc_descr (DW_OP_plus_uconst,
-                                           INTVAL (XEXP (rtl, 1)), 0));
-           }
+           add_loc_descr (&mem_loc_result,
+                          new_loc_descr (DW_OP_plus_uconst,
+                                         INTVAL (XEXP (rtl, 1)), 0));
          else
            {
              add_loc_descr (&mem_loc_result,
@@ -7675,19 +7900,33 @@ mem_loc_descriptor (rtl, mode)
       break;
 
     case MULT:
-      /* If a pseudo-reg is optimized away, it is possible for it to
-        be replaced with a MEM containing a multiply.  */
-      add_loc_descr (&mem_loc_result,
-                    mem_loc_descriptor (XEXP (rtl, 0), mode));
-      add_loc_descr (&mem_loc_result,
-                    mem_loc_descriptor (XEXP (rtl, 1), mode));
-      add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_mul, 0, 0));
-      break;
+      {
+       /* If a pseudo-reg is optimized away, it is possible for it to
+          be replaced with a MEM containing a multiply.  */
+       dw_loc_descr_ref op0 = mem_loc_descriptor (XEXP (rtl, 0), mode);
+       dw_loc_descr_ref op1 = mem_loc_descriptor (XEXP (rtl, 1), mode);
+
+       if (op0 == 0 || op1 == 0)
+         break;
+
+       mem_loc_result = op0;
+       add_loc_descr (&mem_loc_result, op1);
+       add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_mul, 0, 0));
+       break;
+      }
 
     case CONST_INT:
       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 ();
     }
@@ -7703,18 +7942,21 @@ concat_loc_descriptor (x0, x1)
      rtx x0, x1;
 {
   dw_loc_descr_ref cc_loc_result = NULL;
+  dw_loc_descr_ref x0_ref = loc_descriptor (x0);
+  dw_loc_descr_ref x1_ref = loc_descriptor (x1);
 
-  if (!is_pseudo_reg (x0)
-      && (GET_CODE (x0) != MEM || !is_pseudo_reg (XEXP (x0, 0))))
-    add_loc_descr (&cc_loc_result, loc_descriptor (x0));
+  if (x0_ref == 0 || x1_ref == 0)
+    return 0;
+
+  cc_loc_result = x0_ref;
   add_loc_descr (&cc_loc_result,
-                new_loc_descr (DW_OP_piece, GET_MODE_SIZE (GET_MODE (x0)), 0));
+                new_loc_descr (DW_OP_piece,
+                               GET_MODE_SIZE (GET_MODE (x0)), 0));
 
-  if (!is_pseudo_reg (x1)
-      && (GET_CODE (x1) != MEM || !is_pseudo_reg (XEXP (x1, 0))))
-    add_loc_descr (&cc_loc_result, loc_descriptor (x1));
+  add_loc_descr (&cc_loc_result, x1_ref);
   add_loc_descr (&cc_loc_result,
-                new_loc_descr (DW_OP_piece, GET_MODE_SIZE (GET_MODE (x1)), 0));
+                new_loc_descr (DW_OP_piece,
+                               GET_MODE_SIZE (GET_MODE (x1)), 0));
 
   return cc_loc_result;
 }
@@ -7723,13 +7965,16 @@ concat_loc_descriptor (x0, x1)
    which is either allocated in a register or in a memory location.  For a
    register, we just generate an OP_REG and the register number.  For a
    memory location we provide a Dwarf postfix expression describing how to
-   generate the (dynamic) address of the object onto the address stack.  */
+   generate the (dynamic) address of the object onto the address stack.
+
+   If we don't know how to describe it, return 0.  */
 
 static dw_loc_descr_ref
 loc_descriptor (rtl)
      rtx rtl;
 {
   dw_loc_descr_ref loc_result = NULL;
+
   switch (GET_CODE (rtl))
     {
     case SUBREG:
@@ -7740,7 +7985,7 @@ loc_descriptor (rtl)
          contains the given subreg.  */
       rtl = SUBREG_REG (rtl);
 
-      /* Fall through.  */
+      /* ... fall through ...  */
 
     case REG:
       loc_result = reg_loc_descriptor (rtl);
@@ -7761,16 +8006,18 @@ loc_descriptor (rtl)
   return loc_result;
 }
 
-/* Similar, but generate the descriptor from trees instead of rtl.
-   This comes up particularly with variable length arrays.  */
+/* 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)
      tree loc;
      int addressp;
 {
-  dw_loc_descr_ref ret = NULL;
-  int indirect_size = 0;
+  dw_loc_descr_ref ret, ret1;
+  int indirect_p = 0;
   int unsignedp = TREE_UNSIGNED (TREE_TYPE (loc));
   enum dwarf_location_atom op;
 
@@ -7781,37 +8028,58 @@ loc_descriptor_from_tree (loc, addressp)
   switch (TREE_CODE (loc))
     {
     case ERROR_MARK:
-      break;
+      return 0;
 
     case WITH_RECORD_EXPR:
+    case PLACEHOLDER_EXPR:
       /* This case involves extracting fields from an object to determine the
         position of other fields.  We don't try to encode this here.  The
         only user of this is Ada, which encodes the needed information using
         the names of types.  */
-      return ret;
+      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:
     case PARM_DECL:
       {
        rtx rtl = rtl_for_decl_location (loc);
-       enum machine_mode mode = DECL_MODE (loc);
 
        if (rtl == NULL_RTX)
-         break;
+         return 0;
        else if (CONSTANT_P (rtl))
          {
            ret = new_loc_descr (DW_OP_addr, 0, 0);
            ret->dw_loc_oprnd1.val_class = dw_val_class_addr;
            ret->dw_loc_oprnd1.v.val_addr = rtl;
-           indirect_size = GET_MODE_SIZE (mode);
+           indirect_p = 1;
          }
        else
          {
+           enum machine_mode mode = GET_MODE (rtl);
+
            if (GET_CODE (rtl) == MEM)
              {
-               indirect_size = GET_MODE_SIZE (mode);
+               indirect_p = 1;
                rtl = XEXP (rtl, 0);
              }
+
            ret = mem_loc_descriptor (rtl, mode);
          }
       }
@@ -7819,12 +8087,16 @@ loc_descriptor_from_tree (loc, addressp)
 
     case INDIRECT_REF:
       ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
-      indirect_size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (loc)));
+      indirect_p = 1;
       break;
 
+    case COMPOUND_EXPR:
+      return loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 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);
 
@@ -7837,11 +8109,17 @@ 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)
+         return 0;
 
        if (offset != NULL_TREE)
          {
@@ -7850,24 +8128,8 @@ loc_descriptor_from_tree (loc, addressp)
            add_loc_descr (&ret, new_loc_descr (DW_OP_plus, 0, 0));
          }
 
-       if (addressp)
-         {
-           /* We cannot address anything not on a unit boundary.  */
-           if (bitpos % BITS_PER_UNIT != 0)
-             abort ();
-         }
-       else
-         {
-           if (bitpos % BITS_PER_UNIT != 0
-               || bitsize % BITS_PER_UNIT != 0)
-             {
-               /* ??? We could handle this by loading and shifting etc.
-                  Wait until someone needs it before expending the effort.  */
-               abort ();
-             }
-
-           indirect_size = bitsize / BITS_PER_UNIT;
-         }
+       if (!addressp)
+         indirect_p = 1;
 
        bytepos = bitpos / BITS_PER_UNIT;
        if (bytepos > 0)
@@ -7883,40 +8145,59 @@ loc_descriptor_from_tree (loc, addressp)
     case INTEGER_CST:
       if (host_integerp (loc, 0))
        ret = int_loc_descriptor (tree_low_cst (loc, 0));
+      else
+       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;
+
     case TRUNC_DIV_EXPR:
       op = DW_OP_div;
       goto do_binop;
+
     case MINUS_EXPR:
       op = DW_OP_minus;
       goto do_binop;
+
     case TRUNC_MOD_EXPR:
       op = DW_OP_mod;
       goto do_binop;
+
     case MULT_EXPR:
       op = DW_OP_mul;
       goto do_binop;
+
     case LSHIFT_EXPR:
       op = DW_OP_shl;
       goto do_binop;
+
     case RSHIFT_EXPR:
       op = (unsignedp ? DW_OP_shr : DW_OP_shra);
       goto do_binop;
+
     case PLUS_EXPR:
       if (TREE_CODE (TREE_OPERAND (loc, 1)) == INTEGER_CST
          && host_integerp (TREE_OPERAND (loc, 1), 0))
        {
          ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+         if (ret == 0)
+           return 0;
+
          add_loc_descr (&ret,
                         new_loc_descr (DW_OP_plus_uconst,
                                        tree_low_cst (TREE_OPERAND (loc, 1),
@@ -7924,53 +8205,74 @@ loc_descriptor_from_tree (loc, addressp)
                                        0));
          break;
        }
+
       op = DW_OP_plus;
       goto do_binop;
+
     case LE_EXPR:
       if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
-       break;
+       return 0;
+
       op = DW_OP_le;
       goto do_binop;
+
     case GE_EXPR:
       if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
-       break;
+       return 0;
+
       op = DW_OP_ge;
       goto do_binop;
+
     case LT_EXPR:
       if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
-       break;
+       return 0;
+
       op = DW_OP_lt;
       goto do_binop;
+
     case GT_EXPR:
       if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
-       break;
+       return 0;
+
       op = DW_OP_gt;
       goto do_binop;
+
     case EQ_EXPR:
       op = DW_OP_eq;
       goto do_binop;
+
     case NE_EXPR:
       op = DW_OP_ne;
       goto do_binop;
 
     do_binop:
       ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
-      add_loc_descr (&ret, loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 0));
+      ret1 = loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 0);
+      if (ret == 0 || ret1 == 0)
+       return 0;
+
+      add_loc_descr (&ret, ret1);
       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;
+
     case ABS_EXPR:
       op = DW_OP_abs;
       goto do_unop;
+
     case NEGATE_EXPR:
       op = DW_OP_neg;
       goto do_unop;
 
     do_unop:
       ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+      if (ret == 0)
+       return 0;
+
       add_loc_descr (&ret, new_loc_descr (op, 0, 0));
       break;
 
@@ -7979,25 +8281,31 @@ 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:
       {
+       dw_loc_descr_ref lhs
+         = loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 0);
+       dw_loc_descr_ref rhs
+         = loc_descriptor_from_tree (TREE_OPERAND (loc, 2), 0);
        dw_loc_descr_ref bra_node, jump_node, tmp;
 
        ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+       if (ret == 0 || lhs == 0 || rhs == 0)
+         return 0;
+
        bra_node = new_loc_descr (DW_OP_bra, 0, 0);
        add_loc_descr (&ret, bra_node);
 
-       tmp = loc_descriptor_from_tree (TREE_OPERAND (loc, 2), 0);
-       add_loc_descr (&ret, tmp);
+       add_loc_descr (&ret, rhs);
        jump_node = new_loc_descr (DW_OP_skip, 0, 0);
        add_loc_descr (&ret, jump_node);
 
-       tmp = loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 0);
-       add_loc_descr (&ret, tmp);
+       add_loc_descr (&ret, lhs);
        bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
-       bra_node->dw_loc_oprnd1.v.val_loc = tmp;
+       bra_node->dw_loc_oprnd1.v.val_loc = lhs;
 
        /* ??? Need a node to point the skip at.  Use a nop.  */
        tmp = new_loc_descr (DW_OP_nop, 0, 0);
@@ -8011,20 +8319,23 @@ loc_descriptor_from_tree (loc, addressp)
       abort ();
     }
 
-  /* If we can't fill the request for an address, die.  */
-  if (addressp && indirect_size == 0)
-    abort ();
+  /* Show if we can't fill the request for an address.  */
+  if (addressp && indirect_p == 0)
+    return 0;
 
   /* If we've got an address and don't want one, dereference.  */
-  if (!addressp && indirect_size > 0)
+  if (!addressp && indirect_p > 0)
     {
-      if (indirect_size > DWARF2_ADDR_SIZE)
-       abort ();
-      if (indirect_size == DWARF2_ADDR_SIZE)
+      HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (loc));
+
+      if (size > DWARF2_ADDR_SIZE || size == -1)
+       return 0;
+      else if (size == DWARF2_ADDR_SIZE)
        op = DW_OP_deref;
       else
        op = DW_OP_deref_size;
-      add_loc_descr (&ret, new_loc_descr (op, indirect_size, 0));
+
+      add_loc_descr (&ret, new_loc_descr (op, size, 0));
     }
 
   return ret;
@@ -8090,25 +8401,23 @@ 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)
+  else if (TYPE_SIZE (type) == NULL_TREE)
     return 0;
-  if (! host_integerp (type_size_tree, 1))
+  else if (host_integerp (TYPE_SIZE (type), 1))
+    return tree_low_cst (TYPE_SIZE (type), 1);
+  else
     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)
@@ -8118,7 +8427,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;
@@ -8127,8 +8435,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);
@@ -8157,44 +8464,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.  */
@@ -8220,9 +8527,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
@@ -8240,79 +8545,107 @@ add_AT_location_description (die, attr_kind, rtl)
      enum dwarf_attribute attr_kind;
      rtx rtl;
 {
-  /* Handle a special case.  If we are about to output a location descriptor
-     for a variable or parameter which has been optimized out of existence,
-     don't do that.  A variable which has been optimized out
-     of existence will have a DECL_RTL value which denotes a pseudo-reg.
-     Currently, in some rare cases, variables can have DECL_RTL values which
-     look like (MEM (REG pseudo-reg#)).  These cases are due to bugs
-     elsewhere in the compiler.  We treat such cases as if the variable(s) in
-     question had been optimized out of existence.  */
-
-  if (is_pseudo_reg (rtl)
-      || (GET_CODE (rtl) == MEM
-         && is_pseudo_reg (XEXP (rtl, 0)))
-      /* This can happen for a PARM_DECL with a DECL_INCOMING_RTL which
-        references the internal argument pointer (a pseudo) in a function
-        where all references to the internal argument pointer were
-        eliminated via the optimizers.  */
-      || (GET_CODE (rtl) == MEM
-         && GET_CODE (XEXP (rtl, 0)) == PLUS
-         && is_pseudo_reg (XEXP (XEXP (rtl, 0), 0)))
-      || (GET_CODE (rtl) == CONCAT
-         && is_pseudo_reg (XEXP (rtl, 0))
-         && is_pseudo_reg (XEXP (rtl, 1))))
-    return;
+  dw_loc_descr_ref descr = loc_descriptor (rtl);
 
-  add_AT_loc (die, attr_kind, loc_descriptor (rtl));
-}
-
-/* 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).  */
+  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.)  */
 
 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);
 }
 
@@ -8337,17 +8670,21 @@ 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);
        else if ((unsigned long) val == (unsigned HOST_WIDE_INT) val)
          add_AT_unsigned (die, DW_AT_const_value, (unsigned long) val);
-       else if (2*HOST_BITS_PER_LONG == HOST_BITS_PER_WIDE_INT)
-         add_AT_long_long (die, DW_AT_const_value,
-                           val >> HOST_BITS_PER_LONG, val);
        else
-         abort ();
+         {
+#if HOST_BITS_PER_LONG * 2 == HOST_BITS_PER_WIDE_INT
+           add_AT_long_long (die, DW_AT_const_value,
+                             val >> HOST_BITS_PER_LONG, val);
+#else
+           abort ();
+#endif
+         }
       }
       break;
 
@@ -8362,7 +8699,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);
@@ -8392,6 +8729,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));
          }
@@ -8405,7 +8743,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:
@@ -8484,36 +8823,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))
        {
@@ -8522,7 +8875,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
@@ -8560,6 +8913,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));
        }
@@ -8574,16 +8928,49 @@ 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
   return rtl;
 }
 
@@ -8607,8 +8994,7 @@ add_location_or_const_value_attribute (die, decl)
 
   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);
@@ -8673,7 +9059,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),
@@ -8710,18 +9096,12 @@ add_bound_info (subrange_die, bound_attr, bound)
      enum dwarf_attribute bound_attr;
      tree bound;
 {
-  /* If this is an Ada unconstrained array type, then don't emit any debug
-     info because the array bounds are unknown.  They are parameterized when
-     the type is instantiated.  */
-  if (contains_placeholder_p (bound))
-    return;
-
   switch (TREE_CODE (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
@@ -8736,6 +9116,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;
 
@@ -8766,12 +9147,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);
@@ -8816,9 +9196,21 @@ add_bound_info (subrange_die, bound_attr, bound)
        if (loc == NULL)
          break;
 
-       ctx = lookup_decl_die (current_function_decl);
-
-       decl_die = new_die (DW_TAG_variable, ctx);
+       if (current_function_decl == 0)
+         ctx = comp_unit_die;
+       else
+         ctx = lookup_decl_die (current_function_decl);
+
+       /* 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);
@@ -8860,14 +9252,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.  */
@@ -8901,15 +9293,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
@@ -8945,7 +9333,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);
 }
 
@@ -8954,13 +9341,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.
@@ -9064,8 +9450,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);
@@ -9143,6 +9531,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.  */
@@ -9155,11 +9554,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);
 }
 
@@ -9201,7 +9602,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;
@@ -9224,9 +9624,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;
@@ -9235,12 +9634,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;
@@ -9273,19 +9672,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);
 }
@@ -9331,8 +9729,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
@@ -9345,6 +9742,7 @@ decl_start_label (decl)
 {
   rtx x;
   const char *fnname;
+
   x = DECL_RTL (decl);
   if (GET_CODE (x) != MEM)
     abort ();
@@ -9378,7 +9776,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
@@ -9400,9 +9808,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);
 
@@ -9426,7 +9831,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);
@@ -9439,7 +9844,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
@@ -9456,14 +9862,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.  */
 
@@ -9471,10 +9869,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.  */
@@ -9484,7 +9881,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);
@@ -9497,7 +9895,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.  */
@@ -9511,7 +9909,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.  */
@@ -9533,7 +9931,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));
     }
@@ -9562,7 +9960,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)));
@@ -9601,7 +9999,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)))
@@ -9644,10 +10042,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
@@ -9672,7 +10070,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
@@ -9705,15 +10103,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
@@ -9742,13 +10134,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)
@@ -9762,7 +10154,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;
@@ -9776,7 +10168,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;
@@ -9807,12 +10199,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))
@@ -9832,7 +10223,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)
@@ -9876,7 +10267,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);
@@ -9888,7 +10279,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);
@@ -9896,15 +10287,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))
@@ -9913,7 +10304,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);
 
@@ -9946,7 +10337,7 @@ 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,
@@ -10037,19 +10428,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)
     {
@@ -10078,7 +10469,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)
@@ -10086,14 +10477,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);
@@ -10114,8 +10508,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))
@@ -10126,7 +10519,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);
     }
@@ -10154,7 +10546,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];
 
@@ -10198,7 +10590,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))
@@ -10207,7 +10599,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
@@ -10243,7 +10635,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];
 
@@ -10260,6 +10652,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.  */
@@ -10269,14 +10675,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);
@@ -10292,7 +10697,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);
 }
@@ -10302,13 +10706,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);
@@ -10319,13 +10724,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);
@@ -10334,13 +10740,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,
@@ -10357,9 +10765,10 @@ gen_compile_unit_die (filename)
   dw_die_ref die;
   char producer[250];
   const char *wd = getpwd ();
+  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)
@@ -10390,13 +10799,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;
 }
 
@@ -10408,15 +10814,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.  */
@@ -10426,13 +10833,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))
@@ -10454,13 +10862,12 @@ gen_member_die (type, context_die)
      members of this record or union type, we will also be trying to output
      DIEs to represent the *types* of those members. However the `type'
      function (above) will specifically avoid generating type DIEs for member
-     types *within* the list of member DIEs for this (containing) type execpt
+     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))
@@ -10535,7 +10942,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);
@@ -10580,8 +10987,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);
     }
 }
 
@@ -10594,7 +11002,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);
@@ -10614,15 +11023,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))
        {
@@ -10635,6 +11045,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);
     }
@@ -10655,10 +11066,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;
@@ -10666,6 +11080,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;
@@ -10736,20 +11154,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)))
@@ -10869,8 +11286,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;
     }
 
@@ -10892,12 +11310,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"
@@ -10958,8 +11375,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;
 
@@ -11013,15 +11429,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.  */
@@ -11037,6 +11452,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)
@@ -11049,6 +11465,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)
        {
@@ -11076,13 +11493,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);
@@ -11128,8 +11544,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)
        {
@@ -11151,6 +11567,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.  */
 
@@ -11163,7 +11588,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);
@@ -11176,17 +11601,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);
 }
@@ -11199,15 +11624,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
@@ -11224,22 +11645,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;
 
@@ -11248,7 +11671,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:
@@ -11282,7 +11704,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;
@@ -11342,23 +11765,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)
@@ -11374,11 +11799,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;
@@ -11400,7 +11826,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;
 }
@@ -11443,11 +11873,11 @@ 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))
        {
@@ -11510,9 +11940,10 @@ dwarf2out_start_source_file (lineno, filename)
   if (flag_eliminate_dwarf2_dups)
     {
       /* 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 = new_die (DW_TAG_GNU_BINCL, comp_unit_die, NULL);
       add_AT_string (bincl_die, DW_AT_name, filename);
     }
+
   if (debug_info_level >= DINFO_LEVEL_VERBOSE)
     {
       named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
@@ -11531,10 +11962,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);
@@ -11551,12 +11981,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);
@@ -11623,6 +12047,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;
 
@@ -11639,6 +12064,8 @@ dwarf2out_init (main_input_filename)
   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,
                               DEBUG_ABBREV_SECTION_LABEL, 0);
@@ -11646,16 +12073,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);
@@ -11671,6 +12102,44 @@ dwarf2out_init (main_input_filename)
     }
 }
 
+/* Allocate a string in .debug_str hash table.  */
+
+static hashnode
+indirect_string_alloc (tab)
+     hash_table *tab ATTRIBUTE_UNUSED;
+{
+  struct indirect_string_node *node;
+
+  node = xmalloc (sizeof (struct indirect_string_node));
+  node->refcount = 0;
+  node->form = 0;
+  node->label = NULL;
+
+  return (hashnode) node;
+}
+
+/* A helper function for dwarf2out_finish called through
+   ht_forall.  Emit one queued .debug_str string.  */
+
+static int
+output_indirect_string (pfile, h, v)
+     struct cpp_reader *pfile ATTRIBUTE_UNUSED;
+     hashnode h;
+     const PTR v ATTRIBUTE_UNUSED;
+{
+  struct indirect_string_node *node = (struct indirect_string_node *) h;
+
+  if (node->form == DW_FORM_strp)
+    {
+      named_section_flags (DEBUG_STR_SECTION, DEBUG_STR_SECTION_FLAGS);
+      ASM_OUTPUT_LABEL (asm_out_file, node->label);
+      assemble_string ((const char *) HT_STR (&node->id),
+                      HT_LEN (&node->id) + 1);
+    }
+
+  return 1;
+}
+
 /* Output stuff that dwarf requires at the end of every file,
    and generate the DWARF-2 debugging info.  */
 
@@ -11694,15 +12163,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
@@ -11758,9 +12260,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);
 
@@ -11775,24 +12277,24 @@ dwarf2out_finish (input_filename)
      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 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 ();
     }
@@ -11801,14 +12303,21 @@ 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 the string
+     table too.  */
+  if (debug_str_hash)
+    ht_forall (debug_str_hash, output_indirect_string, NULL);
 }
 #endif /* DWARF2_DEBUGGING_INFO || DWARF2_UNWIND_INFO */