Strenghten assumption about dynamic type changes (placement new)

Jan Hubicka hubicka@ucw.cz
Wed Jul 23 16:35:00 GMT 2014


> On July 23, 2014 4:42:22 PM CEST, Jan Hubicka <hubicka@ucw.cz> wrote:
> >> On Tue, Jul 22, 2014 at 5:17 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> >> >> I don't see why
> >> >>
> >> >> long x[1024];
> >> >>
> >> >> Q *q = new (x) Q;
> >> >> q->~Q ();
> >> >> new (x) T;
> >> >>
> >> >> would be invalid.  I also don't see why
> >> >>
> >> >> Q q;
> >> >> q.~Q ();
> >> >> new (&q) T;
> >> >>
> >> >> would be.  Object lifetime is precisely specified and I don't see
> >where it is
> >> >> tied to (static) storage lifetime.
> >> >
> >> > This is precisely the testcase I posted on beggining of this
> >thread.
> >> >
> >> > I do not see how the testcases can work with aliasing rules in the
> >case Q's and T's
> >> > memory is known to not alias.
> >> 
> >> It works because of the well-defined memory model (with regarding to
> >> TBAA) in the middle-end.  Every store changes the dynamic type of
> >> a memory location which means that you can only use TBAA for
> >> true-dependence checks (not anti-dependence or write-dependence
> >> checks).
> >
> >I see, I did not notice this change - it seems like quite a big hammer
> >though,
> >limiting scheduling (and loop opts) quite noticeably for all languages.
> >Are
> >there any other motivations for this besides placement new?
> 
> Aggregate copies and memcpy transferring the dynamic type for example.  Being able to tbaa union accesses for another.  And yes, placement new.
> 
> It's not so much an optimization preventing thing as you still can move loads up and stores down with the help of tbaa.

well, but you lose extra parallelism like

 *shortptr = exp
 <longer dependency chain with shortptr>
 var = *shortptr
 *intptr = exp
 <longer dependency chain with intptr>
 var = *intptr

Honza



More information about the Gcc-patches mailing list