OSDN Git Service

* pa-host.c (MAP_FAILED): Define if not defined.
[pf3gnuchains/gcc-fork.git] / gcc / dwarf2out.c
index 25f4b25..74303c2 100644 (file)
@@ -116,33 +116,38 @@ dwarf2out_do_frame (void)
 /* Various versions of targetm.eh_frame_section.  Note these must appear
    outside the DWARF2_DEBUGGING_INFO || DWARF2_UNWIND_INFO macro guards.  */
 
-/* Version of targetm.eh_frame_section for systems with named sections.  */ 
+/* Version of targetm.eh_frame_section for systems with named sections.  */
 void
 named_section_eh_frame_section (void)
 {
 #ifdef EH_FRAME_SECTION_NAME
-#ifdef HAVE_LD_RO_RW_SECTION_MIXING
-  int fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0);
-  int per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
-  int lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
   int flags;
 
-  flags = (! flag_pic
-          || ((fde_encoding & 0x70) != DW_EH_PE_absptr
-              && (fde_encoding & 0x70) != DW_EH_PE_aligned
-              && (per_encoding & 0x70) != DW_EH_PE_absptr
-              && (per_encoding & 0x70) != DW_EH_PE_aligned
-              && (lsda_encoding & 0x70) != DW_EH_PE_absptr
-              && (lsda_encoding & 0x70) != DW_EH_PE_aligned))
-         ? 0 : SECTION_WRITE;
+  if (EH_TABLES_CAN_BE_READ_ONLY)
+    {
+      int fde_encoding;
+      int per_encoding;
+      int lsda_encoding;
+
+      fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0);
+      per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
+      lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
+      flags = (! flag_pic
+              || ((fde_encoding & 0x70) != DW_EH_PE_absptr
+                  && (fde_encoding & 0x70) != DW_EH_PE_aligned
+                  && (per_encoding & 0x70) != DW_EH_PE_absptr
+                  && (per_encoding & 0x70) != DW_EH_PE_aligned
+                  && (lsda_encoding & 0x70) != DW_EH_PE_absptr
+                  && (lsda_encoding & 0x70) != DW_EH_PE_aligned))
+             ? 0 : SECTION_WRITE;
+    }
+  else
+    flags = SECTION_WRITE;
   named_section_flags (EH_FRAME_SECTION_NAME, flags);
-#else
-  named_section_flags (EH_FRAME_SECTION_NAME, SECTION_WRITE);
-#endif
 #endif
 }
 
-/* Version of targetm.eh_frame_section for systems using collect2.  */ 
+/* Version of targetm.eh_frame_section for systems using collect2.  */
 void
 collect2_eh_frame_section (void)
 {
@@ -358,7 +363,7 @@ static void initial_return_save (rtx);
 static HOST_WIDE_INT stack_adjust_offset (rtx);
 static void output_cfi (dw_cfi_ref, dw_fde_ref, int);
 static void output_call_frame_info (int);
-static void dwarf2out_stack_adjust (rtx);
+static void dwarf2out_stack_adjust (rtx, bool);
 static void flush_queued_reg_saves (void);
 static bool clobbers_queued_reg_save (rtx);
 static void dwarf2out_frame_debug_expr (rtx, const char *);
@@ -1046,7 +1051,7 @@ stack_adjust_offset (rtx pattern)
    much extra space it needs to pop off the stack.  */
 
 static void
-dwarf2out_stack_adjust (rtx insn)
+dwarf2out_stack_adjust (rtx insn, bool after_p)
 {
   HOST_WIDE_INT offset;
   const char *label;
@@ -1059,26 +1064,31 @@ dwarf2out_stack_adjust (rtx insn)
   if (prologue_epilogue_contains (insn) || sibcall_epilogue_contains (insn))
     return;
 
-  if (!flag_asynchronous_unwind_tables && CALL_P (insn))
+  /* If only calls can throw, and we have a frame pointer,
+     save up adjustments until we see the CALL_INSN.  */
+  if (!flag_asynchronous_unwind_tables && cfa.reg != STACK_POINTER_REGNUM)
     {
-      /* Extract the size of the args from the CALL rtx itself.  */
-      insn = PATTERN (insn);
-      if (GET_CODE (insn) == PARALLEL)
-       insn = XVECEXP (insn, 0, 0);
-      if (GET_CODE (insn) == SET)
-       insn = SET_SRC (insn);
-      gcc_assert (GET_CODE (insn) == CALL);
-
-      dwarf2out_args_size ("", INTVAL (XEXP (insn, 1)));
+      if (CALL_P (insn) && !after_p)
+       {
+         /* Extract the size of the args from the CALL rtx itself.  */
+         insn = PATTERN (insn);
+         if (GET_CODE (insn) == PARALLEL)
+           insn = XVECEXP (insn, 0, 0);
+         if (GET_CODE (insn) == SET)
+           insn = SET_SRC (insn);
+         gcc_assert (GET_CODE (insn) == CALL);
+         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)
-    return;
-
-  if (BARRIER_P (insn))
+  if (CALL_P (insn) && !after_p)
+    {
+      if (!flag_asynchronous_unwind_tables)
+       dwarf2out_args_size ("", args_size);
+      return;
+    }
+  else if (BARRIER_P (insn))
     {
       /* When we see a BARRIER, we know to reset args_size to 0.  Usually
         the compiler will have already emitted a stack adjustment, but
@@ -1119,7 +1129,8 @@ dwarf2out_stack_adjust (rtx insn)
 
   label = dwarf2out_cfi_label ();
   def_cfa_1 (label, &cfa);
-  dwarf2out_args_size (label, args_size);
+  if (flag_asynchronous_unwind_tables)
+    dwarf2out_args_size (label, args_size);
 }
 
 #endif
@@ -1150,7 +1161,7 @@ struct reg_saved_in_data GTY(()) {
    more efficient data structure.  */
 static GTY(()) struct reg_saved_in_data regs_saved_in_regs[4];
 static GTY(()) size_t num_regs_saved_in_regs;
-  
+
 #if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
 static const char *last_reg_save_label;
 
@@ -1253,7 +1264,7 @@ reg_saved_in (rtx reg)
   unsigned int regn = REGNO (reg);
   size_t i;
   struct queued_reg_save *q;
-  
+
   for (q = queued_reg_saves; q; q = q->next)
     if (q->saved_reg && regn == REGNO (q->saved_reg))
       return q->reg;
@@ -1311,7 +1322,7 @@ static dw_cfa_location cfa_temp;
   the intent is to save the value of SP from the previous frame.
 
   In addition, if a register has previously been saved to a different
-  register, 
+  register,
 
   Invariants / Summaries of Rules
 
@@ -1430,7 +1441,11 @@ static dw_cfa_location cfa_temp;
   (set (mem (postinc <reg1>:cfa_temp <const_int>)) <reg2>)
   effects: cfa.reg = <reg1>
           cfa.base_offset = -cfa_temp.offset
-          cfa_temp.offset -= mode_size(mem)  */
+          cfa_temp.offset -= mode_size(mem)
+
+  Rule 15:
+  (set <reg> {unspec, unspec_volatile})
+  effects: target-dependent  */
 
 static void
 dwarf2out_frame_debug_expr (rtx expr, const char *label)
@@ -1480,7 +1495,7 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
            {
              /* Rule 1 */
              /* Update the CFA rule wrt SP or FP.  Make sure src is
-                relative to the current CFA register. 
+                relative to the current CFA register.
 
                 We used to require that dest be either SP or FP, but the
                 ARM copies SP to a temporary register, and from there to
@@ -1494,7 +1509,10 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
            {
              /* Saving a register in a register.  */
              gcc_assert (call_used_regs [REGNO (dest)]
-                         && !fixed_regs [REGNO (dest)]);
+                         && (!fixed_regs [REGNO (dest)]
+                             /* For the SPARC and its register window.  */
+                             || DWARF_FRAME_REGNUM (REGNO (src))
+                                  == DWARF_FRAME_RETURN_COLUMN));
              queue_reg_save (label, src, dest, 0);
            }
          break;
@@ -1621,6 +1639,13 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
        case HIGH:
          break;
 
+         /* Rule 15 */
+       case UNSPEC:
+       case UNSPEC_VOLATILE:
+         gcc_assert (targetm.dwarf_handle_frame_unspec);
+         targetm.dwarf_handle_frame_unspec (label, expr, XINT (src, 1));
+         break;
+
        default:
          gcc_unreachable ();
        }
@@ -1677,14 +1702,14 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
        case LO_SUM:
          {
            int regno;
-           
+
            gcc_assert (GET_CODE (XEXP (XEXP (dest, 0), 1)) == CONST_INT);
            offset = INTVAL (XEXP (XEXP (dest, 0), 1));
            if (GET_CODE (XEXP (dest, 0)) == MINUS)
              offset = -offset;
 
            regno = REGNO (XEXP (XEXP (dest, 0), 0));
-           
+
            if (cfa_store.reg == (unsigned) regno)
              offset -= cfa_store.offset;
            else
@@ -1700,7 +1725,7 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
        case REG:
          {
            int regno = REGNO (XEXP (dest, 0));
-           
+
            if (cfa_store.reg == (unsigned) regno)
              offset = -cfa_store.offset;
            else
@@ -1767,10 +1792,13 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
 
 /* Record call frame debugging information for INSN, which either
    sets SP or FP (adjusting how we calculate the frame address) or saves a
-   register to the stack.  If INSN is NULL_RTX, initialize our state.  */
+   register to the stack.  If INSN is NULL_RTX, initialize our state.
+
+   If AFTER_P is false, we're being called before the insn is emitted,
+   otherwise after.  Call instructions get invoked twice.  */
 
 void
-dwarf2out_frame_debug (rtx insn)
+dwarf2out_frame_debug (rtx insn, bool after_p)
 {
   const char *label;
   rtx src;
@@ -1778,7 +1806,7 @@ dwarf2out_frame_debug (rtx insn)
   if (insn == NULL_RTX)
     {
       size_t i;
-      
+
       /* Flush any queued register saves.  */
       flush_queued_reg_saves ();
 
@@ -1791,7 +1819,7 @@ dwarf2out_frame_debug (rtx insn)
       cfa_store = cfa;
       cfa_temp.reg = -1;
       cfa_temp.offset = 0;
-      
+
       for (i = 0; i < num_regs_saved_in_regs; i++)
        {
          regs_saved_in_regs[i].orig_reg = NULL_RTX;
@@ -1807,8 +1835,7 @@ dwarf2out_frame_debug (rtx insn)
   if (! RTX_FRAME_RELATED_P (insn))
     {
       if (!ACCUMULATE_OUTGOING_ARGS)
-       dwarf2out_stack_adjust (insn);
-
+       dwarf2out_stack_adjust (insn, after_p);
       return;
     }
 
@@ -2050,7 +2077,7 @@ output_call_frame_info (int for_eh)
   /* If we make FDEs linkonce, we may have to emit an empty label for
      an FDE that wouldn't otherwise be emitted.  We want to avoid
      having an FDE kept around when the function it refers to is
-     discarded. (Example where this matters: a primary function
+     discarded.  Example where this matters: a primary function
      template in C++ requires EH information, but an explicit
      specialization doesn't.  */
   if (TARGET_USES_WEAK_UNWIND_INFO
@@ -2059,7 +2086,7 @@ output_call_frame_info (int for_eh)
     for (i = 0; i < fde_table_in_use; i++)
       if ((fde_table[i].nothrow || fde_table[i].all_throwers_are_sibcalls)
           && !fde_table[i].uses_eh_lsda
-         && ! DECL_ONE_ONLY (fde_table[i].decl))
+         && ! DECL_WEAK (fde_table[i].decl))
        targetm.asm_out.unwind_label (asm_out_file, fde_table[i].decl,
                                      for_eh, /* empty */ 1);
 
@@ -2074,8 +2101,7 @@ output_call_frame_info (int for_eh)
       for (i = 0; i < fde_table_in_use; i++)
        if (fde_table[i].uses_eh_lsda)
          any_eh_needed = any_lsda_needed = true;
-        else if (TARGET_USES_WEAK_UNWIND_INFO
-                && DECL_ONE_ONLY (fde_table[i].decl))
+        else if (TARGET_USES_WEAK_UNWIND_INFO && DECL_WEAK (fde_table[i].decl))
          any_eh_needed = true;
        else if (! fde_table[i].nothrow
                 && ! fde_table[i].all_throwers_are_sibcalls)
@@ -2222,7 +2248,7 @@ output_call_frame_info (int for_eh)
       /* Don't emit EH unwind info for leaf functions that don't need it.  */
       if (for_eh && !flag_asynchronous_unwind_tables && flag_exceptions
          && (fde->nothrow || fde->all_throwers_are_sibcalls)
-         && (! TARGET_USES_WEAK_UNWIND_INFO || ! DECL_ONE_ONLY (fde->decl))
+         && ! (TARGET_USES_WEAK_UNWIND_INFO && DECL_WEAK (fde_table[i].decl))
          && !fde->uses_eh_lsda)
        continue;
 
@@ -3930,13 +3956,13 @@ static dw_die_ref scope_die_for (tree, dw_die_ref);
 static inline int local_scope_p (dw_die_ref);
 static inline int class_or_namespace_scope_p (dw_die_ref);
 static void add_type_attribute (dw_die_ref, tree, int, int, dw_die_ref);
+static void add_calling_convention_attribute (dw_die_ref, tree);
 static const char *type_tag (tree);
 static tree member_declared_type (tree);
 #if 0
 static const char *decl_start_label (tree);
 #endif
 static void gen_array_type_die (tree, dw_die_ref);
-static void gen_set_type_die (tree, dw_die_ref);
 #if 0
 static void gen_entry_point_die (tree, dw_die_ref);
 #endif
@@ -4809,11 +4835,11 @@ AT_string_form (dw_attr_ref a)
   char label[32];
 
   gcc_assert (a && AT_class (a) == dw_val_class_str);
-  
+
   node = a->dw_attr_val.v.val_str;
   if (node->form)
     return node->form;
-  
+
   len = strlen (node->str) + 1;
 
   /* If the string is shorter or equal to the size of the reference, it is
@@ -8004,7 +8030,6 @@ is_base_type (tree type)
     case CHAR_TYPE:
       return 1;
 
-    case SET_TYPE:
     case ARRAY_TYPE:
     case RECORD_TYPE:
     case UNION_TYPE:
@@ -8637,7 +8662,7 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode, bool can_use_fbreg)
     case ASHIFT:
       op = DW_OP_shl;
       goto do_binop;
-      
+
     case ASHIFTRT:
       op = DW_OP_shra;
       goto do_binop;
@@ -9170,6 +9195,12 @@ loc_descriptor_from_tree_1 (tree loc, int want_address)
       }
       break;
 
+    case FIX_TRUNC_EXPR:
+    case FIX_CEIL_EXPR:
+    case FIX_FLOOR_EXPR:
+    case FIX_ROUND_EXPR:
+      return 0;
+
     default:
       /* Leave front-end specific codes as simply unknown.  This comes
         up, for instance, with the C STMT_EXPR.  */
@@ -9283,7 +9314,7 @@ field_byte_offset (tree decl)
 
   if (TREE_CODE (decl) == ERROR_MARK)
     return 0;
-  
+
   gcc_assert (TREE_CODE (decl) == FIELD_DECL);
 
   type = field_type (decl);
@@ -9557,7 +9588,7 @@ add_const_value_attribute (dw_die_ref die, rtx rtl)
 
        if (val < 0)
          add_AT_int (die, DW_AT_const_value, val);
-       else 
+       else
          add_AT_unsigned (die, DW_AT_const_value, (unsigned HOST_WIDE_INT) val);
       }
       break;
@@ -9605,30 +9636,30 @@ add_const_value_attribute (dw_die_ref die, rtx rtl)
              {
                rtx elt = CONST_VECTOR_ELT (rtl, i);
                HOST_WIDE_INT lo, hi;
-               
+
                switch (GET_CODE (elt))
                  {
                  case CONST_INT:
                    lo = INTVAL (elt);
                    hi = -(lo < 0);
                    break;
-                   
+
                  case CONST_DOUBLE:
                    lo = CONST_DOUBLE_LOW (elt);
                    hi = CONST_DOUBLE_HIGH (elt);
                    break;
-                   
+
                  default:
                    gcc_unreachable ();
                  }
-               
+
                if (elt_size <= sizeof (HOST_WIDE_INT))
                  insert_int (lo, elt_size, p);
                else
                  {
                    unsigned char *p0 = p;
                    unsigned char *p1 = p + sizeof (HOST_WIDE_INT);
-                   
+
                    gcc_assert (elt_size == 2 * sizeof (HOST_WIDE_INT));
                    if (WORDS_BIG_ENDIAN)
                      {
@@ -9789,19 +9820,33 @@ rtl_for_decl_location (tree decl)
     {
       if (rtl == NULL_RTX || is_pseudo_reg (rtl))
        {
-         tree declared_type = type_main_variant (TREE_TYPE (decl));
-         tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
+         tree declared_type = TREE_TYPE (decl);
+         tree passed_type = DECL_ARG_TYPE (decl);
+         enum machine_mode dmode = TYPE_MODE (declared_type);
+         enum machine_mode pmode = TYPE_MODE (passed_type);
 
          /* 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.  */
-         if (declared_type == passed_type)
-           rtl = DECL_INCOMING_RTL (decl);
-         else if (! BYTES_BIG_ENDIAN
-                  && TREE_CODE (declared_type) == INTEGER_TYPE
-                  && (GET_MODE_SIZE (TYPE_MODE (declared_type))
-                      <= GET_MODE_SIZE (TYPE_MODE (passed_type))))
+         if (dmode == pmode)
            rtl = DECL_INCOMING_RTL (decl);
+         else if (SCALAR_INT_MODE_P (dmode)
+                  && GET_MODE_SIZE (dmode) <= GET_MODE_SIZE (pmode)
+                  && DECL_INCOMING_RTL (decl))
+           {
+             rtx inc = DECL_INCOMING_RTL (decl);
+             if (REG_P (inc))
+               rtl = inc;
+             else if (MEM_P (inc))
+               {
+                 if (BYTES_BIG_ENDIAN)
+                   rtl = adjust_address_nv (inc, dmode,
+                                            GET_MODE_SIZE (pmode)
+                                            - GET_MODE_SIZE (dmode));
+                 else
+                   rtl = inc;
+               }
+           }
        }
 
       /* If the parm was passed in registers, but lives on the stack, then
@@ -9889,7 +9934,8 @@ rtl_for_decl_location (tree decl)
                                   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));
+           rtl = gen_rtx_CONST_STRING (VOIDmode,
+                                       ggc_strdup (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
@@ -10620,6 +10666,21 @@ add_type_attribute (dw_die_ref object_die, tree type, int decl_const,
     add_AT_die_ref (object_die, DW_AT_type, type_die);
 }
 
+/* Given an object die, add the calling convention attribute for the
+   function call type.  */
+static void
+add_calling_convention_attribute (dw_die_ref subr_die, tree type)
+{
+  enum dwarf_calling_convention value = DW_CC_normal;
+
+  value = targetm.dwarf_calling_convention (type);
+
+  /* Only add the attribute if the backend requests it, and
+     is not DW_CC_normal.  */
+  if (value && (value != DW_CC_normal))
+    add_AT_unsigned (subr_die, DW_AT_calling_convention, value);
+}
+
 /* Given a tree pointer to a struct, class, union, or enum type node, return
    a pointer to the (string) tag name for the given type, or zero if the type
    was declared without a tag.  */
@@ -10750,16 +10811,6 @@ gen_array_type_die (tree type, dw_die_ref context_die)
   add_type_attribute (array_die, element_type, 0, 0, context_die);
 }
 
-static void
-gen_set_type_die (tree type, dw_die_ref context_die)
-{
-  dw_die_ref type_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);
-}
-
 #if 0
 static void
 gen_entry_point_die (tree decl, dw_die_ref context_die)
@@ -10918,7 +10969,7 @@ gen_formal_parameter_die (tree node, dw_die_ref context_die)
 
   switch (TREE_CODE_CLASS (TREE_CODE (node)))
     {
-    case 'd':
+    case tcc_declaration:
       origin = decl_ultimate_origin (node);
       if (origin != NULL)
        add_abstract_origin_attribute (parm_die, origin);
@@ -10939,7 +10990,7 @@ gen_formal_parameter_die (tree node, dw_die_ref context_die)
 
       break;
 
-    case 't':
+    case tcc_type:
       /* We were called with some kind of a ..._TYPE node.  */
       add_type_attribute (parm_die, node, 0, 0, context_die);
       break;
@@ -11164,7 +11215,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
          subr_die = old_die;
 
          /* Clear out the declaration attribute and the formal parameters.
-            Do not remove all children, because it is possible that this 
+            Do not remove all children, because it is possible that this
             declaration die was forced using force_decl_die(). In such
             cases die that forced declaration die (e.g. TAG_imported_module)
             is one of the children that we do not want to remove.  */
@@ -11217,7 +11268,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
          /* The first time we see a member function, it is in the context of
             the class to which it belongs.  We make sure of this by emitting
             the class first.  The next time is the definition, which is
-            handled above.  The two may come from the same source text. 
+            handled above.  The two may come from the same source text.
 
             Note that force_decl_die() forces function declaration die. It is
             later reused to represent definition.  */
@@ -11375,6 +11426,9 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
        }
 #endif
     }
+  /* Add the calling convention attribute if requested.  */
+  add_calling_convention_attribute (subr_die, TREE_TYPE (decl));
+
 }
 
 /* Generate a DIE to represent a declared data object.  */
@@ -12025,11 +12079,6 @@ gen_type_die (tree type, dw_die_ref context_die)
       gen_ptr_to_mbr_type_die (type, context_die);
       break;
 
-    case SET_TYPE:
-      gen_type_die (TYPE_DOMAIN (type), context_die);
-      gen_set_type_die (type, context_die);
-      break;
-
     case FILE_TYPE:
       gen_type_die (TREE_TYPE (type), context_die);
       /* No way to represent these in Dwarf yet!  */
@@ -12355,7 +12404,7 @@ force_decl_die (tree decl)
          save_fn = current_function_decl;
          current_function_decl = NULL_TREE;
          gen_subprogram_die (decl, context_die);
-         current_function_decl = save_fn; 
+         current_function_decl = save_fn;
          break;
 
        case VAR_DECL:
@@ -12374,14 +12423,14 @@ force_decl_die (tree decl)
        default:
          gcc_unreachable ();
        }
-  
+
       /* See if we can find the die for this deci now.
         If not then abort.  */
       if (!decl_die)
        decl_die = lookup_decl_die (decl);
       gcc_assert (decl_die);
     }
-  
+
   return decl_die;
 }
 
@@ -12417,7 +12466,8 @@ force_type_die (tree type)
 static dw_die_ref
 setup_namespace_context (tree thing, dw_die_ref context_die)
 {
-  tree context = DECL_P (thing) ? DECL_CONTEXT (thing) : TYPE_CONTEXT (thing);
+  tree context = (DECL_P (thing)
+                 ? DECL_CONTEXT (thing) : TYPE_CONTEXT (thing));
   if (context && TREE_CODE (context) == NAMESPACE_DECL)
     /* Force out the namespace.  */
     context_die = force_decl_die (context);
@@ -12694,8 +12744,8 @@ dwarf2out_type_decl (tree decl, int local)
     dwarf2out_decl (decl);
 }
 
-/* Output debug information for imported module or decl.  */ 
+/* Output debug information for imported module or decl.  */
+
 static void
 dwarf2out_imported_module_or_decl (tree decl, tree context)
 {
@@ -12703,14 +12753,14 @@ dwarf2out_imported_module_or_decl (tree decl, tree context)
   dw_die_ref scope_die;
   unsigned file_index;
   expanded_location xloc;
-  
+
   if (debug_info_level <= DINFO_LEVEL_TERSE)
     return;
 
   gcc_assert (decl);
 
   /* To emit DW_TAG_imported_module or DW_TAG_imported_decl, we need two DIEs.
-     We need decl DIE for reference and scope die. First, get DIE for the decl 
+     We need decl DIE for reference and scope die. First, get DIE for the decl
      itself.  */
 
   /* Get the scope die for decl context. Use comp_unit_die for global module
@@ -12727,8 +12777,8 @@ dwarf2out_imported_module_or_decl (tree decl, tree context)
     at_import_die = force_type_die (TREE_TYPE (decl));
   else
     at_import_die = force_decl_die (decl);
-  
-  /* OK, now we have DIEs for decl as well as scope. Emit imported die.  */ 
+
+  /* OK, now we have DIEs for decl as well as scope. Emit imported die.  */
   if (TREE_CODE (decl) == NAMESPACE_DECL)
     imported_die = new_die (DW_TAG_imported_module, scope_die, context);
   else
@@ -12924,7 +12974,7 @@ lookup_filename (const char *file_name)
        return file_table_last_lookup_index;
     }
 
-  /* Didn't match the previous lookup, search the table */
+  /* Didn't match the previous lookup, search the table */
   n = VARRAY_ACTIVE_SIZE (file_table);
   for (i = 1; i < n; i++)
     if (strcmp (file_name, VARRAY_CHAR_PTR (file_table, i)) == 0)
@@ -13217,7 +13267,7 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
   abbrev_die_table = ggc_alloc_cleared (ABBREV_DIE_TABLE_INCREMENT
                                        * sizeof (dw_die_ref));
   abbrev_die_table_allocated = ABBREV_DIE_TABLE_INCREMENT;
-  /* Zero-th entry is allocated, but unused */
+  /* Zero-th entry is allocated, but unused */
   abbrev_die_table_in_use = 1;
 
   /* Allocate the initial hunk of the line_info_table.  */
@@ -13225,7 +13275,7 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
                                       * sizeof (dw_line_info_entry));
   line_info_table_allocated = LINE_INFO_TABLE_INCREMENT;
 
-  /* Zero-th entry is allocated, but unused */
+  /* Zero-th entry is allocated, but unused */
   line_info_table_in_use = 1;
 
   /* Generate the initial DIE for the .debug section.  Note that the (string)
@@ -13243,10 +13293,7 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
   ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0);
   ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label,
                               DEBUG_ABBREV_SECTION_LABEL, 0);
-  if (DWARF2_GENERATE_TEXT_SECTION_LABEL)
-    ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
-  else
-    strcpy (text_section_label, stripattributes (TEXT_SECTION_NAME));
+  ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
 
   ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label,
                               DEBUG_INFO_SECTION_LABEL, 0);
@@ -13269,11 +13316,8 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
       ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label);
     }
 
-  if (DWARF2_GENERATE_TEXT_SECTION_LABEL)
-    {
-      text_section ();
-      ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
-    }
+  text_section ();
+  ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
 }
 
 /* A helper function for dwarf2out_finish called through
@@ -13438,7 +13482,7 @@ static void
 prune_unused_types_prune (dw_die_ref die)
 {
   dw_die_ref c, p, n;
-  
+
   gcc_assert (die->die_mark);
 
   p = NULL;
@@ -13552,7 +13596,12 @@ dwarf2out_finish (const char *filename)
                 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.  */
+                this to be a child of the containing function.
+
+                It may happen that even the containing function got fully
+                inlined and optimized out.  In that case we are lost and
+                assign the empty child.  This should not be big issue as
+                the function is likely unreachable too.  */
              tree context = NULL_TREE;
 
              gcc_assert (node->created_for);
@@ -13561,12 +13610,14 @@ dwarf2out_finish (const char *filename)
                context = DECL_CONTEXT (node->created_for);
              else if (TYPE_P (node->created_for))
                context = TYPE_CONTEXT (node->created_for);
-               
+
              gcc_assert (context && TREE_CODE (context) == FUNCTION_DECL);
-             
+
              origin = lookup_decl_die (context);
-             gcc_assert (origin);
-             add_child_die (origin, die);
+             if (origin)
+               add_child_die (origin, die);
+             else
+               add_child_die (comp_unit_die, die);
            }
        }
     }