From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15019 invoked by alias); 2 Nov 2017 14:51:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 14882 invoked by uid 89); 2 Nov 2017 14:51:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=reflects, Hx-languages-length:2271, our X-HELO: mail-io0-f176.google.com Received: from mail-io0-f176.google.com (HELO mail-io0-f176.google.com) (209.85.223.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Nov 2017 14:51:12 +0000 Received: by mail-io0-f176.google.com with SMTP id p186so14531308ioe.12 for ; Thu, 02 Nov 2017 07:51:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=h+sSSWbxtN3DVVn07gPsYgAo/gx6Q7Rkt242K69Q0Ho=; b=RBtgblxlvtWrvU3cD1Q6gs9dTEYVdK1zlsEI/jczGbmSGJH0wGUVUp48CMh9nCMrat iwuOpFT7/um34YaJx6RMzP/co8JkMWwmH8SEJFHt5Jlj1PeZIJsdrO1sMxTMczFwb5RX 2rV2zWXLEz3g35QwXhMc6q2txynuFLQ3WR9qMUVpJBau2TgSjMCiZ26cOu+akngPflF/ VfSkd+j/wVvGtTR3wtDHq9oV2NPEumosgqyAf6KWa6CJ3+/mcM8PCsUhsFZVhg9v5iy8 dtedFt+A6RQlbWexjyIloZg0DmuRjx4BWwPjvSS02UPpa6IYZPqXgXVxEUSXAU08sxoZ TwZQ== X-Gm-Message-State: AMCzsaW2j0Hg4/J6k2aFcNCVruduNvam5GGvApXH5UQYFR1mHULOoqdB vNANFwn//W7QORqoE+sJGvlDyl6CBrurj5A5ozi9eA== X-Google-Smtp-Source: ABhQp+R5axhuEJsbSBtO8YHSVQs+mooelSHEql96xvIFjMVPJt0gel5IegbGSoDsXtx1u7pSniUplY8YUba/LAaIq/0= X-Received: by 10.36.182.2 with SMTP id g2mr2989850itf.34.1509634270854; Thu, 02 Nov 2017 07:51:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.170.26 with HTTP; Thu, 2 Nov 2017 07:50:50 -0700 (PDT) In-Reply-To: References: <20170727195014.GA10240@gmail.com> From: Jason Merrill Date: Thu, 02 Nov 2017 14:51:00 -0000 Message-ID: Subject: Re: [PATCH] PR debug/81570: dwarf2cfi.c: Update cfa.offset in create_pseudo_cfg To: "H.J. Lu" Cc: gcc-patches List Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg00099.txt.bz2 On Tue, Oct 31, 2017 at 1:57 PM, H.J. Lu wrote: > On Tue, Oct 24, 2017 at 8:26 PM, Jason Merrill wrote: >> On Thu, Jul 27, 2017 at 3:50 PM, H.J. Lu wrote: >>> execute_dwarf2_frame is called for each funtion. But create_cie_data >>> is called only once to initialize cie_cfi_row for all functions. Since >>> INCOMING_FRAME_SP_OFFSET may be different for each function, we can't >>> use the same INCOMING_FRAME_SP_OFFSET in cie_cfi_row for all functions. >>> This patch sets cie_cfi_row->cfa.offset to INCOMING_FRAME_SP_OFFSET in >>> create_pseudo_cfg which is called for each function. >>> >>> Tested on x86-64. OK for trunk? >> >> This looks wrong. cie_cfi_row is the state produced by the >> instructions in the CIE, which don't vary between functions. If > > /* The state of the first row of the FDE table, which includes the > state provided by the CIE. */ > static GTY(()) dw_cfi_row *cie_cfi_row; > > cie_cfi_row is created by > > cie_cfi_row = cur_row = new_cfi_row (); > > /* On entry, the Canonical Frame Address is at SP. */ > memset (&loc, 0, sizeof (loc)); > loc.reg = dw_stack_pointer_regnum; > loc.offset = INCOMING_FRAME_SP_OFFSET; > def_cfa_1 (&loc); > > and used by create_pseudo_cfg > > ti.beg_row = cie_cfi_row; > ti.cfa_store = cie_cfi_row->cfa; > > The problem is that the offset field in cie_cfi_row->cfa may not be the same for > all functions. Sure, the desired value of the offset field may not be the same. But cie_cfi_row->cfa reflects what the actual DWARF instructions emitted in the CIE tell the consumer. If what those instructions tell the consumer is wrong for some functions, then we need to add instructions to the FDE for such functions in order to correct the information. Pretending that the CIE means different things to different functions will just mean that unwinding fails. > cie_cfi_row does change in this case. My patch simply corrects > the offset in CFA of the first row of the FDE table. > >> INCOMING_FRAME_SP_OFFSET varies, we need to add actual FDE >> instructions to reflect that, not just clobber our current model of >> what the CIE means. >> >> Jason > > > > -- > H.J.