public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/110879] [14 Regression] Unnecessary reread from memory in a loop with std::vector
Date: Fri, 01 Sep 2023 15:02:30 +0000	[thread overview]
Message-ID: <bug-110879-4-mfkyg2sOcZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110879-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:419c423d3aeca754e47e1ce1bf707735603a90a3

commit r14-3627-g419c423d3aeca754e47e1ce1bf707735603a90a3
Author: Vladimir Palevich <palevichva@gmail.com>
Date:   Wed Aug 9 01:34:05 2023 +0300

    libstdc++: fix memory clobbering in std::vector [PR110879]

    Fix ordering to prevent clobbering of class members by a call to deallocate
    in _M_realloc_insert and _M_default_append.

    Because of recent changes in _M_realloc_insert and _M_default_append,
    calls to deallocate were ordered after assignment to class members of
    std::vector (in the guard destructor), which is causing said members to
    be call-clobbered.  This is preventing further optimization, the
    compiler is unable to move memory read out of a hot loop in this case.

    This patch reorders the call to before assignments by putting guard in
    its own block. Plus a new testsuite for this case.  I'm not very happy
    with the new testsuite, but I don't know how to properly test this.

            PR libstdc++/110879

    libstdc++-v3/ChangeLog:

            * include/bits/vector.tcc (_M_realloc_insert): End guard
            lifetime just before assignment to class members.
            (_M_default_append): Likewise.

    gcc/testsuite/ChangeLog:

            * g++.dg/pr110879.C: New test.

    Signed-off-by: Vladimir Palevich  <palevichva@gmail.com>

  parent reply	other threads:[~2023-09-01 15:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02 19:26 [Bug c++/110879] New: Unnecessary reread from memory in a loop palevichva at gmail dot com
2023-08-03 11:42 ` [Bug libstdc++/110879] [14 Regression] Unnecessary reread from memory in a loop with std::vector rguenth at gcc dot gnu.org
2023-09-01 15:02 ` cvs-commit at gcc dot gnu.org [this message]
2023-09-01 16:12 ` redi at gcc dot gnu.org
2023-11-22  8:53 ` jakub at gcc dot gnu.org
2023-11-22 11:27 ` redi at gcc dot gnu.org
2023-11-23 10:58 ` cvs-commit 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-110879-4-mfkyg2sOcZ@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).