Switch scopes from keeping decls in SmallSet to keeping them in the new

SmallPtrSet data structure.  This datastructure handles the 'nonsmall' case
quite gracefully, with an efficient exponentially probed hashtable.  This is
important for handling global scope, which gets many thousands of decls (e.g.
every function and enum value).  Of course the typical inner scopes are still
as efficient as ever.

On my mac pro, this speeds up parsing carbon.h from 0.59s to 0.168s (3.5x),
and there is still low hanging fruit :).

For reference, GCC on the same system takes 0.33s for -fsyntax-only.

llvm-svn: 39317
This commit is contained in:
Chris Lattner 2007-01-27 07:16:01 +00:00
parent 38047f9e23
commit 80c114ae7e
1 changed files with 5 additions and 2 deletions

View File

@ -15,6 +15,7 @@
#define LLVM_CLANG_PARSE_SCOPE_H
#include "clang/Parse/Action.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
namespace llvm {
@ -77,7 +78,9 @@ private:
/// popped, these declarations are removed from the IdentifierTable's notion
/// of current declaration. It is up to the current Action implementation to
/// implement these semantics.
SmallSet<Action::DeclTy*, 32> DeclsInScope;
typedef SmallPtrSet<Action::DeclTy*, 32> DeclSetTy;
//typedef SmallSet<Action::DeclTy*, 32> DeclSetTy;
DeclSetTy DeclsInScope;
public:
Scope(Scope *Parent, unsigned ScopeFlags) {
Init(Parent, ScopeFlags);
@ -100,7 +103,7 @@ public:
}
typedef SmallSet<Action::DeclTy*, 32>::iterator decl_iterator;
typedef DeclSetTy::iterator decl_iterator;
decl_iterator decl_begin() const { return DeclsInScope.begin(); }
decl_iterator decl_end() const { return DeclsInScope.end(); }