OSDN Git Service

Revert "Fix PR debug/49047"
[pf3gnuchains/gcc-fork.git] / gcc / dwarf2out.c
index 382d918..7ec1e93 100644 (file)
@@ -2237,7 +2237,7 @@ dwarf2out_frame_debug_cfa_restore (rtx reg, const char *label)
           cfa_temp.offset = <const_int>
 
   Rule 10:
-  (set (mem (pre_modify sp:cfa_store (???? <reg1> <const_int>))) <reg2>)
+  (set (mem ({pre,post}_modify sp:cfa_store (???? <reg1> <const_int>))) <reg2>)
   effects: cfa_store.offset -= <const_int>
           cfa.offset = cfa_store.offset if cfa.reg == sp
           cfa.reg = sp
@@ -2578,6 +2578,7 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
          /* Rule 10 */
          /* With a push.  */
        case PRE_MODIFY:
+       case POST_MODIFY:
          /* We can't handle variable size modifications.  */
          gcc_assert (GET_CODE (XEXP (XEXP (XEXP (dest, 0), 1), 1))
                      == CONST_INT);
@@ -2590,7 +2591,10 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
          if (cfa.reg == STACK_POINTER_REGNUM)
            cfa.offset = cfa_store.offset;
 
-         offset = -cfa_store.offset;
+         if (GET_CODE (XEXP (dest, 0)) == POST_MODIFY)
+           offset -= cfa_store.offset;
+         else
+           offset = -cfa_store.offset;
          break;
 
          /* Rule 11 */
@@ -10166,6 +10170,20 @@ is_nested_in_subprogram (dw_die_ref die)
   return local_scope_p (decl);
 }
 
+/* Return non-zero if this DIE contains a defining declaration of a
+   subprogram.  */
+
+static int
+contains_subprogram_definition (dw_die_ref die)
+{
+  dw_die_ref c;
+
+  if (die->die_tag == DW_TAG_subprogram && ! is_declaration_die (die))
+    return 1;
+  FOR_EACH_CHILD (die, c, if (contains_subprogram_definition(c)) return 1);
+  return 0;
+}
+
 /* Return non-zero if this is a type DIE that should be moved to a
    COMDAT .debug_types section.  */
 
@@ -10184,6 +10202,8 @@ should_move_die_to_comdat (dw_die_ref die)
           || get_AT (die, DW_AT_abstract_origin)
           || is_nested_in_subprogram (die))
         return 0;
+      /* A type definition should never contain a subprogram definition.  */
+      gcc_assert (!contains_subprogram_definition (die));
       return 1;
     case DW_TAG_array_type:
     case DW_TAG_interface_type:
@@ -13011,7 +13031,7 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
     }
   else if (code == REFERENCE_TYPE)
     {
-      if (TYPE_REF_IS_RVALUE (type) && use_debug_types)
+      if (TYPE_REF_IS_RVALUE (type) && dwarf_version >= 4)
        mod_type_die = new_die (DW_TAG_rvalue_reference_type, comp_unit_die (),
                                type);
       else
@@ -13860,7 +13880,11 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
        break;
       if (GET_MODE_CLASS (mode) == MODE_INT
          && GET_MODE_CLASS (GET_MODE (SUBREG_REG (rtl))) == MODE_INT
-         && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
+         && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
+#ifdef POINTERS_EXTEND_UNSIGNED
+             || (mode == Pmode && mem_mode != VOIDmode)
+#endif
+            )
          && GET_MODE_SIZE (GET_MODE (SUBREG_REG (rtl))) <= DWARF2_ADDR_SIZE)
        {
          mem_loc_result = mem_loc_descriptor (SUBREG_REG (rtl),
@@ -13883,7 +13907,7 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
 
          mem_loc_result = mem_loc_descriptor (SUBREG_REG (rtl),
                                               GET_MODE (SUBREG_REG (rtl)),
-                                              mode, initialized);
+                                              mem_mode, initialized);
          if (mem_loc_result == NULL)
            break;
          type_die = base_type_for_mode (mode, 0);
@@ -13906,7 +13930,11 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
 
     case REG:
       if (GET_MODE_CLASS (mode) != MODE_INT
-         || GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE)
+         || (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE
+#ifdef POINTERS_EXTEND_UNSIGNED
+             && (mode != Pmode || mem_mode == VOIDmode)
+#endif
+             ))
        {
          dw_die_ref type_die;
 
@@ -14049,8 +14077,12 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
         pool.  */
     case CONST:
     case SYMBOL_REF:
-      if (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE
-         || GET_MODE_CLASS (mode) != MODE_INT)
+      if (GET_MODE_CLASS (mode) != MODE_INT
+         || (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE
+#ifdef POINTERS_EXTEND_UNSIGNED
+             && (mode != Pmode || mem_mode == VOIDmode)
+#endif
+             ))
        break;
       if (GET_CODE (rtl) == SYMBOL_REF
          && SYMBOL_REF_TLS_MODEL (rtl) != TLS_MODEL_NONE)
@@ -14288,7 +14320,13 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
       break;
 
     case CONST_INT:
-      if (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE)
+      if (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
+#ifdef POINTERS_EXTEND_UNSIGNED
+         || (mode == Pmode
+             && mem_mode != VOIDmode
+             && trunc_int_for_mode (INTVAL (rtl), ptr_mode) == INTVAL (rtl))
+#endif
+         )
        {
          mem_loc_result = int_loc_descriptor (INTVAL (rtl));
          break;
@@ -17681,7 +17719,9 @@ tree_add_const_value_attribute_for_decl (dw_die_ref var_die, tree decl)
 
   if (!decl
       || (TREE_CODE (decl) != VAR_DECL
-         && TREE_CODE (decl) != CONST_DECL))
+         && TREE_CODE (decl) != CONST_DECL)
+      || (TREE_CODE (decl) == VAR_DECL
+         && !TREE_STATIC (decl)))
     return false;
 
     if (TREE_READONLY (decl)
@@ -20646,7 +20686,7 @@ gen_reference_type_die (tree type, dw_die_ref context_die)
 {
   dw_die_ref ref_die, scope_die = scope_die_for (type, context_die);
 
-  if (TYPE_REF_IS_RVALUE (type) && use_debug_types)
+  if (TYPE_REF_IS_RVALUE (type) && dwarf_version >= 4)
     ref_die = new_die (DW_TAG_rvalue_reference_type, scope_die, type);
   else
     ref_die = new_die (DW_TAG_reference_type, scope_die, type);