public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "slyfox at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/98499] [11 Regression] Possibly bad std::string initialization in constructors
Date: Sat, 30 Jan 2021 18:02:55 +0000	[thread overview]
Message-ID: <bug-98499-4-7VB35NPu0Z@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98499-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #10 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #9)
> Thanks for all the detailed analysis and sorry for getting into this late.
> 
> > Oh, thank you! Only after many printf() attempts it sunk in that `036t.ealias` is using data from seemingly later `043t.modref1` pass. It is so confusing!
> 
> This is because it is an inter-procedural analysis.  We compile in
> topological order and propagate info from function to callers.
> 
> Here I think poblem is:
> 
> void Importer::Importer (struct Importer * const this)                      
> 
> {                                                                           
> 
>   struct string * _1;                                                       
> 
>                                                                             
> 
>   <bb 2> :                                                                  
> 
>   *this_3(D) ={v} {CLOBBER};                                                
> 
>   *this_3(D).base_path = dir_name (); [return slot optimization]            
> 
>   return;                                                                   
> 
>                                                                             
> 
> }                                                                           
> 
> 
> We get parm 0 flags: direct noescape nodirectescape
> 
> While dir_name does:
> 
> struct string dir_name ()                                                   
> 
> {                                                                           
> 
>   <bb 2> :                                                                  
> 
>   string::string (_2(D));                                                   
> 
>   return _2(D);                                                             
> 
>                                                                             
> 
> }
> and that gets to                                                            
> 
> void string::string (struct string * const this)                            
> 
> {                                                                           
> 
>   char[16] * _1;                                                            
> 
>                                                                             
> 
>   <bb 2> :                                                                  
> 
>   *this_3(D) ={v} {CLOBBER};                                                
> 
>   _1 = &this_3(D)->_M_local_buf;                                            
> 
>   *this_3(D)._M_buf = _1;                                                   
> 
>   return;                                                                   
> 
>                                                                             
> 
> }                                                                           
> 
> which indeed conflict with noescape.
> 
> So problem here is that return slot optimized variables are behaving kind of
> like parameters.  Since modref does not track EAF flags for them I think
> your conservative fix makes sense.
> 
> It is also relatively easy to track the EAF flags here, I will try to get
> quick stats on how often this makes difference (and whether we want to add
> trakcing now or next stage1).

Sounds great!

I send a conservative variant of the patch with the test as
https://gcc.gnu.org/pipermail/gcc-patches/2021-January/564579.html. I hope I
will not interfere with your possible improvement.

  parent reply	other threads:[~2021-01-30 18:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-02 11:11 [Bug c++/98499] New: " slyfox at gcc dot gnu.org
2021-01-02 22:22 ` [Bug c++/98499] " slyfox at gcc dot gnu.org
2021-01-03 11:44 ` slyfox at gcc dot gnu.org
2021-01-03 20:56 ` slyfox at gcc dot gnu.org
2021-01-03 21:50 ` slyfox at gcc dot gnu.org
2021-01-04 12:28 ` marxin at gcc dot gnu.org
2021-01-05 11:09 ` rguenth at gcc dot gnu.org
2021-01-06 23:11 ` [Bug tree-optimization/98499] " slyfox at gcc dot gnu.org
2021-01-07  8:12 ` rguenth at gcc dot gnu.org
2021-01-10 18:39 ` slyfox at gcc dot gnu.org
2021-01-28 10:55 ` hubicka at gcc dot gnu.org
2021-01-30 18:02 ` slyfox at gcc dot gnu.org [this message]
2021-02-01 18:14 ` cvs-commit at gcc dot gnu.org
2021-02-01 18:39 ` slyfox at gcc dot gnu.org
2021-02-01 18:40 ` slyfox 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-98499-4-7VB35NPu0Z@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).