[llvm-commits] [llvm] r108885 - /llvm/trunk/include/llvm/PassRegistry.h

Chris Lattner clattner at apple.com
Sun Sep 5 15:39:02 PDT 2010


On Jul 20, 2010, at 11:53 AM, Owen Anderson wrote:
> Added:
>    llvm/trunk/include/llvm/PassRegistry.h

Thanks for working on this Owen, some comments:

> +//
> +// This file defines PassRegistry, a class that is used in the initialization
> +// and registration of passes.  At initialization, passes are registered with

"initialization" of what?  Please mention app startup time or some other time.

> +// the PassRegistry, which is later provided to the PassManager for dependency
> +// resolution and similar tasks.

> +#include "llvm/PassSupport.h"
> +#include "llvm/ADT/StringMap.h"
> +#include "llvm/System/DataTypes.h"
> +#include "llvm/System/Mutex.h"
> +#include <map>
> +#include <set>
> +
> +using namespace llvm;
> +
> +namespace llvm {
> +
> +class PassRegistry {
> +  /// Guards the contents of this class.
> +  mutable sys::SmartMutex<true> Lock;

Why?  I don't see why this needs to be locked at all.

> +  
> +  /// PassInfoMap - Keep track of the PassInfo object for each registered pass.
> +  typedef std::map<intptr_t, const PassInfo*> MapType;
> +  MapType PassInfoMap;

Please use a DenseMap for this.

> +  typedef StringMap<const PassInfo*> StringMapType;
> +  StringMapType PassInfoStringMap;
> +  
> +  /// AnalysisGroupInfo - Keep track of information for each analysis group.
> +  struct AnalysisGroupInfo {
> +    std::set<const PassInfo *> Implementations;
> +  };

Please use a SmallPtrSet

> +  std::map<const PassInfo*, AnalysisGroupInfo> AnalysisGroupInfoMap;

Please use the pimpl idiom to avoid having the this (and AnalysisGroupInfo) exposed in the header, eliminating some #includes.

> +
> +public:
> +  static PassRegistry *getPassRegistry();
> +  
> +  const PassInfo *getPassInfo(intptr_t TI) const;
> +  const PassInfo *getPassInfo(StringRef Arg) const;
> +  
> +  void registerPass(const PassInfo &PI);
> +  void unregisterPass(const PassInfo &PI);
> +  
> +  /// Analysis Group Mechanisms.
> +  void registerAnalysisGroup(PassInfo *InterfaceInfo,
> +                             const PassInfo *ImplementationInfo,
> +                             bool isDefault);
> +  
> +  void enumerateWith(PassRegistrationListener *L);
> +};

Doxygen comments please!  This is a public interface and it's extremely unclear what all this stuff does, please document it.

-Chris



> +
> +}
> +
> +#endif
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list