This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix missed DSE opportunity with operator delete.


On Tue, Apr 26, 2016 at 5:07 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Mon, Apr 25, 2016 at 9:57 PM, Jason Merrill <jason@redhat.com> wrote:
>> Hmm, this seems to assume that operator delete itself doesn't do
>> anything with the object being deleted.  This is true of the default
>> implementation, but I don't see anything in the standard that
>> prohibits a user-supplied replacement or class-specific deallocation
>> function from accessing the memory.
>
> Hmm, but the delete expression invokes the (default) destructor which
> ends the lifetime of the object and thus invalidates all memory.  Don't
> we place a CLOBBER there as well nowadays (seems not).

We put a CLOBBER inside the destructor.  Now that you mention it, I
suppose we would get more DSE if we put it in the calling context
instead.

But for types with trivial destructors, including scalar types, the
lifetime of the object doesn't end until the storage is released,
somewhere within the call to operator delete.  The clang folks have
been arguing recently that this asymmetry is harmful, so we might move
toward a model where trivial destruction also ends the lifetime of an
object, but that's currently unclear.

operator delete is like free in that it renders the pointer invalid.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]