Hi,
On Wed, 27 Jul 2011, Richard Guenther wrote:
> > > I don't think it is safe to try to get at the VLA type the way you do.
> >
> > I don't understand in what way it's not safe. Do you mean I don't manage to
> > find
> > the type always, or that I find the wrong type, or something else?
>
> I think you might get the wrong type, you also do not transform code
> like
>
> int *p = alloca(4);
> *p = 3;
>
> as there is no array type involved here.
That's good, because you _can't_ transform that code into an array decl.
See:
for (int i = 0; i < 100; i++)
p[i] = alloca(4);
assert (p[0] != p[1]);
vs.
char vla_cst[4];
for (int i = 0; i < 100; i++)
p[i] = &vla_cst;
assert (p[0] != p[1]);
Tom: you can reliably detect if an alloca call is for a VLA by checking
CALL_ALLOCA_FOR_VAR_P (on a tree call expression, but only if it's a
builtin call) or gimple_call_alloca_for_var_p (on a gimple call stmt).
Ciao,
Michael.