On Tue, Nov 21, 2023 at 8:59 AM Alexander Monakov <amona...@ispras.ru> wrote:
>
>
> On Tue, 21 Nov 2023, Alexander Monakov wrote:
>
> > I am concerned that if GCC ever learns to leave out the following access
> > to 'this->foo', leaving tmp uninitialized, we will end up with:
> >
> >       this->foo = 42;
>
> Sorry, this store will be DSE'd out, of course, but my question stands.

I think that would be a reasonable transform, yes.

> Alexander
>
> >       *this = { CLOBBER };
> >       __valgrind_make_mem_undefined(this, sizeof *this);
> >       int tmp(D);
> >       return tmp(D); // uninitialized

and this, too, btw. - the DSE actually happens, the latter transform not.
We specifically "opt out" of doing that for QOI to not make undefined
behavior worse.  The more correct transform would be to replace the
load with a __builtin_trap () during path isolation (or wire in path isolation
to value-numbering where we actually figure out there's no valid definition
to reach for the load).

So yes, if you want to avoid these kind of transforms earlier instrumentation
is better.

Richard.

> >
> > and Valgrind will not report anything since the invalid load is optimized 
> > out.
> >
> > With early instrumentation such optimization is not going to happen, since 
> > the
> > builtin may modify *this.
> >
> > Is my concern reasonable?
> >
> > Thanks.
> > Alexander

Reply via email to