public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Mark Wielaard <mark@klomp.org>, Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org, tom@tromey.com
Subject: Re: [PATCH 2/5] Make sure that static data member constexpr isn't optimized away in test.
Date: Tue, 9 Feb 2021 14:40:12 -0500	[thread overview]
Message-ID: <fe81267c-ae2a-2a3e-70a5-3a8e83611bb8@redhat.com> (raw)
In-Reply-To: <02d2f197-ea05-79bb-d6e5-c462fa46c59e@redhat.com>

On 9/1/20 2:46 PM, Jason Merrill wrote:
> On 8/25/20 5:19 AM, Mark Wielaard wrote:
>> On Mon, 2020-08-24 at 17:38 -0400, Jason Merrill wrote:
>>>> This looks incorrect to me, that is a workaround for a real GCC bug.
>>>>
>>>> Shouldn't we instead do something like (untested) following patch?
>>>> I mean, for DWARF < 5 the static data members were using DW_TAG_member,
>>>> which has been always marked by the function, so IMHO we should also 
>>>> always
>>>> mark the DW_TAG_variables at the class scope that replaced those.
>>>
>>> The earlier behavior seems like an accident, that happened because we
>>> always need to emit information about non-static data members.  I don't
>>> think we should take it as guidance.
>>
>> Maybe the reason they got emitted this way was an accident on the GCC
>> side. But I don't think it is an accident on the GDB side. At least
>> looking at the various gdb testcases, the intention is to show a
>> struct/class type as defined to the user, which includes both the
>> static and non-static data members of a class.
> 
> That would make sense.

So, GDB prefers no pruning of members...

>>> In this case one reason we don't emit debug info is because (before
>>> C++17) there's no definition of 'b'.  After C++17 the in-class
>>> declaration of 'b' is a definition, but we don't have to give it a
>>> symbol, so there's still nothing for the debug info to describe.
>>
>> But don't we describe other parts of a type that don't have a symbol as
>> part of the debug info?
> 
> It seems that currently we describe unused/undefined functions, but not 
> unused nested types/typedefs.

> On 8/25/20 8:41 AM, Jakub Jelinek wrote:
>>
>> On Mon, Aug 24, 2020 at 05:38:28PM -0400, Jason Merrill via 
>> Gcc-patches wrote:
>>>
>>> This issue doesn't seem specific to class members; it also affects
>>> namespace-scope C++17 inline variables:
>>>
>>> inline const int var = 42;
>>> int main() { return var; }
>>>
>>> Compiling this testcase with -g doesn't emit any debug info for 'var' 
>>> even
>>> though it's used.
>>>
>>> Should we assume that if a variable with DW_AT_const_value is 
>>> TREE_USED, we
>>> need to write out debug info for it?
>>
>> I guess it is a question of how exactly the (default on)
>> -feliminate-unused-debug-symbols should behave with different kind of
>> entities.
>>
>> One thing are the non-inline static data members without const/constexpr or
>> without initializer in the class.  Those need a definition if they are ever
>> used, so it is probably fine to only emit them in the class in the TU where
>> they are defined.  But note that e.g. with -fdebug-types-section we still
>> force them to be output in class and do no pruning (and the pruning actually
>> makes dwz less efficient unless dwz is tought to not only merge the DIEs
>> with the same children and attributes, but also reconstruct more complete
>> DIEs out of several less complete ones for the same class).
> 
> Right, this gets at Mark's point above.  How much pruning do we want to 
> do of class bodies?  We currently do some, but how much benefit does 
> that actually give us?  Is it worth the cost?

...and our deduplication mechanisms prefer no pruning of members.

>> Another case is non-inline static const data member with initializer,
>> do we track non-odr uses e.g. during constant evaluation and if so, should
>> that result in the static data member appearing?  Because if the static
>> const data member with initializer is never odr used, it doesn't have to be
>> ever defined and so it might never appear in the debug info.
>>
>> Another case are inline vars, shall we treat as being used just that they
>> were used in some constant expression, or do only odr uses count?
> 
> If the goal of debug info is to be able to evaluate the same expressions 
> that appear in the source, constant uses need to count, too.  I wonder 
> how we could associate the uses with their context so pruning works 
> properly.

For GCC 11, I think let's fix the regression with your (Jakub) earlier 
patch, maybe only for DIEs with DW_AT_const_value.

For GCC 12, maybe we want to stop pruning any class members by default.

Jason


  reply	other threads:[~2021-02-09 19:40 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-24 12:56 BoF DWARF5 patches Mark Wielaard
2020-08-24 12:56 ` [PATCH 1/5] Don't enable -gvariable-location-views by default for DWARF5 Mark Wielaard
2020-08-24 17:38   ` Jakub Jelinek
2020-08-24 20:12     ` Mark Wielaard
2020-08-25  4:05     ` Alexandre Oliva
2020-08-25  7:27       ` Richard Biener
2020-08-25  9:24       ` Mark Wielaard
2020-08-26 12:22         ` Alexandre Oliva
2020-09-29 11:15     ` Mark Wielaard
2020-08-24 12:56 ` [PATCH 2/5] Make sure that static data member constexpr isn't optimized away in test Mark Wielaard
2020-08-24 17:40   ` Jakub Jelinek
2020-08-24 20:17     ` Mark Wielaard
2020-08-24 20:59       ` Tom Tromey
2020-08-24 21:38     ` Jason Merrill
2020-08-25  9:19       ` Mark Wielaard
2020-09-01 18:46         ` Jason Merrill
2021-02-09 19:40           ` Jason Merrill [this message]
2021-02-09 19:55             ` Jakub Jelinek
2021-02-09 23:15               ` Jakub Jelinek
2020-08-25 12:41       ` Jakub Jelinek
2020-08-24 12:56 ` [PATCH 3/5] Add DWARF5 variants of assembly scan tests that use DW_FORM_implicit_const Mark Wielaard
2020-08-24 17:44   ` Jakub Jelinek
2020-08-24 20:26     ` Mark Wielaard
2020-09-17 16:03       ` Mark Wielaard
2020-09-17 16:45         ` Jakub Jelinek
2020-08-24 12:56 ` [PATCH 4/5] Default to DWARF5 Mark Wielaard
2020-08-24 12:56 ` [PATCH 5/5] Add --gdwarf-5 to ASM_SPEC Mark Wielaard
2020-08-26 21:37   ` Duplicate .debug_lines (Was: [PATCH 5/5] Add --gdwarf-5 to ASM_SPEC) Mark Wielaard
2020-08-26 23:38     ` H.J. Lu
2020-08-29 12:23       ` Mark Wielaard
2020-08-29 14:34         ` H.J. Lu
2020-08-29 15:23           ` Mark Wielaard
2020-08-29 15:43             ` H.J. Lu
2020-08-29 16:32               ` Mark Wielaard
2020-08-29 16:44                 ` H.J. Lu
2020-08-29 17:32                   ` Mark Wielaard
2020-09-07 12:37     ` [PATCH] gas: Don't error when .debug_line already exists, unless .loc was used Mark Wielaard
2020-08-25  9:32 ` BoF DWARF5 patches Mark Wielaard
2020-09-09 19:57   ` BoF DWARF5 patches (25% .debug section size reduction) Mark Wielaard
2020-09-10 11:16     ` Jakub Jelinek
2020-09-10 11:45       ` Jakub Jelinek
2020-09-15 18:40         ` [PATCH] debug: Pass --gdwarf-N to assembler if fixed gas is detected during configure Jakub Jelinek
2020-09-16 12:33           ` Mark Wielaard
2020-09-16 13:31             ` Jakub Jelinek
2020-09-18 15:21           ` Mark Wielaard
2020-10-06 15:54             ` Mark Wielaard
2020-10-06 20:57               ` Jason Merrill
2020-10-07 11:29                 ` Mark Wielaard
2020-09-29 13:56       ` BoF DWARF5 patches (25% .debug section size reduction) Mark Wielaard
2020-11-15 22:41         ` Mark Wielaard
2021-01-15 16:16           ` Jakub Jelinek
2021-01-18 10:19             ` Sebastian Huber
2021-01-18 11:18             ` Mark Wielaard
2020-11-17  0:19         ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe81267c-ae2a-2a3e-70a5-3a8e83611bb8@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=mark@klomp.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).