TBAA: Propagating aliasing information to derived pointers

Hi,

While adding support for TBAA to GHC's LLVM backend, we ran into the
following issue: given a pointer that we know has certain aliasing
properties (e.g. it points to the stack, not the heap) we'd like to

* annotate all loads and stores to that pointer with a TBAA type "stack", and
* also annotate all loads and stores to pointers derived from that
pointer as "stack".

For example, given Sp, which is the GHC stack pointer, and this pseudo-code

    tmp = Sp + 4
    tmp2 = load tmp // should be marked as "stack"

we'd like to not only annotate loads/stores to Sp as "stack" but also
all loads/stores to tmp.

Is this something that can be achieved within the current framework or
should we propagate the pointer aliasing information ourselves?

Cheers,
Johan

In the current TBAA implementation, the marking only applies to the
given load; it doesn't give any special properties to the loaded
pointer.

-Eli

Is there a particular reason the current implementation doesn't do it
(i.e. is it unsafe in general?) or is it just that no one has gotten
around to implementing it?

Cheers,
Johan

It's unsafe in general. For example, this is valid:

void *v = whatever;
int *p = v;
float *q = v;

int **x = &p;
float **y = &q;

Here, *x and *y refer to distinct memory, but **x and **y refer
to the same memory.

Dan