This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix missed DSE opportunity with operator delete.
- From: Jason Merrill <jason at redhat dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Mikhail Maltsev <maltsevm at gmail dot com>, gcc-patches mailing list <gcc-patches at gcc dot gnu dot org>, Marc Glisse <marc dot glisse at inria dot fr>
- Date: Tue, 26 Apr 2016 08:58:19 -0400
- Subject: Re: [PATCH] Fix missed DSE opportunity with operator delete.
- Authentication-results: sourceware.org; auth=none
- References: <5712AF84 dot 5080002 at gmail dot com> <CAFiYyc2wz_a-92BbvMGa5mtUtWTgk2wafxWmmzum1r_t-_-vnw at mail dot gmail dot com> <5716998B dot 8010907 at gmail dot com> <CAFiYyc0NdjRjuvJKr5ZHhnAEc0zaDAktSCZES9M3FPRqmciSXg at mail dot gmail dot com> <571A999E dot 7060704 at gmail dot com> <CAFiYyc2XA=qRsTgvuFohuw-6kwVrp1W+sDqhbjqV-uei9EY=yQ at mail dot gmail dot com> <CADzB+2neZpNEfDZoCcBoGtDz0MairJ+KnniBbcPRpQPzYy0=fA at mail dot gmail dot com> <CAFiYyc3Gv0GTZn1MEkUWhvMu0r=nSt2y8k8qLovONVrz_ckYJQ at mail dot gmail dot com>
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