[LLVMdev] PROPOSAL: struct-access-path aware TBAA
Krzysztof Parzyszek
kparzysz at codeaurora.org
Tue Mar 12 19:21:13 PDT 2013
On 3/12/2013 12:13 PM, Manman Ren wrote:
>
> Given
> struct A {
> int x;
> int y;
> };
> struct B {
> A a;
> int z;
> };
> struct C {
> B b1;
> B b2;
> };
> struct D {
> C c;
> };
>
> with struct-access-path aware TBAA, C::b1.a.x does not alias with
D::c.b2.a.x.
> without it, the 2 scalar accesses can alias since both have int type.
I browsed the 2012 standard for a while and I didn't see anything that
would make this illegal:
char *p = malloc(enough_bytes);
intptr_t x = reinterpret_cast<intptr_t>(p);
x += offsetof(C, b2);
D &vd = *reinterpret_cast<D*>(p);
C &vc = *reinterpret_cast<C*>(x);
vd.c.b2.a.x = 1; // ..accessing the same
int t = vc.b1.a.x; // ..storage
I don't think that the path through the type structure is really sufficient.
-Krzysztof
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
More information about the llvm-dev
mailing list