From: Jakub Jelinek Date: Mon, 31 Oct 2016 17:12:56 +0000 (+0100) Subject: dwarf2out.c (dwarf_op): New function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=23157abc1c0c29b975dc311a7d66a32cd5a3864f;p=gcc.git dwarf2out.c (dwarf_op): New function. * dwarf2out.c (dwarf_op): New function. (size_of_loc_descr): Handle DW_OP_{implicit_pointer,entry_value}, DW_OP_{const,regval,deref}_type and DW_OP_{convert,reinterpret}. (output_loc_operands, output_loc_operands_raw): Likewise. (resolve_args_picking_1, prune_unused_types_walk_loc_descr, mark_base_types, hash_loc_operands, compare_loc_operands): Likewise. (resolve_addr_in_expr): Likewise. Only punt for !dwarf_strict if dwarf_version < 5. (convert_descriptor_to_mode): Use dwarf_op (DW_OP_xxx) instead of DW_OP_GNU_xxx. (scompare_loc_descriptor, ucompare_loc_descriptor, minmax_loc_descriptor, typed_binop, mem_loc_descriptor, implicit_ptr_descriptor, optimize_one_addr_into_implicit_ptr, optimize_location_into_implicit_ptr): Likewise. Only punt for !dwarf_strict if dwarf_version < 5. (string_cst_pool_decl): Adjust comment. (non_dwarf_expression): Handle DW_OP_implicit_pointer. From-SVN: r241712 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 007389bd37e..b7605287cac 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,23 @@ 2016-10-31 Jakub Jelinek + * dwarf2out.c (dwarf_op): New function. + (size_of_loc_descr): Handle DW_OP_{implicit_pointer,entry_value}, + DW_OP_{const,regval,deref}_type and DW_OP_{convert,reinterpret}. + (output_loc_operands, output_loc_operands_raw): Likewise. + (resolve_args_picking_1, prune_unused_types_walk_loc_descr, + mark_base_types, hash_loc_operands, compare_loc_operands): Likewise. + (resolve_addr_in_expr): Likewise. Only punt for !dwarf_strict + if dwarf_version < 5. + (convert_descriptor_to_mode): Use dwarf_op (DW_OP_xxx) instead of + DW_OP_GNU_xxx. + (scompare_loc_descriptor, ucompare_loc_descriptor, + minmax_loc_descriptor, typed_binop, mem_loc_descriptor, + implicit_ptr_descriptor, optimize_one_addr_into_implicit_ptr, + optimize_location_into_implicit_ptr): Likewise. Only punt for + !dwarf_strict if dwarf_version < 5. + (string_cst_pool_decl): Adjust comment. + (non_dwarf_expression): Handle DW_OP_implicit_pointer. + * dwarf2out.h (enum dw_val_class): Add dw_val_class_const_implicit, dw_val_class_unsigned_const_implicit and dw_val_class_file_implicit. (struct dw_val_node): Add val_file_implicit field. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 60e22742fef..8cb4309dc81 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -1517,6 +1517,54 @@ loc_list_plus_const (dw_loc_list_ref list_head, HOST_WIDE_INT offset) #define DWARF_REF_SIZE \ (dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE) +/* Utility inline function for construction of ops that were GNU extension + before DWARF 5. */ +static inline enum dwarf_location_atom +dwarf_op (enum dwarf_location_atom op) +{ + switch (op) + { + case DW_OP_implicit_pointer: + if (dwarf_version < 5) + return DW_OP_GNU_implicit_pointer; + break; + + case DW_OP_entry_value: + if (dwarf_version < 5) + return DW_OP_GNU_entry_value; + break; + + case DW_OP_const_type: + if (dwarf_version < 5) + return DW_OP_GNU_const_type; + break; + + case DW_OP_regval_type: + if (dwarf_version < 5) + return DW_OP_GNU_regval_type; + break; + + case DW_OP_deref_type: + if (dwarf_version < 5) + return DW_OP_GNU_deref_type; + break; + + case DW_OP_convert: + if (dwarf_version < 5) + return DW_OP_GNU_convert; + break; + + case DW_OP_reinterpret: + if (dwarf_version < 5) + return DW_OP_GNU_reinterpret; + break; + + default: + break; + } + return op; +} + static unsigned long int get_base_type_offset (dw_die_ref); /* Return the size of a location descriptor. */ @@ -1636,15 +1684,18 @@ size_of_loc_descr (dw_loc_descr_ref loc) size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned) + loc->dw_loc_oprnd1.v.val_unsigned; break; + case DW_OP_implicit_pointer: case DW_OP_GNU_implicit_pointer: size += DWARF_REF_SIZE + size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int); break; + case DW_OP_entry_value: case DW_OP_GNU_entry_value: { unsigned long op_size = size_of_locs (loc->dw_loc_oprnd1.v.val_loc); size += size_of_uleb128 (op_size) + op_size; break; } + case DW_OP_const_type: case DW_OP_GNU_const_type: { unsigned long o @@ -1671,6 +1722,7 @@ size_of_loc_descr (dw_loc_descr_ref loc) } break; } + case DW_OP_regval_type: case DW_OP_GNU_regval_type: { unsigned long o @@ -1679,6 +1731,7 @@ size_of_loc_descr (dw_loc_descr_ref loc) + size_of_uleb128 (o); } break; + case DW_OP_deref_type: case DW_OP_GNU_deref_type: { unsigned long o @@ -1686,6 +1739,8 @@ size_of_loc_descr (dw_loc_descr_ref loc) size += 1 + size_of_uleb128 (o); } break; + case DW_OP_convert: + case DW_OP_reinterpret: case DW_OP_GNU_convert: case DW_OP_GNU_reinterpret: if (loc->dw_loc_oprnd1.val_class == dw_val_class_unsigned_const) @@ -2046,6 +2101,7 @@ output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip) } break; + case DW_OP_implicit_pointer: case DW_OP_GNU_implicit_pointer: { char label[MAX_ARTIFICIAL_LABEL_BYTES @@ -2057,11 +2113,13 @@ output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip) } break; + case DW_OP_entry_value: case DW_OP_GNU_entry_value: dw2_asm_output_data_uleb128 (size_of_locs (val1->v.val_loc), NULL); output_loc_sequence (val1->v.val_loc, for_eh_or_skip); break; + case DW_OP_const_type: case DW_OP_GNU_const_type: { unsigned long o = get_base_type_offset (val1->v.val_die_ref.die), l; @@ -2135,6 +2193,7 @@ output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip) } } break; + case DW_OP_regval_type: case DW_OP_GNU_regval_type: { unsigned r = val1->v.val_unsigned; @@ -2150,6 +2209,7 @@ output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip) dw2_asm_output_data_uleb128 (o, NULL); } break; + case DW_OP_deref_type: case DW_OP_GNU_deref_type: { unsigned long o = get_base_type_offset (val2->v.val_die_ref.die); @@ -2158,6 +2218,8 @@ output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip) dw2_asm_output_data_uleb128 (o, NULL); } break; + case DW_OP_convert: + case DW_OP_reinterpret: case DW_OP_GNU_convert: case DW_OP_GNU_reinterpret: if (loc->dw_loc_oprnd1.val_class == dw_val_class_unsigned_const) @@ -2356,6 +2418,13 @@ output_loc_operands_raw (dw_loc_descr_ref loc) } break; + case DW_OP_implicit_pointer: + case DW_OP_entry_value: + case DW_OP_const_type: + case DW_OP_regval_type: + case DW_OP_deref_type: + case DW_OP_convert: + case DW_OP_reinterpret: case DW_OP_GNU_implicit_pointer: case DW_OP_GNU_entry_value: case DW_OP_GNU_const_type: @@ -12815,13 +12884,13 @@ convert_descriptor_to_mode (machine_mode mode, dw_loc_descr_ref op) if (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE) { - add_loc_descr (&op, new_loc_descr (DW_OP_GNU_convert, 0, 0)); + add_loc_descr (&op, new_loc_descr (dwarf_op (DW_OP_convert), 0, 0)); return op; } type_die = base_type_for_mode (outer_mode, 1); if (type_die == NULL) return NULL; - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; @@ -12862,6 +12931,7 @@ scompare_loc_descriptor (enum dwarf_location_atom op, rtx rtl, return NULL; if (dwarf_strict + && dwarf_version < 5 && (!SCALAR_INT_MODE_P (op_mode) || GET_MODE_SIZE (op_mode) > DWARF2_ADDR_SIZE)) return NULL; @@ -12885,12 +12955,12 @@ scompare_loc_descriptor (enum dwarf_location_atom op, rtx rtl, if (type_die == NULL) return NULL; - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; add_loc_descr (&op0, cvt); - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; @@ -12972,7 +13042,9 @@ ucompare_loc_descriptor (enum dwarf_location_atom op, rtx rtl, if (!SCALAR_INT_MODE_P (op_mode)) return NULL; - if (dwarf_strict && GET_MODE_SIZE (op_mode) > DWARF2_ADDR_SIZE) + if (dwarf_strict + && dwarf_version < 5 + && GET_MODE_SIZE (op_mode) > DWARF2_ADDR_SIZE) return NULL; op0 = mem_loc_descriptor (XEXP (rtl, 0), op_mode, mem_mode, @@ -13036,6 +13108,7 @@ minmax_loc_descriptor (rtx rtl, machine_mode mode, dw_loc_descr_ref bra_node, drop_node; if (dwarf_strict + && dwarf_version < 5 && (!SCALAR_INT_MODE_P (mode) || GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE)) return NULL; @@ -13085,12 +13158,12 @@ minmax_loc_descriptor (rtx rtl, machine_mode mode, dw_loc_descr_ref cvt; if (type_die == NULL) return NULL; - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; add_loc_descr (&op0, cvt); - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; @@ -13136,12 +13209,12 @@ typed_binop (enum dwarf_location_atom op, rtx rtl, dw_die_ref type_die, VAR_INIT_STATUS_INITIALIZED); if (op0 == NULL || op1 == NULL) return NULL; - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; add_loc_descr (&op0, cvt); - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; @@ -13609,7 +13682,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, mem_mode, initialized); break; } - if (dwarf_strict) + if (dwarf_strict && dwarf_version < 5) break; if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (inner))) break; @@ -13635,9 +13708,9 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, } if (GET_MODE_SIZE (mode) != GET_MODE_SIZE (GET_MODE (inner))) - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); else - cvt = new_loc_descr (DW_OP_GNU_reinterpret, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_reinterpret), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; @@ -13646,7 +13719,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE) { /* Convert it to untyped afterwards. */ - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); add_loc_descr (&mem_loc_result, cvt); } } @@ -13665,7 +13738,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, dw_die_ref type_die; unsigned int dbx_regnum; - if (dwarf_strict) + if (dwarf_strict && dwarf_version < 5) break; if (REGNO (rtl) > FIRST_PSEUDO_REGISTER) break; @@ -13676,7 +13749,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, dbx_regnum = dbx_reg_number (rtl); if (dbx_regnum == IGNORED_DWARF_REGNUM) break; - mem_loc_result = new_loc_descr (DW_OP_GNU_regval_type, + mem_loc_result = new_loc_descr (dwarf_op (DW_OP_regval_type), dbx_regnum, 0); mem_loc_result->dw_loc_oprnd2.val_class = dw_val_class_die_ref; mem_loc_result->dw_loc_oprnd2.v.val_die_ref.die = type_die; @@ -13748,7 +13821,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, add_loc_descr (&mem_loc_result, int_loc_descriptor (shift)); add_loc_descr (&mem_loc_result, new_loc_descr (op, 0, 0)); } - else if (!dwarf_strict) + else if (!dwarf_strict || dwarf_version >= 5) { dw_die_ref type_die1, type_die2; dw_loc_descr_ref cvt; @@ -13761,12 +13834,12 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, if (type_die2 == NULL) break; mem_loc_result = op0; - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die1; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; add_loc_descr (&mem_loc_result, cvt); - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die2; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; @@ -13798,13 +13871,13 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, dw_die_ref type_die; dw_loc_descr_ref deref; - if (dwarf_strict) + if (dwarf_strict && dwarf_version < 5) return NULL; type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode)); if (type_die == NULL) return NULL; - deref = new_loc_descr (DW_OP_GNU_deref_type, + deref = new_loc_descr (dwarf_op (DW_OP_deref_type), GET_MODE_SIZE (mode), 0); deref->dw_loc_oprnd2.val_class = dw_val_class_die_ref; deref->dw_loc_oprnd2.v.val_die_ref.die = type_die; @@ -13875,7 +13948,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, return 0; case ENTRY_VALUE: - if (dwarf_strict) + if (dwarf_strict && dwarf_version < 5) return NULL; if (REG_P (ENTRY_VALUE_EXP (rtl))) { @@ -13904,7 +13977,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, gcc_unreachable (); if (op0 == NULL) return NULL; - mem_loc_result = new_loc_descr (DW_OP_GNU_entry_value, 0, 0); + mem_loc_result = new_loc_descr (dwarf_op (DW_OP_entry_value), 0, 0); mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_loc; mem_loc_result->dw_loc_oprnd1.v.val_loc = op0; break; @@ -13975,7 +14048,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, goto do_binop; case DIV: - if (!dwarf_strict + if ((!dwarf_strict || dwarf_version >= 5) && SCALAR_INT_MODE_P (mode) && GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) { @@ -14053,7 +14126,8 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, break; case MOD: - if (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE && !dwarf_strict) + if (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE + && (!dwarf_strict || dwarf_version >= 5)) { mem_loc_result = typed_binop (DW_OP_mod, rtl, base_type_for_mode (mode, 0), @@ -14079,7 +14153,8 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, break; case UDIV: - if (!dwarf_strict && SCALAR_INT_MODE_P (mode)) + if ((!dwarf_strict || dwarf_version >= 5) + && SCALAR_INT_MODE_P (mode)) { if (GET_MODE_CLASS (mode) > DWARF2_ADDR_SIZE) { @@ -14127,7 +14202,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, mem_loc_result = int_loc_descriptor (INTVAL (rtl)); break; } - if (!dwarf_strict + if ((!dwarf_strict || dwarf_version >= 5) && (GET_MODE_BITSIZE (mode) == HOST_BITS_PER_WIDE_INT || GET_MODE_BITSIZE (mode) == HOST_BITS_PER_DOUBLE_INT)) { @@ -14140,20 +14215,20 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, if (INTVAL (rtl) >= 0 && amode != BLKmode && trunc_int_for_mode (INTVAL (rtl), amode) == INTVAL (rtl) - /* const DW_OP_GNU_convert vs. - DW_OP_GNU_const_type . */ + /* const DW_OP_convert vs. + DW_OP_const_type . */ && size_of_int_loc_descriptor (INTVAL (rtl)) + 1 + 1 < (unsigned long) 1 + 1 + 1 + GET_MODE_SIZE (mode)) { mem_loc_result = int_loc_descriptor (INTVAL (rtl)); - op0 = new_loc_descr (DW_OP_GNU_convert, 0, 0); + op0 = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); op0->dw_loc_oprnd1.val_class = dw_val_class_die_ref; op0->dw_loc_oprnd1.v.val_die_ref.die = type_die; op0->dw_loc_oprnd1.v.val_die_ref.external = 0; add_loc_descr (&mem_loc_result, op0); return mem_loc_result; } - mem_loc_result = new_loc_descr (DW_OP_GNU_const_type, 0, + mem_loc_result = new_loc_descr (dwarf_op (DW_OP_const_type), 0, INTVAL (rtl)); mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_die_ref; mem_loc_result->dw_loc_oprnd1.v.val_die_ref.die = type_die; @@ -14171,7 +14246,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, break; case CONST_DOUBLE: - if (!dwarf_strict) + if (!dwarf_strict || dwarf_version >= 5) { dw_die_ref type_die; @@ -14190,7 +14265,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode)); if (type_die == NULL) return NULL; - mem_loc_result = new_loc_descr (DW_OP_GNU_const_type, 0, 0); + mem_loc_result = new_loc_descr (dwarf_op (DW_OP_const_type), 0, 0); mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_die_ref; mem_loc_result->dw_loc_oprnd1.v.val_die_ref.die = type_die; mem_loc_result->dw_loc_oprnd1.v.val_die_ref.external = 0; @@ -14218,14 +14293,14 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, break; case CONST_WIDE_INT: - if (!dwarf_strict) + if (!dwarf_strict || dwarf_version >= 5) { dw_die_ref type_die; type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode)); if (type_die == NULL) return NULL; - mem_loc_result = new_loc_descr (DW_OP_GNU_const_type, 0, 0); + mem_loc_result = new_loc_descr (dwarf_op (DW_OP_const_type), 0, 0); mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_die_ref; mem_loc_result->dw_loc_oprnd1.v.val_die_ref.die = type_die; mem_loc_result->dw_loc_oprnd1.v.val_die_ref.external = 0; @@ -14361,7 +14436,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, case UNSIGNED_FLOAT: case FIX: case UNSIGNED_FIX: - if (!dwarf_strict) + if (!dwarf_strict || dwarf_version >= 5) { dw_die_ref type_die; dw_loc_descr_ref cvt; @@ -14379,7 +14454,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, GET_CODE (rtl) == UNSIGNED_FLOAT); if (type_die == NULL) break; - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; @@ -14388,7 +14463,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, type_die = base_type_for_mode (mode, GET_CODE (rtl) == UNSIGNED_FIX); if (type_die == NULL) break; - cvt = new_loc_descr (DW_OP_GNU_convert, 0, 0); + cvt = new_loc_descr (dwarf_op (DW_OP_convert), 0, 0); cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; @@ -14550,7 +14625,7 @@ concatn_loc_descriptor (rtx concatn, enum var_init_status initialized) return cc_loc_result; } -/* Helper function for loc_descriptor. Return DW_OP_GNU_implicit_pointer +/* Helper function for loc_descriptor. Return DW_OP_implicit_pointer for DEBUG_IMPLICIT_PTR RTL. */ static dw_loc_descr_ref @@ -14559,13 +14634,13 @@ implicit_ptr_descriptor (rtx rtl, HOST_WIDE_INT offset) dw_loc_descr_ref ret; dw_die_ref ref; - if (dwarf_strict) + if (dwarf_strict && dwarf_version < 5) return NULL; gcc_assert (TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == VAR_DECL || TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == PARM_DECL || TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == RESULT_DECL); ref = lookup_decl_die (DEBUG_IMPLICIT_PTR_DECL (rtl)); - ret = new_loc_descr (DW_OP_GNU_implicit_pointer, 0, offset); + ret = new_loc_descr (dwarf_op (DW_OP_implicit_pointer), 0, offset); ret->dw_loc_oprnd2.val_class = dw_val_class_const; if (ref) { @@ -15823,6 +15898,13 @@ resolve_args_picking_1 (dw_loc_descr_ref loc, unsigned initial_frame_offset, break; } + case DW_OP_implicit_pointer: + case DW_OP_entry_value: + case DW_OP_const_type: + case DW_OP_regval_type: + case DW_OP_deref_type: + case DW_OP_convert: + case DW_OP_reinterpret: case DW_OP_GNU_push_tls_address: case DW_OP_GNU_uninit: case DW_OP_GNU_encoded_addr: @@ -26198,6 +26280,9 @@ prune_unused_types_walk_loc_descr (dw_loc_descr_ref loc) for (; loc != NULL; loc = loc->dw_loc_next) switch (loc->dw_loc_opc) { + case DW_OP_implicit_pointer: + case DW_OP_convert: + case DW_OP_reinterpret: case DW_OP_GNU_implicit_pointer: case DW_OP_GNU_convert: case DW_OP_GNU_reinterpret: @@ -26207,16 +26292,20 @@ prune_unused_types_walk_loc_descr (dw_loc_descr_ref loc) case DW_OP_call2: case DW_OP_call4: case DW_OP_call_ref: + case DW_OP_const_type: case DW_OP_GNU_const_type: case DW_OP_GNU_parameter_ref: gcc_assert (loc->dw_loc_oprnd1.val_class == dw_val_class_die_ref); prune_unused_types_mark (loc->dw_loc_oprnd1.v.val_die_ref.die, 1); break; + case DW_OP_regval_type: + case DW_OP_deref_type: case DW_OP_GNU_regval_type: case DW_OP_GNU_deref_type: gcc_assert (loc->dw_loc_oprnd2.val_class == dw_val_class_die_ref); prune_unused_types_mark (loc->dw_loc_oprnd2.v.val_die_ref.die, 1); break; + case DW_OP_entry_value: case DW_OP_GNU_entry_value: gcc_assert (loc->dw_loc_oprnd1.val_class == dw_val_class_loc); prune_unused_types_walk_loc_descr (loc->dw_loc_oprnd1.v.val_loc); @@ -26678,18 +26767,24 @@ mark_base_types (dw_loc_descr_ref loc) { switch (loc->dw_loc_opc) { + case DW_OP_regval_type: + case DW_OP_deref_type: case DW_OP_GNU_regval_type: case DW_OP_GNU_deref_type: base_type = loc->dw_loc_oprnd2.v.val_die_ref.die; break; + case DW_OP_convert: + case DW_OP_reinterpret: case DW_OP_GNU_convert: case DW_OP_GNU_reinterpret: if (loc->dw_loc_oprnd1.val_class == dw_val_class_unsigned_const) continue; /* FALLTHRU */ + case DW_OP_const_type: case DW_OP_GNU_const_type: base_type = loc->dw_loc_oprnd1.v.val_die_ref.die; break; + case DW_OP_entry_value: case DW_OP_GNU_entry_value: mark_base_types (loc->dw_loc_oprnd1.v.val_loc); continue; @@ -26834,7 +26929,7 @@ resolve_one_addr (rtx *addr) /* For STRING_CST, return SYMBOL_REF of its constant pool entry, if possible, and create DW_TAG_dwarf_procedure that can be referenced - from DW_OP_GNU_implicit_pointer if the string hasn't been seen yet. */ + from DW_OP_implicit_pointer if the string hasn't been seen yet. */ static rtx string_cst_pool_decl (tree t) @@ -26876,7 +26971,7 @@ string_cst_pool_decl (tree t) a DW_OP_addr followed by DW_OP_stack_value, either at the start of exprloc or after DW_OP_{,bit_}piece, and val_addr can't be resolved. Replace it (both DW_OP_addr and DW_OP_stack_value) - with DW_OP_GNU_implicit_pointer if possible + with DW_OP_implicit_pointer if possible and return true, if unsuccessful, return false. */ static bool @@ -26915,7 +27010,7 @@ optimize_one_addr_into_implicit_ptr (dw_loc_descr_ref loc) if (ref && (get_AT (ref, DW_AT_location) || get_AT (ref, DW_AT_const_value))) { - loc->dw_loc_opc = DW_OP_GNU_implicit_pointer; + loc->dw_loc_opc = dwarf_op (DW_OP_implicit_pointer); loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref; loc->dw_loc_oprnd1.val_entry = NULL; loc->dw_loc_oprnd1.v.val_die_ref.die = ref; @@ -26948,7 +27043,7 @@ resolve_addr_in_expr (dw_loc_descr_ref loc) || prev->dw_loc_opc == DW_OP_bit_piece) && loc->dw_loc_next && loc->dw_loc_next->dw_loc_opc == DW_OP_stack_value - && !dwarf_strict + && (!dwarf_strict || dwarf_version >= 5) && optimize_one_addr_into_implicit_ptr (loc)) break; return false; @@ -26991,6 +27086,7 @@ resolve_addr_in_expr (dw_loc_descr_ref loc) && !resolve_one_addr (&loc->dw_loc_oprnd2.v.val_addr)) return false; break; + case DW_OP_implicit_pointer: case DW_OP_GNU_implicit_pointer: case DW_OP_GNU_parameter_ref: if (loc->dw_loc_oprnd1.val_class == dw_val_class_decl_ref) @@ -27004,17 +27100,25 @@ resolve_addr_in_expr (dw_loc_descr_ref loc) loc->dw_loc_oprnd1.v.val_die_ref.external = 0; } break; + case DW_OP_const_type: + case DW_OP_regval_type: + case DW_OP_deref_type: + case DW_OP_convert: + case DW_OP_reinterpret: case DW_OP_GNU_const_type: case DW_OP_GNU_regval_type: case DW_OP_GNU_deref_type: case DW_OP_GNU_convert: case DW_OP_GNU_reinterpret: while (loc->dw_loc_next - && loc->dw_loc_next->dw_loc_opc == DW_OP_GNU_convert) + && (loc->dw_loc_next->dw_loc_opc == DW_OP_convert + || loc->dw_loc_next->dw_loc_opc == DW_OP_GNU_convert)) { dw_die_ref base1, base2; unsigned enc1, enc2, size1, size2; - if (loc->dw_loc_opc == DW_OP_GNU_regval_type + if (loc->dw_loc_opc == DW_OP_regval_type + || loc->dw_loc_opc == DW_OP_deref_type + || loc->dw_loc_opc == DW_OP_GNU_regval_type || loc->dw_loc_opc == DW_OP_GNU_deref_type) base1 = loc->dw_loc_oprnd2.v.val_die_ref.die; else if (loc->dw_loc_oprnd1.val_class @@ -27038,9 +27142,11 @@ resolve_addr_in_expr (dw_loc_descr_ref loc) && loc != keep) || enc1 == enc2)) { - /* Optimize away next DW_OP_GNU_convert after + /* Optimize away next DW_OP_convert after adjusting LOC's base type die reference. */ - if (loc->dw_loc_opc == DW_OP_GNU_regval_type + if (loc->dw_loc_opc == DW_OP_regval_type + || loc->dw_loc_opc == DW_OP_deref_type + || loc->dw_loc_opc == DW_OP_GNU_regval_type || loc->dw_loc_opc == DW_OP_GNU_deref_type) loc->dw_loc_oprnd2.v.val_die_ref.die = base2; else @@ -27048,7 +27154,7 @@ resolve_addr_in_expr (dw_loc_descr_ref loc) loc->dw_loc_next = loc->dw_loc_next->dw_loc_next; continue; } - /* Don't change integer DW_OP_GNU_convert after e.g. floating + /* Don't change integer DW_OP_convert after e.g. floating point typed stack entry. */ else if (enc1 != DW_ATE_unsigned && enc1 != DW_ATE_signed) keep = loc->dw_loc_next; @@ -27065,7 +27171,7 @@ resolve_addr_in_expr (dw_loc_descr_ref loc) DW_OP_addr alone, which referred to DECL in DW_OP_addr's operand and DW_OP_addr couldn't be resolved. resolve_addr has already removed the DW_AT_location attribute. This function attempts to - add a new DW_AT_location attribute with DW_OP_GNU_implicit_pointer + add a new DW_AT_location attribute with DW_OP_implicit_pointer to it or DW_AT_const_value attribute, if possible. */ static void @@ -27087,13 +27193,13 @@ optimize_location_into_implicit_ptr (dw_die_ref die, tree decl) DW_AT_const_value instead. */ if (tree_add_const_value_attribute (die, init)) return; - if (dwarf_strict) + if (dwarf_strict && dwarf_version < 5) return; /* If init is ADDR_EXPR or POINTER_PLUS_EXPR of ADDR_EXPR, and ADDR_EXPR refers to a decl that has DW_AT_location or DW_AT_const_value (but isn't addressable, otherwise resolving the original DW_OP_addr wouldn't fail), see if - we can add DW_OP_GNU_implicit_pointer. */ + we can add DW_OP_implicit_pointer. */ STRIP_NOPS (init); if (TREE_CODE (init) == POINTER_PLUS_EXPR && tree_fits_shwi_p (TREE_OPERAND (init, 1))) @@ -27127,7 +27233,7 @@ optimize_location_into_implicit_ptr (dw_die_ref die, tree decl) || (!get_AT (ref, DW_AT_location) && !get_AT (ref, DW_AT_const_value))) return; - l = new_loc_descr (DW_OP_GNU_implicit_pointer, 0, offset); + l = new_loc_descr (dwarf_op (DW_OP_implicit_pointer), 0, offset); l->dw_loc_oprnd1.val_class = dw_val_class_die_ref; l->dw_loc_oprnd1.v.val_die_ref.die = ref; l->dw_loc_oprnd1.v.val_die_ref.external = 0; @@ -27150,6 +27256,7 @@ non_dwarf_expression (dw_loc_descr_ref l) case DW_OP_regx: case DW_OP_implicit_value: case DW_OP_stack_value: + case DW_OP_implicit_pointer: case DW_OP_GNU_implicit_pointer: case DW_OP_GNU_parameter_ref: case DW_OP_piece: @@ -27639,12 +27746,16 @@ hash_loc_operands (dw_loc_descr_ref loc, inchash::hash &hstate) inchash::add_rtx (val1->val_entry->addr.rtl, hstate); } break; + case DW_OP_implicit_pointer: case DW_OP_GNU_implicit_pointer: hstate.add_int (val2->v.val_int); break; + case DW_OP_entry_value: case DW_OP_GNU_entry_value: hstate.add_object (val1->v.val_loc); break; + case DW_OP_regval_type: + case DW_OP_deref_type: case DW_OP_GNU_regval_type: case DW_OP_GNU_deref_type: { @@ -27657,6 +27768,8 @@ hash_loc_operands (dw_loc_descr_ref loc, inchash::hash &hstate) hstate.add_object (encoding); } break; + case DW_OP_convert: + case DW_OP_reinterpret: case DW_OP_GNU_convert: case DW_OP_GNU_reinterpret: if (val1->val_class == dw_val_class_unsigned_const) @@ -27665,6 +27778,7 @@ hash_loc_operands (dw_loc_descr_ref loc, inchash::hash &hstate) break; } /* FALLTHRU */ + case DW_OP_const_type: case DW_OP_GNU_const_type: { unsigned int byte_size @@ -27673,7 +27787,8 @@ hash_loc_operands (dw_loc_descr_ref loc, inchash::hash &hstate) = get_AT_unsigned (val1->v.val_die_ref.die, DW_AT_encoding); hstate.add_object (byte_size); hstate.add_object (encoding); - if (loc->dw_loc_opc != DW_OP_GNU_const_type) + if (loc->dw_loc_opc != DW_OP_const_type + && loc->dw_loc_opc != DW_OP_GNU_const_type) break; hstate.add_object (val2->val_class); switch (val2->val_class) @@ -27866,13 +27981,16 @@ compare_loc_operands (dw_loc_descr_ref x, dw_loc_descr_ref y) rtx ay1 = valy1->val_entry->addr.rtl; return rtx_equal_p (ax1, ay1); } + case DW_OP_implicit_pointer: case DW_OP_GNU_implicit_pointer: return valx1->val_class == dw_val_class_die_ref && valx1->val_class == valy1->val_class && valx1->v.val_die_ref.die == valy1->v.val_die_ref.die && valx2->v.val_int == valy2->v.val_int; + case DW_OP_entry_value: case DW_OP_GNU_entry_value: return compare_loc_operands (valx1->v.val_loc, valy1->v.val_loc); + case DW_OP_const_type: case DW_OP_GNU_const_type: if (valx1->v.val_die_ref.die != valy1->v.val_die_ref.die || valx2->val_class != valy2->val_class) @@ -27895,10 +28013,14 @@ compare_loc_operands (dw_loc_descr_ref x, dw_loc_descr_ref y) default: gcc_unreachable (); } + case DW_OP_regval_type: + case DW_OP_deref_type: case DW_OP_GNU_regval_type: case DW_OP_GNU_deref_type: return valx1->v.val_int == valy1->v.val_int && valx2->v.val_die_ref.die == valy2->v.val_die_ref.die; + case DW_OP_convert: + case DW_OP_reinterpret: case DW_OP_GNU_convert: case DW_OP_GNU_reinterpret: if (valx1->val_class != valy1->val_class)