From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2270 invoked by alias); 7 Feb 2018 04:02:35 -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 2259 invoked by uid 89); 7 Feb 2018 04:02:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*o:Group, assessment, defers, fighter 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 ESMTP; Wed, 07 Feb 2018 04:02:32 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5F33883B4; Wed, 7 Feb 2018 04:02:31 +0000 (UTC) Received: from freie.home (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B5395C556; Wed, 7 Feb 2018 04:02:31 +0000 (UTC) Received: from livre (livre.home [172.31.160.2]) by freie.home (8.15.2/8.15.2) with ESMTP id w17427pR012717; Wed, 7 Feb 2018 02:02:07 -0200 From: Alexandre Oliva To: Jason Merrill Cc: Jeff Law , Richard Biener , Jakub Jelinek , gcc-patches Subject: Re: [SFN+LVU+IEPM v4 7/9] [LVU] Introduce location views References: <20171110023448.28164-7-aoliva@redhat.com> <7d731476-256b-28c3-69fe-e28c116281d1@redhat.com> <309c52a4-e2cb-2cc4-a31f-c57b717d10c3@redhat.com> Date: Wed, 07 Feb 2018 04:02:00 -0000 In-Reply-To: <309c52a4-e2cb-2cc4-a31f-c57b717d10c3@redhat.com> (Jason Merrill's message of "Tue, 6 Feb 2018 16:13:07 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2018-02/txt/msg00297.txt.bz2 On Feb 6, 2018, Jason Merrill wrote: > On 12/11/2017 09:52 PM, Alexandre Oliva wrote: >> +/* output symbol LAB1 as an unsigned LEB128 quantity. */ >> + >> +void >> +dw2_asm_output_symname_uleb128 (const char *lab1 ATTRIBUTE_UNUSED, >> + const char *comment, ...) > I'm having trouble understanding the use of symbols for views. The > configure test for gas support doesn't obviously define a symbol > anywhere; is it implicitly defined by its use in the location > directive? This could use more documentation in dwarf2out. Yeah. It's the .loc statement that assigns a view number to the view number symbol. That's documented in the gas manual, but I guess it won't hurt to add something to dwarf2out too. Will do. >> + view computation, and it is refers to a view identifier for which > "it refers" Thanks > Why do we need to use a non-zero view identifier for a zero view? Why > can't we always use 0 instead of the bitmap? We assign view ids before we can determine whether the assigned view id will be a zero view. That's because we scan insns forward, and debug binds take effect at the next .loc directive, which might be hundreds of insns after the first reference (lots of intervening debug binds before the insn that will take the next view), and insns that would cause the .loc directive to be at a different address from that of the previous .loc might be anywhere between those two loc-generating insns, before or after the bind. So, by the time we have to assign an id to the view, we don't know whether we'll find an insn that sets RESETTING_VIEW_P before we reach the loc-emitting insn that will take that view id. It made more sense to me to assign the ids uniformly, and then mark those that we find to be zero when we reach them, than to scan forward (potentially O(n^2)) to tell in advance. This also reduces differences in view id tracking between gcc-internal and asm view assignment. >> DW_LNS_fixed_advance_pc is the only opcode that may change the >> address without resetting the view. It is available for compilers >> to use when an address change is uncertain, e.g., when advancing >> past opcodes that may expand to an empty sequence, >> e.g. possibly-empty alignment sequences, optional no-operation >> opcodes or the like. >> + if (debug_variable_location_views && table->view) >> + push_dw_line_info_entry (table, LI_adv_address, label_num); > It looks like you'll always use DW_LNS_fixed_advance_pc when we don't > have .loc support. Does that mean that the view never gets reset? No, table->view will be zero if we have crossed an insn that RESET_NEXT_VIEW, and then we'll use a LI_set_address. > I'm uncomfortable with the special handling of this opcode; it isn't > special in DWARF5 except as a fallback if more compact encodings > aren't usable. Currently GCC is even more conservative than this, and > always use a relocation (DW_LNS_set_address); if we can use D_L_f_a_p > instead, I would expect that to help with link times. It seems wrong > to use it only in the context of view support. We didn't use it before, but if we use, that's ok. We don't *have* to reset the view number to zero at a PC change. It would be all right to never reset it, as long as the compiler and the debug info consumer agrees about it. Since in some cases the compiler has to assign views itself (when the assembler doesn't support views), but it can't tell whether there will be a PC change (e.g. at an align), we need some mechanism that predictably refrains from resetting the view number, otherwise the compiler might pick a view number based on a possibly incorrect assumption about whether the align changes PC or not, and then it might not match what the consumer, that knows whether the PC advanced, would compute. To make it concrete: # ... .L352: # .loc 1 533 view 3 (internal compiler tracking, no assembler support) mov r12 <- whatever # DEBUG x => r12 .balign 32 .L353: # .loc 1 480 view Consider you're the compiler and you're generating a view-augmented loclist for variable x. You have to indicate the view number at .L353 for the range that starts there, and possibly for the range that ends there. But is the view number 4 or 0? Namely, does .balign advance PC or not? The compiler can't possibly know. So if it guesses .balign does advance PC and assign a view number zero at .L353, but it guesses wrong, that will be indistinguishable from view number zero at say .L350, because the PC is the same. The debug info consumer will see no PC change and assign view number 4 to the line number table entry correspoding to the .loc directive with view , but it won't find any loclist referencing that view number. Conversely, if the compiler guessed .balign did not advance PC, it would assign view number 4 to .L353, but then, with your suggestion, the debug info consumer would instead assign it view number zero, and we'd be out of sync. That's why we need an opcode that enables the compiler and the debug info consumer to remain in sync, disregarding a potential PC change that would cause a view reset, because the compiler can't predict whether or not there will be an actual PC change. > Would it make sense to say for *all* opcodes that the view is reset if > and only if the address actually changes? I don't see how to keep compiler and consumer in sync with this arrangement. That's why I introduced the one exceptional opcode. > How are we coordinating the line number table and location list > versions of the view counter? When the compiler is emitting the line number programs and computing view numbers itself, it resets view numbers at known PC changes and counts from that, and then it emits view numbers as literal constants in locviewlists. When the compiler defers view computation to the assembler, it emits symbolic view numbers in locviewlists, with the exception of views known to be zero (forced resets, or reset after compiler-visible PC changes): instead of emitting symbols for these, we emit literal zero and assert the assembler agrees with the compiler's assessment. We could use symbolic views everywhere, instead of special-casing zero views, but then we'd be unable to optimize out locviewlists that contain only zeros. -- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer