From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9957 invoked by alias); 26 May 2016 16:16:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 9931 invoked by uid 89); 26 May 2016 16:16:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=expressed, cfa, CFA, programmer X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 26 May 2016 16:16:41 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26AB94DB09; Thu, 26 May 2016 16:16:40 +0000 (UTC) Received: from [10.36.6.226] (vpn1-6-226.ams2.redhat.com [10.36.6.226]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4QGGbc5001766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 26 May 2016 12:16:39 -0400 Subject: Re: RFA: Generate normal DWARF DW_LOC descriptors for non integer mode pointers To: Jeff Law , gcc-patches@gcc.gnu.org References: <87h9dyt7m3.fsf@redhat.com> <1c7da1c8-c088-6c35-dbc8-bacebd4ad4d0@redhat.com> <344916c2-c8d0-9a4b-1fc4-0b8035276ea6@redhat.com> <9f8e1f36-5186-67bc-898e-6910e0d041a6@redhat.com> Cc: gdb-patches@sourceware.org From: Nick Clifton Message-ID: <424fe5c1-a849-6d4d-fdca-ac531e8ee53b@redhat.com> Date: Thu, 26 May 2016 16:16:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <9f8e1f36-5186-67bc-898e-6910e0d041a6@redhat.com> Content-Type: multipart/mixed; boundary="------------4242A829675FA77DA1FE622A" X-SW-Source: 2016-05/txt/msg00457.txt.bz2 This is a multi-part message in MIME format. --------------4242A829675FA77DA1FE622A Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Content-length: 2344 Hi Jeff, >>> I may be missing something, but isn't it the transition to an FP >>> relative address rather than a SP relative address that's the problem >>> here? >> >> Yes, I believe so. >> >>> Where does that happen? I think that it happens in dwarf2out.c:based_loc_descr() which detects the use of the frame pointer and works out that it is going to be eliminated to the stack pointer: /* We only use "frame base" when we're sure we're talking about the post-prologue local stack frame. We do this by *not* running register elimination until this point, and recognizing the special argument pointer and soft frame pointer rtx's. */ if (reg == arg_pointer_rtx || reg == frame_pointer_rtx) { rtx elim = (ira_use_lra_p ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX) : eliminate_regs (reg, VOIDmode, NULL_RTX)); if (elim != reg) ..... The problem, I believe, is that based_loc_descr() is only called from mem_loc_descriptor when the mode of the rtl concerned is an MODE_INT. For example: case REG: if (GET_MODE_CLASS (mode) != MODE_INT [...] else if (REGNO (rtl) < FIRST_PSEUDO_REGISTER) mem_loc_result = based_loc_descr (rtl, 0, VAR_INIT_STATUS_INITIALIZED); or, (this is another one that I found whilst investigating this problem further): case PLUS: plus: if (is_based_loc (rtl) && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE || XEXP (rtl, 0) == arg_pointer_rtx || XEXP (rtl, 0) == frame_pointer_rtx) && GET_MODE_CLASS (mode) == MODE_INT) mem_loc_result = based_loc_descr (XEXP (rtl, 0), INTVAL (XEXP (rtl, 1)), VAR_INIT_STATUS_INITIALIZED); else There are quite a few places in mem_loc_descriptor where the code checks for the mode being in the MODE_INT class. I am not exactly sure why. I think that it might be that the programmer thought that any expression that does not involve integer based arithmetic cannot be expressed in DWARF CFA notation and so would have to be handled specially. If I am correct, then it seems to me that the proper fix would be to use SCALAR_INT_MODE_P instead. I tried out the extended patch (attached) and it gave even better GDB results for the MSP430 and still no regressions (GCC or GDB) for MSP430 or x86_64. Is this enough justification ? Cheers Nick --------------4242A829675FA77DA1FE622A Content-Type: application/x-troff-man; name="dwarf2out.c.patch.2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="dwarf2out.c.patch.2" Content-length: 10502 Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 236761) +++ gcc/dwarf2out.c (working copy) @@ -12605,7 +12605,7 @@ return NULL; if (dwarf_strict - && (GET_MODE_CLASS (op_mode) != MODE_INT + && (!SCALAR_INT_MODE_P (op_mode) || GET_MODE_SIZE (op_mode) > DWARF2_ADDR_SIZE)) return NULL; @@ -12617,7 +12617,7 @@ if (op0 == NULL || op1 == NULL) return NULL; - if (GET_MODE_CLASS (op_mode) != MODE_INT + if (!SCALAR_INT_MODE_P (op_mode) || GET_MODE_SIZE (op_mode) == DWARF2_ADDR_SIZE) return compare_loc_descriptor (op, op0, op1); @@ -12712,7 +12712,7 @@ op_mode = GET_MODE (XEXP (rtl, 1)); if (op_mode == VOIDmode) return NULL; - if (GET_MODE_CLASS (op_mode) != MODE_INT) + if (!SCALAR_INT_MODE_P (op_mode)) return NULL; if (dwarf_strict && GET_MODE_SIZE (op_mode) > DWARF2_ADDR_SIZE) @@ -12779,7 +12779,7 @@ dw_loc_descr_ref bra_node, drop_node; if (dwarf_strict - && (GET_MODE_CLASS (mode) != MODE_INT + && (!SCALAR_INT_MODE_P (mode) || GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE)) return NULL; @@ -12812,7 +12812,7 @@ add_loc_descr (&op1, new_loc_descr (DW_OP_plus_uconst, bias, 0)); } } - else if (GET_MODE_CLASS (mode) == MODE_INT + else if (!SCALAR_INT_MODE_P (mode) && GET_MODE_SIZE (mode) < DWARF2_ADDR_SIZE) { int shift = (DWARF2_ADDR_SIZE - GET_MODE_SIZE (mode)) * BITS_PER_UNIT; @@ -12821,7 +12821,7 @@ add_loc_descr (&op1, int_loc_descriptor (shift)); add_loc_descr (&op1, new_loc_descr (DW_OP_shl, 0, 0)); } - else if (GET_MODE_CLASS (mode) == MODE_INT + else if (SCALAR_INT_MODE_P (mode) && GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) { dw_die_ref type_die = base_type_for_mode (mode, 0); @@ -12855,7 +12855,7 @@ bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc; bra_node->dw_loc_oprnd1.v.val_loc = drop_node; if ((GET_CODE (rtl) == SMIN || GET_CODE (rtl) == SMAX) - && GET_MODE_CLASS (mode) == MODE_INT + && SCALAR_INT_MODE_P (mode) && GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) ret = convert_descriptor_to_mode (mode, ret); return ret; @@ -12934,7 +12934,7 @@ dw_loc_descr_ref l4jump, l4label; rtx msb; - if (GET_MODE_CLASS (mode) != MODE_INT + if (!SCALAR_INT_MODE_P (mode) || GET_MODE (XEXP (rtl, 0)) != mode) return NULL; @@ -13042,7 +13042,7 @@ dw_loc_descr_ref l1jump, l1label; dw_loc_descr_ref l2jump, l2label; - if (GET_MODE_CLASS (mode) != MODE_INT + if (!SCALAR_INT_MODE_P (mode) || GET_MODE (XEXP (rtl, 0)) != mode) return NULL; @@ -13103,7 +13103,7 @@ dw_loc_descr_ref l1jump, l1label; dw_loc_descr_ref l2jump, l2label; - if (GET_MODE_CLASS (mode) != MODE_INT + if (!SCALAR_INT_MODE_P (mode) || BITS_PER_UNIT != 8 || (GET_MODE_BITSIZE (mode) != 32 && GET_MODE_BITSIZE (mode) != 64)) @@ -13188,7 +13188,7 @@ dw_loc_descr_ref op0, op1, ret, mask[2] = { NULL, NULL }; int i; - if (GET_MODE_CLASS (mode) != MODE_INT) + if (!SCALAR_INT_MODE_P (mode)) return NULL; if (GET_MODE (rtlop1) != VOIDmode @@ -13337,8 +13337,8 @@ case TRUNCATE: if (inner == NULL_RTX) inner = XEXP (rtl, 0); - if (GET_MODE_CLASS (mode) == MODE_INT - && GET_MODE_CLASS (GET_MODE (inner)) == MODE_INT + if (SCALAR_INT_MODE_P (mode) + && SCALAR_INT_MODE_P (GET_MODE (inner)) && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE #ifdef POINTERS_EXTEND_UNSIGNED || (mode == Pmode && mem_mode != VOIDmode) @@ -13356,8 +13356,8 @@ if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (inner))) break; if (GET_MODE_SIZE (mode) != GET_MODE_SIZE (GET_MODE (inner)) - && (GET_MODE_CLASS (mode) != MODE_INT - || GET_MODE_CLASS (GET_MODE (inner)) != MODE_INT)) + && (!SCALAR_INT_MODE_P (mode) + || !SCALAR_INT_MODE_P (GET_MODE (inner)))) break; else { @@ -13369,8 +13369,7 @@ mem_mode, initialized); if (mem_loc_result == NULL) break; - type_die = base_type_for_mode (mode, - GET_MODE_CLASS (mode) == MODE_INT); + type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode)); if (type_die == NULL) { mem_loc_result = NULL; @@ -13385,7 +13384,7 @@ cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; add_loc_descr (&mem_loc_result, cvt); - if (GET_MODE_CLASS (mode) == MODE_INT + if (SCALAR_INT_MODE_P (mode) && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE) { /* Convert it to untyped afterwards. */ @@ -13396,7 +13395,7 @@ break; case REG: - if (GET_MODE_CLASS (mode) != MODE_INT + if (! SCALAR_INT_MODE_P (mode) || (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE && rtl != arg_pointer_rtx && rtl != frame_pointer_rtx @@ -13412,8 +13411,7 @@ break; if (REGNO (rtl) > FIRST_PSEUDO_REGISTER) break; - type_die = base_type_for_mode (mode, - GET_MODE_CLASS (mode) == MODE_INT); + type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode)); if (type_die == NULL) break; @@ -13420,7 +13418,7 @@ 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 (DW_OP_GNU_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; @@ -13456,7 +13454,7 @@ case SIGN_EXTEND: case ZERO_EXTEND: - if (GET_MODE_CLASS (mode) != MODE_INT) + if (!SCALAR_INT_MODE_P (mode)) break; op0 = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (XEXP (rtl, 0)), mem_mode, VAR_INIT_STATUS_INITIALIZED); @@ -13537,7 +13535,7 @@ if (mem_loc_result != NULL) { if (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE - || GET_MODE_CLASS (mode) != MODE_INT) + || !SCALAR_INT_MODE_P(mode)) { dw_die_ref type_die; dw_loc_descr_ref deref; @@ -13545,7 +13543,7 @@ if (dwarf_strict) return NULL; type_die - = base_type_for_mode (mode, GET_MODE_CLASS (mode) == MODE_INT); + = 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, @@ -13573,8 +13571,7 @@ pool. */ case CONST: case SYMBOL_REF: - if ((GET_MODE_CLASS (mode) != MODE_INT - && GET_MODE_CLASS (mode) != MODE_PARTIAL_INT) + if (!SCALAR_INT_MODE_P (mode) || (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE #ifdef POINTERS_EXTEND_UNSIGNED && (mode != Pmode || mem_mode == VOIDmode) @@ -13624,7 +13621,7 @@ return NULL; if (REG_P (ENTRY_VALUE_EXP (rtl))) { - if (GET_MODE_CLASS (mode) != MODE_INT + if (!SCALAR_INT_MODE_P (mode) || GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) op0 = mem_loc_descriptor (ENTRY_VALUE_EXP (rtl), mode, VOIDmode, VAR_INIT_STATUS_INITIALIZED); @@ -13682,7 +13679,7 @@ && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE || XEXP (rtl, 0) == arg_pointer_rtx || XEXP (rtl, 0) == frame_pointer_rtx) - && GET_MODE_CLASS (mode) == MODE_INT) + && SCALAR_INT_MODE_P (mode)) mem_loc_result = based_loc_descr (XEXP (rtl, 0), INTVAL (XEXP (rtl, 1)), VAR_INIT_STATUS_INITIALIZED); @@ -13721,7 +13718,7 @@ case DIV: if (!dwarf_strict - && GET_MODE_CLASS (mode) == MODE_INT + && SCALAR_INT_MODE_P (mode) && GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) { mem_loc_result = typed_binop (DW_OP_div, rtl, @@ -13749,7 +13746,7 @@ goto do_shift; do_shift: - if (GET_MODE_CLASS (mode) != MODE_INT) + if (!SCALAR_INT_MODE_P (mode)) break; op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, VAR_INIT_STATUS_INITIALIZED); @@ -13824,7 +13821,7 @@ break; case UDIV: - if (!dwarf_strict && GET_MODE_CLASS (mode) == MODE_INT) + if (!dwarf_strict && SCALAR_INT_MODE_P (mode)) { if (GET_MODE_CLASS (mode) > DWARF2_ADDR_SIZE) { @@ -13932,8 +13929,7 @@ || (GET_MODE (rtl) == VOIDmode && GET_MODE_BITSIZE (mode) != HOST_BITS_PER_DOUBLE_INT)) break; - type_die = base_type_for_mode (mode, - GET_MODE_CLASS (mode) == MODE_INT); + 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); @@ -13968,8 +13964,7 @@ { dw_die_ref type_die; - type_die = base_type_for_mode (mode, - GET_MODE_CLASS (mode) == MODE_INT); + 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); @@ -14025,7 +14020,7 @@ case UMIN: case UMAX: - if (GET_MODE_CLASS (mode) != MODE_INT) + if (!SCALAR_INT_MODE_P (mode)) break; /* FALLTHRU */ case SMIN: @@ -14040,7 +14035,7 @@ && ((unsigned) INTVAL (XEXP (rtl, 1)) + (unsigned) INTVAL (XEXP (rtl, 2)) <= GET_MODE_BITSIZE (mode)) - && GET_MODE_CLASS (mode) == MODE_INT + && SCALAR_INT_MODE_P (mode) && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE && GET_MODE_SIZE (GET_MODE (XEXP (rtl, 0))) <= DWARF2_ADDR_SIZE) { @@ -14117,7 +14112,7 @@ mem_mode, VAR_INIT_STATUS_INITIALIZED); if (op0 == NULL) break; - if (GET_MODE_CLASS (GET_MODE (XEXP (rtl, 0))) == MODE_INT + if (SCALAR_INT_MODE_P (GET_MODE (XEXP (rtl, 0))) && (GET_CODE (rtl) == FLOAT || GET_MODE_SIZE (GET_MODE (XEXP (rtl, 0))) <= DWARF2_ADDR_SIZE)) @@ -14140,7 +14135,7 @@ 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); - if (GET_MODE_CLASS (mode) == MODE_INT + if (SCALAR_INT_MODE_P (mode) && (GET_CODE (rtl) == FIX || GET_MODE_SIZE (mode) < DWARF2_ADDR_SIZE)) { @@ -14570,7 +14565,8 @@ /* FALLTHRU */ do_default: default: - if ((GET_MODE_CLASS (mode) == MODE_INT && GET_MODE (rtl) == mode + if ((SCALAR_INT_MODE_P (mode) + && GET_MODE (rtl) == mode && GET_MODE_SIZE (GET_MODE (rtl)) <= DWARF2_ADDR_SIZE && dwarf_version >= 4) || (!dwarf_strict && mode != VOIDmode && mode != BLKmode)) --------------4242A829675FA77DA1FE622A--