[llvm-commits] [cfe-commits] Compiler-rt changes for detecting initialization order problems in Address Sanitizer

Kostya Serebryany kcc at google.com
Mon Jul 2 22:13:49 PDT 2012


On Mon, Jul 2, 2012 at 9:17 PM, Joerg Sonnenberger
<joerg at britannica.bec.de>wrote:

> On Mon, Jul 02, 2012 at 11:55:31AM +0400, Kostya Serebryany wrote:
> > +  for (ListOfGlobals *l = list_of_globals; l; l = l->next) {
> > +    //Poison only globals not defined in this TU
> > +    if (!IsGlobalInList(globals, n, l->g)){
> >
> > This is N^2, isn't it?
> > Even once we get rid of N^2, this will still be not very efficient (due
> to
> > linked list traversal).
> > I can live with this for now, but this will need to be fixed before we
> > enable the phase.
>
>
First, let me remind that asan-rt is not a usual C++ code.
It can not use malloc/new, and thus STL containers are inaccessible.
It can allocate memory from raw mmap, but that's costly, so we try not to
allocate memory at all :)


> Would it possible to build a sorted array of all globals first?


Why?
Much simpler is to run through all globals of the current CU and mark them
(using a boolean flag member).
This will make the algorithm M+N instead of M*N
(M=num globals in the current CU, N=num globals in the whole program)

--kcc


> That
> would make the individual check logarithmic and allow more compact
> representation in general. A bloom filter might also be a nice
> pre-filter.
>
> Joerg
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120703/ab39a752/attachment.html>


More information about the llvm-commits mailing list