public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/104550] bogus warning from -Wuninitialized + -ftrivial-auto-var-init=pattern
Date: Thu, 17 Feb 2022 08:01:05 +0000	[thread overview]
Message-ID: <bug-104550-4-q6ply2fvNw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104550-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104550

--- Comment #13 from rguenther at suse dot de <rguenther at suse dot de> ---
On Wed, 16 Feb 2022, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104550
> 
> Jakub Jelinek <jakub at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |jakub at gcc dot gnu.org
> 
> --- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> Well, for the .DEFERRED_INIT case if the var ends up in memory, I really don't
> see the point in any clear_padding, .DEFERRED_INIT expansion should just
> initialize the whole DECL_RTL MEM_P slot with the pattern it wants, trying to
> initialize only the non-padding bits and then only the padding bits next to
> each other is a waste of CPU cycles.
> Another case are C++ vars with non-trivial ctors, if we for -flifetime-dse=2
> emit CLOBBERs at the start of such ctors, then IMNSHO the right thing is to
> emit the zero or pattern initialization in those constructors, perhaps through
> .DEFERRED_INIT.
> This is the start_preparsed_function
>   if (!processing_template_decl
>       && (flag_lifetime_dse > 1)
>       && DECL_CONSTRUCTOR_P (decl1)
>       && !DECL_CLONED_FUNCTION_P (decl1)
>       /* Clobbering an empty base is harmful if it overlays real data.  */
>       && !is_empty_class (current_class_type)
>       /* We can't clobber safely for an implicitly-defined default constructor
>          because part of the initialization might happen before we enter the
>          constructor, via AGGR_INIT_ZERO_FIRST (c++/68006).  */
>       && !implicit_default_ctor_p (decl1))
>     finish_expr_stmt (build_clobber_this ());
> case.  Advantage of doing it in the ctor is that if it isn't inlined, it is
> done just once per type, doesn't need to be duplicated in all the spots that
> use it.
> Of course, if the above conditions aren't met, then it still needs to be
> initialized somewhere else like where it is done currently, or for the case of
> vars with constructors for which we don't emit it perhaps do
> __builtin_clear_padding after the constructor (but can we be sure that the ctor
> hasn't e.g. performed placement new and built in itself some other class?).
> 
> Anyway, doing __builtin_clear_padding at RTL expansion time might be
> non-trivial.  One thing we still haven't decided on what to do with the virtual
> inheritance, whether we need a langhook which won't be there at expansion time,
> or if we can just use binfo (but doesn't free_lang_data mess up with binfo
> too)?
> And right now the code has two main possibilities, either emit gimple code to
> do the clearing, or set a padding bitmask in memory.  For RTL, either one could
> use the latter and turn that into RTL code clearing, or we would need a third
> mode in which it would be emitting RTL directly.  Emitting such code early has
> the advantage of store-merging and all kinds of other optimizations though...

There's also the option to do .DEFERRED_INIT expansion on GIMPLE 
somewhere, maybe in ISEL.  But sure, if padding clearing needs a langhook
that's a no-go.  BINFOs are preserved to the extent needed for
devirtualization.  I suppose the mask could also be precomputed and
stuck into the .DEFERRED_INIT call itself somehow ... (encoded into
some sequence of variable number of args? <offset>, <mask>, <offset>, 
<mask>, 0)

  parent reply	other threads:[~2022-02-17  8:01 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 15:49 [Bug middle-end/104550] New: " qinzhao at gcc dot gnu.org
2022-02-15 15:50 ` [Bug middle-end/104550] " qinzhao at gcc dot gnu.org
2022-02-15 15:52 ` qinzhao at gcc dot gnu.org
2022-02-15 21:33 ` qinzhao at gcc dot gnu.org
2022-02-15 21:38 ` pinskia at gcc dot gnu.org
2022-02-15 22:38 ` qing.zhao at oracle dot com
2022-02-16 10:33 ` rguenther at suse dot de
2022-02-16 15:05 ` qinzhao at gcc dot gnu.org
2022-02-16 15:38 ` jakub at gcc dot gnu.org
2022-02-16 16:24 ` qinzhao at gcc dot gnu.org
2022-02-16 16:44 ` jakub at gcc dot gnu.org
2022-02-16 16:57 ` qinzhao at gcc dot gnu.org
2022-02-17  7:54 ` rguenther at suse dot de
2022-02-17  8:01 ` rguenther at suse dot de [this message]
2022-02-17 16:47 ` qing.zhao at oracle dot com
2022-02-17 16:53 ` jakub at gcc dot gnu.org
2022-02-18  6:53 ` rguenther at suse dot de
2022-02-18 17:16 ` qinzhao at gcc dot gnu.org
2022-02-18 20:14 ` qinzhao at gcc dot gnu.org
2022-02-21  7:56 ` rguenth at gcc dot gnu.org
2022-02-21 15:21 ` qing.zhao at oracle dot com
2022-02-28 15:58 ` cvs-commit at gcc dot gnu.org
2022-02-28 16:00 ` qinzhao at gcc dot gnu.org

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=bug-104550-4-q6ply2fvNw@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).