From patchwork Mon Oct 23 17:10:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116771 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4877270qgn; Mon, 23 Oct 2017 10:11:35 -0700 (PDT) X-Received: by 10.98.53.196 with SMTP id c187mr14004817pfa.38.1508778695449; Mon, 23 Oct 2017 10:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508778695; cv=none; d=google.com; s=arc-20160816; b=K/hSQEDbYMNuPBJYjR76Qc7u2Rata0EMpU7majOKrJj1Do6zTOzKJgnUjSINrHzBcb XI4AjNa3hIAumDe8Fss3zmVXQCNN6aijYqn5JO7FJc5nJgG+8wBAyDKNGbfxluBJn7kF SXHLhkc6ew2/n32zpdvI8orrFBnIFYn0QhBDHJQW5RB1WJL3i2fB0Bvz4D4TvJUKpL4c j2dgxASj6aLEG3Qx9eBukHSYlGYQdhelfRf4u38dQN81z2e0lUi3E2S7ZwJz7ICVxyDg Ui9lWrYSa8tRrQGvZtlY4X/C2gbJDwtm1vU4I11djGbEF/AFCRaJiaUUFCs/TunwoQBH XCbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=EOOjc469vgb4H1LE8gQC4HYxjvv4bdSPkUsgIKaxoSU=; b=Zo2MSgs/G1lQD6J6gxfpUkDzhlu4NrU6DWanbv8PHchnaQJbRLfemu3qNIc+uwCs1T WotnxNPtD8CDP9xPnmhSU3BxygzuHgE38KcMbpHfFHLgEBRU9irTq4g429AwA19V82jp tm0YOD4lDOLih5EyEt8rJ9GYApEszH91legA9nmLAEE99rCnNsnFSc11evLKXRgXiQV3 QYW+/ALJUFNefKNEkeMFsxkSIr54/1DTQgxngm9+KLOXL/PbSgTB8781oFIfxsYRqqoS 7kkFFnOUVvKu6WqNZV+G4Yeid8XBzsUR8Up7eb9KQq+2MkMfgc+L82EvBVaAy5toV3fb 8Ptw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yr0g8b4k; spf=pass (google.com: domain of gcc-patches-return-464803-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464803-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z19si5550238pfe.624.2017.10.23.10.11.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464803-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yr0g8b4k; spf=pass (google.com: domain of gcc-patches-return-464803-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464803-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=WYfGSzYuKVZFA3pM1tJrWfQXTbSHM sZcn83059214iV4ambP2HUcKU6jGoRsciTNgfG1JuUH/1uSMipmo+/6vXBFIJ1tc PKhtQ7uPSKb+N7tRxuMqJeNTF43PeuyOZGAy4z4pBwKEZgLTVRfIygLbh21AtShD U0mqSGfOSV/RLk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=oe60n23zUUDKbwxsfE76aK6d2I0=; b=yr0 g8b4keekDmFNS00FYM9AJKH6tqrmHsu5Gn15zA3ocg3IwStQPNRx4dhDvIyjBsCR 6+MbLc4hhHH1xMOAvmtM6CKEYLZ6gsvF2lYaAIy/LsWjx9BD+BnzUdhef7C80sKu bcLnZtdlxtUxKbvOLgf3cNRwmSuiGMHaBKko4s2U= Received: (qmail 11418 invoked by alias); 23 Oct 2017 17:11:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 11355 invoked by uid 89); 23 Oct 2017 17:11:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=20027 X-HELO: mail-wm0-f54.google.com Received: from mail-wm0-f54.google.com (HELO mail-wm0-f54.google.com) (74.125.82.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:11:02 +0000 Received: by mail-wm0-f54.google.com with SMTP id q124so10916795wmb.0 for ; Mon, 23 Oct 2017 10:11:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=EOOjc469vgb4H1LE8gQC4HYxjvv4bdSPkUsgIKaxoSU=; b=eSKkiT66gIJBxtAhZwXCDp2sF1mcon3GF0QkpCTvnGYUIr4mr/qI1eCk9lbdd9QUSu mUSI+3w7S/kx5gayGmigk0plqqKKuMiWyciwgm34MjKe4uZfprVl9mT5I2BirX4gTRi4 eUOWobLk3hBirlGWMhEKCEoZ/5JxUdP0nWI69VGjm7PPrXIvkxQSbdPIUQ7ZgSZb83Am EeH9GNXcY9eo3itSZe2qgv6myOrcH160lwBOUmWUrtvcUifAl79TpA6HZcXLU0cfZPZM iE0OLtzGNYObzc3XgJwQGpvl5UXUKlGvA/9/JD9ppbtsoIGFvFaQFqnnoH7gByTAvLCE Ckag== X-Gm-Message-State: AMCzsaWfQbZJiFwzitiowUWtxyGa/Uw44Fm5V/8ra12tRCs4PJJxui7j TjTtIxd0uaFmvv145VEGOS0YEwblZI4= X-Google-Smtp-Source: ABhQp+QpjyDG/wSpnIvS5DEqOKgmIC2UYG8+8vgxRwxzCk1jxVKWntWE+M5uKw4Oma5U5YVoVptAsQ== X-Received: by 10.28.137.193 with SMTP id l184mr5813131wmd.24.1508778660019; Mon, 23 Oct 2017 10:11:00 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id h5sm5264355wrb.89.2017.10.23.10.10.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:10:59 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [027/nnn] poly_int: DWARF CFA offsets References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:10:58 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87mv4hpz6l.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes the DWARF code use poly_int64 rather than HOST_WIDE_INT for CFA offsets. The main changes are: - to make reg_save use a DW_CFA_expression representation when the offset isn't constant and - to record the CFA information alongside a def_cfa_expression if either offset is polynomial, since it's quite difficult to reconstruct the CFA information otherwise. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * gengtype.c (main): Handle poly_int64_pod. * dwarf2out.h (dw_cfi_oprnd_cfa_loc): New dw_cfi_oprnd_type. (dw_cfi_oprnd::dw_cfi_cfa_loc): New field. (dw_cfa_location::offset, dw_cfa_location::base_offset): Change from HOST_WIDE_INT to poly_int64_pod. * dwarf2cfi.c (queued_reg_save::cfa_offset): Likewise. (copy_cfa): New function. (lookup_cfa_1): Use the cached dw_cfi_cfa_loc, if it exists. (cfi_oprnd_equal_p): Handle dw_cfi_oprnd_cfa_loc. (cfa_equal_p, dwarf2out_frame_debug_adjust_cfa) (dwarf2out_frame_debug_cfa_offset, dwarf2out_frame_debug_expr) (initial_return_save): Treat offsets as poly_ints. (def_cfa_0): Likewise. Cache the CFA in dw_cfi_cfa_loc if either offset is nonconstant. (reg_save): Take the offset as a poly_int64. Fall back to DW_CFA_expression for nonconstant offsets. (queue_reg_save): Take the offset as a poly_int64. * dwarf2out.c (dw_cfi_oprnd2_desc): Handle DW_CFA_def_cfa_expression. Index: gcc/gengtype.c =================================================================== --- gcc/gengtype.c 2017-10-23 17:16:50.367528682 +0100 +++ gcc/gengtype.c 2017-10-23 17:16:57.211604434 +0100 @@ -5192,6 +5192,7 @@ #define POS_HERE(Call) do { pos.file = t POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos)); POS_HERE (do_scalar_typedef ("FIXED_VALUE_TYPE", &pos)); POS_HERE (do_scalar_typedef ("double_int", &pos)); + POS_HERE (do_scalar_typedef ("poly_int64_pod", &pos)); POS_HERE (do_scalar_typedef ("offset_int", &pos)); POS_HERE (do_scalar_typedef ("widest_int", &pos)); POS_HERE (do_scalar_typedef ("int64_t", &pos)); Index: gcc/dwarf2out.h =================================================================== --- gcc/dwarf2out.h 2017-10-23 17:11:40.311071579 +0100 +++ gcc/dwarf2out.h 2017-10-23 17:16:57.210604569 +0100 @@ -43,7 +43,8 @@ enum dw_cfi_oprnd_type { dw_cfi_oprnd_reg_num, dw_cfi_oprnd_offset, dw_cfi_oprnd_addr, - dw_cfi_oprnd_loc + dw_cfi_oprnd_loc, + dw_cfi_oprnd_cfa_loc }; typedef union GTY(()) { @@ -51,6 +52,8 @@ typedef union GTY(()) { HOST_WIDE_INT GTY ((tag ("dw_cfi_oprnd_offset"))) dw_cfi_offset; const char * GTY ((tag ("dw_cfi_oprnd_addr"))) dw_cfi_addr; struct dw_loc_descr_node * GTY ((tag ("dw_cfi_oprnd_loc"))) dw_cfi_loc; + struct dw_cfa_location * GTY ((tag ("dw_cfi_oprnd_cfa_loc"))) + dw_cfi_cfa_loc; } dw_cfi_oprnd; struct GTY(()) dw_cfi_node { @@ -114,8 +117,8 @@ struct GTY(()) dw_fde_node { Instead of passing around REG and OFFSET, we pass a copy of this structure. */ struct GTY(()) dw_cfa_location { - HOST_WIDE_INT offset; - HOST_WIDE_INT base_offset; + poly_int64_pod offset; + poly_int64_pod base_offset; /* REG is in DWARF_FRAME_REGNUM space, *not* normal REGNO space. */ unsigned int reg; BOOL_BITFIELD indirect : 1; /* 1 if CFA is accessed via a dereference. */ Index: gcc/dwarf2cfi.c =================================================================== --- gcc/dwarf2cfi.c 2017-10-23 17:07:41.013611927 +0100 +++ gcc/dwarf2cfi.c 2017-10-23 17:16:57.208604839 +0100 @@ -206,7 +206,7 @@ static GTY(()) unsigned long dwarf2out_c struct queued_reg_save { rtx reg; rtx saved_reg; - HOST_WIDE_INT cfa_offset; + poly_int64_pod cfa_offset; }; @@ -434,6 +434,16 @@ copy_cfi_row (dw_cfi_row *src) return dst; } +/* Return a copy of an existing CFA location. */ + +static dw_cfa_location * +copy_cfa (dw_cfa_location *src) +{ + dw_cfa_location *dst = ggc_alloc (); + *dst = *src; + return dst; +} + /* Generate a new label for the CFI info to refer to. */ static char * @@ -629,7 +639,10 @@ lookup_cfa_1 (dw_cfi_ref cfi, dw_cfa_loc loc->offset = cfi->dw_cfi_oprnd2.dw_cfi_offset; break; case DW_CFA_def_cfa_expression: - get_cfa_from_loc_descr (loc, cfi->dw_cfi_oprnd1.dw_cfi_loc); + if (cfi->dw_cfi_oprnd2.dw_cfi_cfa_loc) + *loc = *cfi->dw_cfi_oprnd2.dw_cfi_cfa_loc; + else + get_cfa_from_loc_descr (loc, cfi->dw_cfi_oprnd1.dw_cfi_loc); break; case DW_CFA_remember_state: @@ -654,10 +667,10 @@ lookup_cfa_1 (dw_cfi_ref cfi, dw_cfa_loc cfa_equal_p (const dw_cfa_location *loc1, const dw_cfa_location *loc2) { return (loc1->reg == loc2->reg - && loc1->offset == loc2->offset + && must_eq (loc1->offset, loc2->offset) && loc1->indirect == loc2->indirect && (loc1->indirect == 0 - || loc1->base_offset == loc2->base_offset)); + || must_eq (loc1->base_offset, loc2->base_offset))); } /* Determine if two CFI operands are identical. */ @@ -678,6 +691,8 @@ cfi_oprnd_equal_p (enum dw_cfi_oprnd_typ || strcmp (a->dw_cfi_addr, b->dw_cfi_addr) == 0); case dw_cfi_oprnd_loc: return loc_descr_equal_p (a->dw_cfi_loc, b->dw_cfi_loc); + case dw_cfi_oprnd_cfa_loc: + return cfa_equal_p (a->dw_cfi_cfa_loc, b->dw_cfi_cfa_loc); } gcc_unreachable (); } @@ -758,19 +773,23 @@ def_cfa_0 (dw_cfa_location *old_cfa, dw_ cfi = new_cfi (); - if (new_cfa->reg == old_cfa->reg && !new_cfa->indirect && !old_cfa->indirect) + HOST_WIDE_INT const_offset; + if (new_cfa->reg == old_cfa->reg + && !new_cfa->indirect + && !old_cfa->indirect + && new_cfa->offset.is_constant (&const_offset)) { /* Construct a "DW_CFA_def_cfa_offset " instruction, indicating the CFA register did not change but the offset did. The data factoring for DW_CFA_def_cfa_offset_sf happens in output_cfi, or in the assembler via the .cfi_def_cfa_offset directive. */ - if (new_cfa->offset < 0) + if (const_offset < 0) cfi->dw_cfi_opc = DW_CFA_def_cfa_offset_sf; else cfi->dw_cfi_opc = DW_CFA_def_cfa_offset; - cfi->dw_cfi_oprnd1.dw_cfi_offset = new_cfa->offset; + cfi->dw_cfi_oprnd1.dw_cfi_offset = const_offset; } - else if (new_cfa->offset == old_cfa->offset + else if (must_eq (new_cfa->offset, old_cfa->offset) && old_cfa->reg != INVALID_REGNUM && !new_cfa->indirect && !old_cfa->indirect) @@ -781,19 +800,20 @@ def_cfa_0 (dw_cfa_location *old_cfa, dw_ cfi->dw_cfi_opc = DW_CFA_def_cfa_register; cfi->dw_cfi_oprnd1.dw_cfi_reg_num = new_cfa->reg; } - else if (new_cfa->indirect == 0) + else if (new_cfa->indirect == 0 + && new_cfa->offset.is_constant (&const_offset)) { /* Construct a "DW_CFA_def_cfa " instruction, indicating the CFA register has changed to with the specified offset. The data factoring for DW_CFA_def_cfa_sf happens in output_cfi, or in the assembler via the .cfi_def_cfa directive. */ - if (new_cfa->offset < 0) + if (const_offset < 0) cfi->dw_cfi_opc = DW_CFA_def_cfa_sf; else cfi->dw_cfi_opc = DW_CFA_def_cfa; cfi->dw_cfi_oprnd1.dw_cfi_reg_num = new_cfa->reg; - cfi->dw_cfi_oprnd2.dw_cfi_offset = new_cfa->offset; + cfi->dw_cfi_oprnd2.dw_cfi_offset = const_offset; } else { @@ -805,6 +825,13 @@ def_cfa_0 (dw_cfa_location *old_cfa, dw_ cfi->dw_cfi_opc = DW_CFA_def_cfa_expression; loc_list = build_cfa_loc (new_cfa, 0); cfi->dw_cfi_oprnd1.dw_cfi_loc = loc_list; + if (!new_cfa->offset.is_constant () + || !new_cfa->base_offset.is_constant ()) + /* It's hard to reconstruct the CFA location for a polynomial + expression, so just cache it instead. */ + cfi->dw_cfi_oprnd2.dw_cfi_cfa_loc = copy_cfa (new_cfa); + else + cfi->dw_cfi_oprnd2.dw_cfi_cfa_loc = NULL; } return cfi; @@ -836,33 +863,42 @@ def_cfa_1 (dw_cfa_location *new_cfa) otherwise it is saved in SREG. */ static void -reg_save (unsigned int reg, unsigned int sreg, HOST_WIDE_INT offset) +reg_save (unsigned int reg, unsigned int sreg, poly_int64 offset) { dw_fde_ref fde = cfun ? cfun->fde : NULL; dw_cfi_ref cfi = new_cfi (); cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg; - /* When stack is aligned, store REG using DW_CFA_expression with FP. */ - if (fde - && fde->stack_realign - && sreg == INVALID_REGNUM) - { - cfi->dw_cfi_opc = DW_CFA_expression; - cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg; - cfi->dw_cfi_oprnd2.dw_cfi_loc - = build_cfa_aligned_loc (&cur_row->cfa, offset, - fde->stack_realignment); - } - else if (sreg == INVALID_REGNUM) - { - if (need_data_align_sf_opcode (offset)) - cfi->dw_cfi_opc = DW_CFA_offset_extended_sf; - else if (reg & ~0x3f) - cfi->dw_cfi_opc = DW_CFA_offset_extended; + if (sreg == INVALID_REGNUM) + { + HOST_WIDE_INT const_offset; + /* When stack is aligned, store REG using DW_CFA_expression with FP. */ + if (fde && fde->stack_realign) + { + cfi->dw_cfi_opc = DW_CFA_expression; + cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg; + cfi->dw_cfi_oprnd2.dw_cfi_loc + = build_cfa_aligned_loc (&cur_row->cfa, offset, + fde->stack_realignment); + } + else if (offset.is_constant (&const_offset)) + { + if (need_data_align_sf_opcode (const_offset)) + cfi->dw_cfi_opc = DW_CFA_offset_extended_sf; + else if (reg & ~0x3f) + cfi->dw_cfi_opc = DW_CFA_offset_extended; + else + cfi->dw_cfi_opc = DW_CFA_offset; + cfi->dw_cfi_oprnd2.dw_cfi_offset = const_offset; + } else - cfi->dw_cfi_opc = DW_CFA_offset; - cfi->dw_cfi_oprnd2.dw_cfi_offset = offset; + { + cfi->dw_cfi_opc = DW_CFA_expression; + cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg; + cfi->dw_cfi_oprnd2.dw_cfi_loc + = build_cfa_loc (&cur_row->cfa, offset); + } } else if (sreg == reg) { @@ -995,7 +1031,7 @@ record_reg_saved_in_reg (rtx dest, rtx s SREG, or if SREG is NULL then it is saved at OFFSET to the CFA. */ static void -queue_reg_save (rtx reg, rtx sreg, HOST_WIDE_INT offset) +queue_reg_save (rtx reg, rtx sreg, poly_int64 offset) { queued_reg_save *q; queued_reg_save e = {reg, sreg, offset}; @@ -1097,20 +1133,11 @@ dwarf2out_frame_debug_def_cfa (rtx pat) { memset (cur_cfa, 0, sizeof (*cur_cfa)); - if (GET_CODE (pat) == PLUS) - { - cur_cfa->offset = INTVAL (XEXP (pat, 1)); - pat = XEXP (pat, 0); - } + pat = strip_offset (pat, &cur_cfa->offset); if (MEM_P (pat)) { cur_cfa->indirect = 1; - pat = XEXP (pat, 0); - if (GET_CODE (pat) == PLUS) - { - cur_cfa->base_offset = INTVAL (XEXP (pat, 1)); - pat = XEXP (pat, 0); - } + pat = strip_offset (XEXP (pat, 0), &cur_cfa->base_offset); } /* ??? If this fails, we could be calling into the _loc functions to define a full expression. So far no port does that. */ @@ -1133,7 +1160,7 @@ dwarf2out_frame_debug_adjust_cfa (rtx pa { case PLUS: gcc_assert (dwf_regno (XEXP (src, 0)) == cur_cfa->reg); - cur_cfa->offset -= INTVAL (XEXP (src, 1)); + cur_cfa->offset -= rtx_to_poly_int64 (XEXP (src, 1)); break; case REG: @@ -1152,7 +1179,7 @@ dwarf2out_frame_debug_adjust_cfa (rtx pa static void dwarf2out_frame_debug_cfa_offset (rtx set) { - HOST_WIDE_INT offset; + poly_int64 offset; rtx src, addr, span; unsigned int sregno; @@ -1170,7 +1197,7 @@ dwarf2out_frame_debug_cfa_offset (rtx se break; case PLUS: gcc_assert (dwf_regno (XEXP (addr, 0)) == cur_cfa->reg); - offset = INTVAL (XEXP (addr, 1)) - cur_cfa->offset; + offset = rtx_to_poly_int64 (XEXP (addr, 1)) - cur_cfa->offset; break; default: gcc_unreachable (); @@ -1195,7 +1222,7 @@ dwarf2out_frame_debug_cfa_offset (rtx se { /* We have a PARALLEL describing where the contents of SRC live. Adjust the offset for each piece of the PARALLEL. */ - HOST_WIDE_INT span_offset = offset; + poly_int64 span_offset = offset; gcc_assert (GET_CODE (span) == PARALLEL); @@ -1535,7 +1562,7 @@ dwarf2out_frame_debug_cfa_window_save (v dwarf2out_frame_debug_expr (rtx expr) { rtx src, dest, span; - HOST_WIDE_INT offset; + poly_int64 offset; dw_fde_ref fde; /* If RTX_FRAME_RELATED_P is set on a PARALLEL, process each member of @@ -1639,19 +1666,14 @@ dwarf2out_frame_debug_expr (rtx expr) { /* Rule 2 */ /* Adjusting SP. */ - switch (GET_CODE (XEXP (src, 1))) + if (REG_P (XEXP (src, 1))) { - case CONST_INT: - offset = INTVAL (XEXP (src, 1)); - break; - case REG: gcc_assert (dwf_regno (XEXP (src, 1)) == cur_trace->cfa_temp.reg); offset = cur_trace->cfa_temp.offset; - break; - default: - gcc_unreachable (); } + else if (!poly_int_rtx_p (XEXP (src, 1), &offset)) + gcc_unreachable (); if (XEXP (src, 0) == hard_frame_pointer_rtx) { @@ -1680,9 +1702,8 @@ dwarf2out_frame_debug_expr (rtx expr) gcc_assert (frame_pointer_needed); gcc_assert (REG_P (XEXP (src, 0)) - && dwf_regno (XEXP (src, 0)) == cur_cfa->reg - && CONST_INT_P (XEXP (src, 1))); - offset = INTVAL (XEXP (src, 1)); + && dwf_regno (XEXP (src, 0)) == cur_cfa->reg); + offset = rtx_to_poly_int64 (XEXP (src, 1)); if (GET_CODE (src) != MINUS) offset = -offset; cur_cfa->offset += offset; @@ -1695,11 +1716,11 @@ dwarf2out_frame_debug_expr (rtx expr) /* Rule 4 */ if (REG_P (XEXP (src, 0)) && dwf_regno (XEXP (src, 0)) == cur_cfa->reg - && CONST_INT_P (XEXP (src, 1))) + && poly_int_rtx_p (XEXP (src, 1), &offset)) { /* Setting a temporary CFA register that will be copied into the FP later on. */ - offset = - INTVAL (XEXP (src, 1)); + offset = -offset; cur_cfa->offset += offset; cur_cfa->reg = dwf_regno (dest); /* Or used to save regs to the stack. */ @@ -1722,11 +1743,9 @@ dwarf2out_frame_debug_expr (rtx expr) /* Rule 9 */ else if (GET_CODE (src) == LO_SUM - && CONST_INT_P (XEXP (src, 1))) - { - cur_trace->cfa_temp.reg = dwf_regno (dest); - cur_trace->cfa_temp.offset = INTVAL (XEXP (src, 1)); - } + && poly_int_rtx_p (XEXP (src, 1), + &cur_trace->cfa_temp.offset)) + cur_trace->cfa_temp.reg = dwf_regno (dest); else gcc_unreachable (); } @@ -1734,8 +1753,9 @@ dwarf2out_frame_debug_expr (rtx expr) /* Rule 6 */ case CONST_INT: + case POLY_INT_CST: cur_trace->cfa_temp.reg = dwf_regno (dest); - cur_trace->cfa_temp.offset = INTVAL (src); + cur_trace->cfa_temp.offset = rtx_to_poly_int64 (src); break; /* Rule 7 */ @@ -1745,7 +1765,11 @@ dwarf2out_frame_debug_expr (rtx expr) && CONST_INT_P (XEXP (src, 1))); cur_trace->cfa_temp.reg = dwf_regno (dest); - cur_trace->cfa_temp.offset |= INTVAL (XEXP (src, 1)); + if (!can_ior_p (cur_trace->cfa_temp.offset, INTVAL (XEXP (src, 1)), + &cur_trace->cfa_temp.offset)) + /* The target shouldn't generate this kind of CFI note if we + can't represent it. */ + gcc_unreachable (); break; /* Skip over HIGH, assuming it will be followed by a LO_SUM, @@ -1800,9 +1824,7 @@ dwarf2out_frame_debug_expr (rtx expr) 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); - offset = -INTVAL (XEXP (XEXP (XEXP (dest, 0), 1), 1)); + offset = -rtx_to_poly_int64 (XEXP (XEXP (XEXP (dest, 0), 1), 1)); gcc_assert (REGNO (XEXP (XEXP (dest, 0), 0)) == STACK_POINTER_REGNUM && cur_trace->cfa_store.reg == dw_stack_pointer_regnum); @@ -1860,9 +1882,8 @@ dwarf2out_frame_debug_expr (rtx expr) { unsigned int regno; - gcc_assert (CONST_INT_P (XEXP (XEXP (dest, 0), 1)) - && REG_P (XEXP (XEXP (dest, 0), 0))); - offset = INTVAL (XEXP (XEXP (dest, 0), 1)); + gcc_assert (REG_P (XEXP (XEXP (dest, 0), 0))); + offset = rtx_to_poly_int64 (XEXP (XEXP (dest, 0), 1)); if (GET_CODE (XEXP (dest, 0)) == MINUS) offset = -offset; @@ -1923,7 +1944,7 @@ dwarf2out_frame_debug_expr (rtx expr) { /* We're storing the current CFA reg into the stack. */ - if (cur_cfa->offset == 0) + if (known_zero (cur_cfa->offset)) { /* Rule 19 */ /* If stack is aligned, putting CFA reg into stack means @@ -1981,7 +2002,7 @@ dwarf2out_frame_debug_expr (rtx expr) { /* We have a PARALLEL describing where the contents of SRC live. Queue register saves for each piece of the PARALLEL. */ - HOST_WIDE_INT span_offset = offset; + poly_int64 span_offset = offset; gcc_assert (GET_CODE (span) == PARALLEL); @@ -2884,7 +2905,7 @@ create_pseudo_cfg (void) initial_return_save (rtx rtl) { unsigned int reg = INVALID_REGNUM; - HOST_WIDE_INT offset = 0; + poly_int64 offset = 0; switch (GET_CODE (rtl)) { @@ -2905,12 +2926,12 @@ initial_return_save (rtx rtl) case PLUS: gcc_assert (REGNO (XEXP (rtl, 0)) == STACK_POINTER_REGNUM); - offset = INTVAL (XEXP (rtl, 1)); + offset = rtx_to_poly_int64 (XEXP (rtl, 1)); break; case MINUS: gcc_assert (REGNO (XEXP (rtl, 0)) == STACK_POINTER_REGNUM); - offset = -INTVAL (XEXP (rtl, 1)); + offset = -rtx_to_poly_int64 (XEXP (rtl, 1)); break; default: Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-10-23 17:16:50.362529357 +0100 +++ gcc/dwarf2out.c 2017-10-23 17:16:57.210604569 +0100 @@ -570,6 +570,9 @@ dw_cfi_oprnd2_desc (enum dwarf_call_fram case DW_CFA_val_expression: return dw_cfi_oprnd_loc; + case DW_CFA_def_cfa_expression: + return dw_cfi_oprnd_cfa_loc; + default: return dw_cfi_oprnd_unused; }