[cfe-commits] r165515 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp

Chandler Carruth chandlerc at google.com
Tue Oct 9 11:49:45 PDT 2012


On Tue, Oct 9, 2012 at 10:50 AM, Douglas Gregor <dgregor at apple.com> wrote:

> Author: dgregor
> Date: Tue Oct  9 12:50:23 2012
> New Revision: 165515
>
> URL: http://llvm.org/viewvc/llvm-project?rev=165515&view=rev
> Log:
> Make the order of visitation of the pending bodies in the AST reader
> deterministic.
>
> Modified:
>     cfe/trunk/include/clang/Serialization/ASTReader.h
>     cfe/trunk/lib/Serialization/ASTReader.cpp
>
> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=165515&r1=165514&r2=165515&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Oct  9 12:50:23
> 2012
> @@ -33,6 +33,7 @@
>  #include "llvm/ADT/APFloat.h"
>  #include "llvm/ADT/APInt.h"
>  #include "llvm/ADT/APSInt.h"
> +#include "llvm/ADT/MapVector.h"
>  #include "llvm/ADT/OwningPtr.h"
>  #include "llvm/ADT/SmallPtrSet.h"
>  #include "llvm/ADT/SmallSet.h"
> @@ -342,8 +343,13 @@
>    /// declarations that have not yet been linked to their definitions.
>    llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
>
> +  typedef llvm::MapVector<Decl *, uint64_t,
> +                          llvm::SmallDenseMap<Decl *, unsigned, 4>,
>

I would expect the generated code to be slightly better with a map of <Decl
*, uintptr_t> (or size_t, or some other pointer-sized entity). While in an
ideal world, LLVM could figure this out, I wouldn't be surprised if having
a 12-byte element with 16-byte alignment prevents initialization of the
buckets from being a simple memset....

I wonder if we shouldn't make a SmallMapVector wrapper just to automate
building this with optimal type pairs?


> +                          llvm::SmallVector<std::pair<Decl *, uint64_t>,
> 4> >
> +    PendingBodiesMap;
> +
>    /// \brief Functions or methods that have bodies that will be attached.
> -  llvm::SmallDenseMap<Decl *, uint64_t, 4> PendingBodies;
> +  PendingBodiesMap PendingBodies;
>
>    /// \brief Read the records that describe the contents of declcontexts.
>    bool ReadDeclContextStorage(ModuleFile &M,
>
> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=165515&r1=165514&r2=165515&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Oct  9 12:50:23 2012
> @@ -6484,8 +6484,8 @@
>    // Load the bodies of any functions or methods we've encountered. We do
>    // this now (delayed) so that we can be sure that the declaration chains
>    // have been fully wired up.
> -  for (llvm::SmallDenseMap<Decl *, uint64_t, 4>::iterator
> -         PB = PendingBodies.begin(), PBEnd = PendingBodies.end();
> +  for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
> +                               PBEnd = PendingBodies.end();
>         PB != PBEnd; ++PB) {
>      if (FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
>        // FIXME: Check for =delete/=default?
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121009/476c441c/attachment.html>


More information about the cfe-commits mailing list