DWARF: Use DW_OP_addrx and DW_OP_constx for DWARF5.
authorMark Wielaard <mark@klomp.org>
Tue, 15 May 2018 08:37:46 +0000 (08:37 +0000)
committerMark Wielaard <mark@gcc.gnu.org>
Tue, 15 May 2018 08:37:46 +0000 (08:37 +0000)
For older DWARF and -gsplit-dwarf we want to emit DW_OP_GNU_addr_index
and DW_OP_GNU_const_index, but for DWARF5 we should use DW_OP_addrx
and DW_OP_constx.

gcc/ChangeLog:

* dwarf2out.c (dwarf_OP): Handle DW_OP_addrx and DW_OP_constx.
(size_of_loc_descr): Likewise.
(output_loc_operands): Likewise.
(output_loc_operands_raw): Likewise.
(dw_addr_op): Use dwarf_OP () for DW_OP_constx and DW_OP_addrx.
(resolve_addr_in_expr): Handle DW_OP_addrx and DW_OP_constx.
(hash_loc_operands): Likewise.
(compare_loc_operands): Likewise.

From-SVN: r260252

gcc/ChangeLog
gcc/dwarf2out.c

index 7e145f4..f5da0eb 100644 (file)
@@ -1,3 +1,14 @@
+2018-05-13  Mark Wielaard  <mark@klomp.org>
+
+       * dwarf2out.c (dwarf_OP): Handle DW_OP_addrx and DW_OP_constx.
+       (size_of_loc_descr): Likewise.
+       (output_loc_operands): Likewise.
+       (output_loc_operands_raw): Likewise.
+       (dw_addr_op): Use dwarf_OP () for DW_OP_constx and DW_OP_addrx.
+       (resolve_addr_in_expr): Handle DW_OP_addrx and DW_OP_constx.
+       (hash_loc_operands): Likewise.
+       (compare_loc_operands): Likewise.
+
 2018-05-14  Mark Wielaard  <mark@klomp.org>
 
        * dwarf2out.c (count_index_addrs): New function.
index 7ced2b1..97e8ed9 100644 (file)
@@ -1657,6 +1657,16 @@ dwarf_OP (enum dwarf_location_atom op)
        return DW_OP_GNU_reinterpret;
       break;
 
+    case DW_OP_addrx:
+      if (dwarf_version < 5)
+       return DW_OP_GNU_addr_index;
+      break;
+
+    case DW_OP_constx:
+      if (dwarf_version < 5)
+       return DW_OP_GNU_const_index;
+      break;
+
     default:
       break;
     }
@@ -1772,7 +1782,9 @@ size_of_loc_descr (dw_loc_descr_ref loc)
       size += DWARF2_ADDR_SIZE;
       break;
     case DW_OP_GNU_addr_index:
+    case DW_OP_addrx:
     case DW_OP_GNU_const_index:
+    case DW_OP_constx:
       gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED);
       size += size_of_uleb128 (loc->dw_loc_oprnd1.val_entry->index);
       break;
@@ -2272,7 +2284,9 @@ output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip)
       break;
 
     case DW_OP_GNU_addr_index:
+    case DW_OP_addrx:
     case DW_OP_GNU_const_index:
+    case DW_OP_constx:
       gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED);
       dw2_asm_output_data_uleb128 (loc->dw_loc_oprnd1.val_entry->index,
                                    "(index into .debug_addr)");
@@ -2503,7 +2517,9 @@ output_loc_operands_raw (dw_loc_descr_ref loc)
     {
     case DW_OP_addr:
     case DW_OP_GNU_addr_index:
+    case DW_OP_addrx:
     case DW_OP_GNU_const_index:
+    case DW_OP_constx:
     case DW_OP_implicit_value:
       /* We cannot output addresses in .cfi_escape, only bytes.  */
       gcc_unreachable ();
@@ -3903,10 +3919,10 @@ static inline enum dwarf_location_atom
 dw_addr_op (enum dtprel_bool dtprel)
 {
   if (dtprel == dtprel_true)
-    return (dwarf_split_debug_info ? DW_OP_GNU_const_index
+    return (dwarf_split_debug_info ? dwarf_OP (DW_OP_constx)
             : (DWARF2_ADDR_SIZE == 4 ? DW_OP_const4u : DW_OP_const8u));
   else
-    return dwarf_split_debug_info ? DW_OP_GNU_addr_index : DW_OP_addr;
+    return dwarf_split_debug_info ? dwarf_OP (DW_OP_addrx) : DW_OP_addr;
 }
 
 /* Return a pointer to a newly allocated address location description.  If
@@ -29697,9 +29713,14 @@ resolve_addr_in_expr (dw_attr_node *a, dw_loc_descr_ref loc)
          }
        break;
       case DW_OP_GNU_addr_index:
+      case DW_OP_addrx:
       case DW_OP_GNU_const_index:
-       if (loc->dw_loc_opc == DW_OP_GNU_addr_index
-            || (loc->dw_loc_opc == DW_OP_GNU_const_index && loc->dtprel))
+      case DW_OP_constx:
+       if ((loc->dw_loc_opc == DW_OP_GNU_addr_index
+            || loc->dw_loc_opc == DW_OP_addrx)
+           || ((loc->dw_loc_opc == DW_OP_GNU_const_index
+                || loc->dw_loc_opc == DW_OP_constx)
+               && loc->dtprel))
           {
             rtx rtl = loc->dw_loc_oprnd1.val_entry->addr.rtl;
             if (!resolve_one_addr (&rtl))
@@ -30485,7 +30506,9 @@ hash_loc_operands (dw_loc_descr_ref loc, inchash::hash &hstate)
       inchash::add_rtx (val1->v.val_addr, hstate);
       break;
     case DW_OP_GNU_addr_index:
+    case DW_OP_addrx:
     case DW_OP_GNU_const_index:
+    case DW_OP_constx:
       {
         if (loc->dtprel)
           {
@@ -30726,7 +30749,9 @@ compare_loc_operands (dw_loc_descr_ref x, dw_loc_descr_ref y)
     hash_addr:
       return rtx_equal_p (valx1->v.val_addr, valy1->v.val_addr);
     case DW_OP_GNU_addr_index:
+    case DW_OP_addrx:
     case DW_OP_GNU_const_index:
+    case DW_OP_constx:
       {
         rtx ax1 = valx1->val_entry->addr.rtl;
         rtx ay1 = valy1->val_entry->addr.rtl;