public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61982] New: Optimizer does not eliminate stores to destroyed objects
@ 2014-07-31 18:54 avi@cloudius-systems.com
  2014-08-01  8:24 ` [Bug c++/61982] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: avi@cloudius-systems.com @ 2014-07-31 18:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61982
           Summary: Optimizer does not eliminate stores to destroyed
                    objects
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: avi@cloudius-systems.com

After a destructor is run, access to the object is forbidden; the object is
turned into a pile of bytes.  Yet the generated code for:


struct X { 
  int i; 
  void clear() { i = 0; } 
}; 

void f(X* x) { 
  x->clear(); 
  x->~X(); 
} 

void g(X* x) {
  x->clear();
  delete x;
}

contains a store for each of f() and g(), stores that should have been
eliminated:

0000000000000000 <f(X*)>:
   0:    c7 07 00 00 00 00        movl   $0x0,(%rdi)
   6:    c3                       retq   
   7:    66 0f 1f 84 00 00 00     nopw   0x0(%rax,%rax,1)
   e:    00 00 

0000000000000010 <g(X*)>:
  10:    c7 07 00 00 00 00        movl   $0x0,(%rdi)
  16:    e9 00 00 00 00           jmpq   1b <g(X*)+0xb>
            17: R_X86_64_PC32    operator delete(void*)-0x4


To be clear, the generated code is correct, but not optimal.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/61982] Optimizer does not eliminate stores to destroyed objects
  2014-07-31 18:54 [Bug c++/61982] New: Optimizer does not eliminate stores to destroyed objects avi@cloudius-systems.com
@ 2014-08-01  8:24 ` rguenth at gcc dot gnu.org
  2014-08-01 15:12 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-08-01  8:24 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-08-01
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at redhat dot com
            Version|unknown                     |4.9.1
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
We are missing CLOBBERs here - Jakub, ISTR you added indirect clobbers for
this kind of stuff from the C++ frontend in some cases, but why not here?
Seems this was for TARGET_EXPRs only?  That is, here the frontend would be
responsible for adding them?

Confirmed.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/61982] Optimizer does not eliminate stores to destroyed objects
  2014-07-31 18:54 [Bug c++/61982] New: Optimizer does not eliminate stores to destroyed objects avi@cloudius-systems.com
  2014-08-01  8:24 ` [Bug c++/61982] " rguenth at gcc dot gnu.org
@ 2014-08-01 15:12 ` jakub at gcc dot gnu.org
  2014-08-01 16:32 ` avi@cloudius-systems.com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-08-01 15:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The CLOBBER for non-decl expressions is added in the destructors, here we have
trivial destructor, so it is "inlined" already by the frontend and thus not
emitted.  Perhaps we could emit it in the places where we'd normally insert a
call to destructor if the object being destructed is not a decl (in that case I
believe adding the CLOBBER for it should be handled during gimplification).


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/61982] Optimizer does not eliminate stores to destroyed objects
  2014-07-31 18:54 [Bug c++/61982] New: Optimizer does not eliminate stores to destroyed objects avi@cloudius-systems.com
  2014-08-01  8:24 ` [Bug c++/61982] " rguenth at gcc dot gnu.org
  2014-08-01 15:12 ` jakub at gcc dot gnu.org
@ 2014-08-01 16:32 ` avi@cloudius-systems.com
  2014-08-01 16:52 ` glisse at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: avi@cloudius-systems.com @ 2014-08-01 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Avi Kivity <avi@cloudius-systems.com> ---
I observed this with non-trivial destructors as well.

In fact, something like:

X::~X() { i = 3; }

also emits a store.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/61982] Optimizer does not eliminate stores to destroyed objects
  2014-07-31 18:54 [Bug c++/61982] New: Optimizer does not eliminate stores to destroyed objects avi@cloudius-systems.com
                   ` (2 preceding siblings ...)
  2014-08-01 16:32 ` avi@cloudius-systems.com
@ 2014-08-01 16:52 ` glisse at gcc dot gnu.org
  2014-08-01 17:10 ` avi@cloudius-systems.com
  2014-08-01 18:10 ` daniel.kruegler at googlemail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: glisse at gcc dot gnu.org @ 2014-08-01 16:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Avi Kivity from comment #3)
> I observed this with non-trivial destructors as well.
> 
> In fact, something like:
> 
> X::~X() { i = 3; }
> 
> also emits a store.

Not for me, at least at -O2.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/61982] Optimizer does not eliminate stores to destroyed objects
  2014-07-31 18:54 [Bug c++/61982] New: Optimizer does not eliminate stores to destroyed objects avi@cloudius-systems.com
                   ` (3 preceding siblings ...)
  2014-08-01 16:52 ` glisse at gcc dot gnu.org
@ 2014-08-01 17:10 ` avi@cloudius-systems.com
  2014-08-01 18:10 ` daniel.kruegler at googlemail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: avi@cloudius-systems.com @ 2014-08-01 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Avi Kivity <avi@cloudius-systems.com> ---
Ah, I see that non-trivial destructors were fixed in gcc 4.9.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/61982] Optimizer does not eliminate stores to destroyed objects
  2014-07-31 18:54 [Bug c++/61982] New: Optimizer does not eliminate stores to destroyed objects avi@cloudius-systems.com
                   ` (4 preceding siblings ...)
  2014-08-01 17:10 ` avi@cloudius-systems.com
@ 2014-08-01 18:10 ` daniel.kruegler at googlemail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2014-08-01 18:10 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 5525 bytes --]

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

--- Comment #6 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Avi Kivity from comment #5)
> Ah, I see that non-trivial destructors were fixed in gcc 4.9.

I'm not sure whether I can agree with "fixed" here. A related (yet unresolved)
core-language issue is

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#640
>From gcc-bugs-return-457572-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Aug 01 18:15:12 2014
Return-Path: <gcc-bugs-return-457572-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 25679 invoked by alias); 1 Aug 2014 18:15:12 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 25635 invoked by uid 48); 1 Aug 2014 18:15:08 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/61982] Optimizer does not eliminate stores to destroyed objects
Date: Fri, 01 Aug 2014 18:15:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.1
X-Bugzilla-Keywords: missed-optimization
X-Bugzilla-Severity: minor
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-61982-4-pk926qeUdb@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-61982-4@http.gcc.gnu.org/bugzilla/>
References: <bug-61982-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-08/txt/msg00069.txt.bz2
Content-length: 492

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Daniel Krügler from comment #6)
> (In reply to Avi Kivity from comment #5)
> > Ah, I see that non-trivial destructors were fixed in gcc 4.9.
> 
> I'm not sure whether I can agree with "fixed" here. A related (yet
> unresolved) core-language issue is
> 
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#640

Ugh, what a terrible proposal.
>From gcc-bugs-return-457573-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Aug 01 18:23:56 2014
Return-Path: <gcc-bugs-return-457573-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 7108 invoked by alias); 1 Aug 2014 18:23:56 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 7063 invoked by uid 48); 1 Aug 2014 18:23:50 -0000
From: "galtgendo at o2 dot pl" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug web/61992] New: git web interface handles some paths badly
Date: Fri, 01 Aug 2014 18:23:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: web
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: minor
X-Bugzilla-Who: galtgendo at o2 dot pl
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-61992-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-08/txt/msg00070.txt.bz2
Content-length: 1083

https://gcc.gnu.org/bugzilla/show_bug.cgi?ida992

            Bug ID: 61992
           Summary: git web interface handles some paths badly
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: web
          Assignee: unassigned at gcc dot gnu.org
          Reporter: galtgendo at o2 dot pl

I don't know, if this is a misconfiguration on your part or a bug in the web
frontend, but if I browse from gcc.gnu.org/git to
https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=libstdc%2B%2B-v3;hº19769f319ff21297cf78bd31aeca0e0d2d25e0;hb=refs/heads/gcc-4_9-branch

then click on 'blob' for any file, the file is displayed as empty with
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/aclocal.m4;h`b7ccb59124ea9bdd7736b4c244e5a697edbd76;hb=refs/heads/gcc-4_9-branch
path.
If I change the path to
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc++-v3/aclocal.m4;h`b7ccb59124ea9bdd7736b4c244e5a697edbd76;hb=refs/heads/gcc-4_9-branch,
the file content gets displayed correctly.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-01 18:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-31 18:54 [Bug c++/61982] New: Optimizer does not eliminate stores to destroyed objects avi@cloudius-systems.com
2014-08-01  8:24 ` [Bug c++/61982] " rguenth at gcc dot gnu.org
2014-08-01 15:12 ` jakub at gcc dot gnu.org
2014-08-01 16:32 ` avi@cloudius-systems.com
2014-08-01 16:52 ` glisse at gcc dot gnu.org
2014-08-01 17:10 ` avi@cloudius-systems.com
2014-08-01 18:10 ` daniel.kruegler at googlemail dot com

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).