[cfe-dev] [RFC] cHash: Integration of AST hashing

Richard Trieu via cfe-dev cfe-dev at lists.llvm.org
Tue Dec 12 15:13:54 PST 2017


On Tue, Dec 12, 2017 at 1:10 AM, Christian Dietrich <
dietrich at sra.uni-hannover.de> wrote:

> Christian Dietrich <dietrich at sra.uni-hannover.de> writes:
>
> > Sure, this would definitly be a better option. A quick look into the
> > RecursiveASTVisitor tells me that there are at least 76 for (...) loops.
> > So we have to add them.
>
> Unluckily, there is no general approach to get the number of elements in
> an iterator_range, but calling std::distance, however:
>
>   addData(std::distance(S->attrs().begin(), S->attrs.end()));
>
> is kind of ugly, so we better leave that to the implmentor of addData()
> by using a template matching iterator_range<> and simply give the child
> range to the Collector user:
>
>   addData(S->attrs());
>
> Decl::getAttrs() will return a reference to a SmallVector which can be
queried for the size.  Decl::hasAttrs() needs to be checked before calling.


> In this case, the user of the collector can do more fancy things on this.
>
> > Perhaps we can combine both, length-indicators and and
> > non-small-integers, by using llvm::hash on the <Decl::getKind()> values.
> > As the documentation says, we have to spent less than 20 cycles per
> > 32-bit value on this. By this, we avoid the magic numbers. I will start
> > on doing the changes to incorporate the length fields.
>
> Wait a moment. When thinking of it, the number of children is not a
> node-local property, so it should be placed in a different category.
> Perhaps, we could do something similar to D40781[1]:
>
> class Collector {
>   code Local = [{}];
>   code CrossRef = [{}];
>
>   code CHash = !codeconcat(Local, CrossRef);
> }
>
> class Decl : Collector {
>    code Local = [{
>       addData(S->getKind());
>    }];
>
>    code CrossRef = [{
>       addData(S->attrs());
>    }];
> }
>
> However, D40782[2] has to land first in LLVM for this, since TableGen
> has no !codeconcat command at the moment. So for the moment, I will put
> it into Code = [{}];
>
> chris
>
> [1] https://reviews.llvm.org/D40781
> [2] https://reviews.llvm.org/D40782
> --
> Christian Dietrich, M.Sc. (Scientific Staff)
> Institute for Systems Engineering (Systems and Computerarchitecture)
> Leibniz Universität Hannover
> Appelstraße 4
> 30167 Hannover, Germany
>
> Tel:    +49 511 762-19737
> Fax:    +49 511 762-19733
> eMail:  dietrich at sra.uni-hannover.de
> WWW:    https://www.sra.uni-hannover.de
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171212/3f45f17e/attachment.html>


More information about the cfe-dev mailing list