[cfe-dev] Help with APValue comparisons
Richard Smith
richard at metafoo.co.uk
Sun Jun 17 19:23:38 PDT 2012
Hi,
On Thu, Jun 14, 2012 at 5:06 AM, Andy Gibbs <andyg1001 at hotmail.co.uk> wrote:
> I'm in the middle of cooking a patch which dramatically speeds up
> compilation of constexpr functions. I have a partially working patch
> already which "fixes" the bug at http://llvm.org/bugs/show_bug.cgi?id=12850.
> I put "fixes" in quotes because at present the fix only works for the
> "simple" cases as present, by which I mean where arguments evaluate to
> APValues of type interger / float / complex / array / vector / struct.
>
> The question I have is this: the above cases have, lets say, fairly obvious
> ways for comparing whether two APValues are the same, however, I'm not sure
> about LValue -- does anyone know of a suitable / correct way of comparing
> two LValue-type APValues?
It depends what you're trying to compute.
Firstly, if either of them has a non-zero call index, and they weren't
both produced by the same evaluation, you must assume they are
different, because we no longer know what they referred to.
If you want to know whether they point to the same address, compare
the base and the offset.
Otherwise, you need to compare the base, offset and path. That should
always work (the one-past-the-end flag can be deduced in this case, so
that covers all the relevant semantic information). Alternatively, if
both values have paths (as they should for your case), you can compare
the base, path and one-past-the-end flag (the symbolic representation
of the glvalue) -- the offset can be deduced from that information.
Have you measured the memory and performance impact of this work on
well-written constexpr functions (those that don't rely on the
compiler perfoming memoization) and those that manipulate large
objects?
Richard
More information about the cfe-dev
mailing list