diff mbox series

DWARF: Use DW_OP_addrx and DW_OP_constx for DWARF5.

Message ID 1526304923-16673-1-git-send-email-mark@klomp.org
State New
Headers show
Series DWARF: Use DW_OP_addrx and DW_OP_constx for DWARF5. | expand

Commit Message

Mark Wielaard May 14, 2018, 1:35 p.m. UTC
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.
---
 gcc/ChangeLog   | 11 +++++++++++
 gcc/dwarf2out.c | 33 +++++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 4 deletions(-)

Comments

Jeff Law May 14, 2018, 9:09 p.m. UTC | #1
On 05/14/2018 07:35 AM, Mark Wielaard wrote:
> 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.
OK.
jeff
diff mbox series

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8589065..6bc342d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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-04-30  Mark Wielaard  <mark@klomp.org>
 
 	* dwarf2out.c (dwarf_FORM): New function.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 0d2af85..9c1d7c4 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -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;
     }
@@ -1794,7 +1804,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;
@@ -2294,7 +2306,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)");
@@ -2525,7 +2539,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 ();
@@ -3925,10 +3941,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
@@ -29746,9 +29762,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))
@@ -30534,7 +30555,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)
           {
@@ -30775,7 +30798,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;