From a5370172b64bed5daf8e2869d7bf7cb52f80d6b7 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 28 Aug 2006 00:42:29 +0000 Subject: [PATCH] simplify AnalysisGroup registration, eliminating one typeid call. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29932 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/PassSupport.h | 18 +++++------------- lib/Analysis/AliasAnalysisCounter.cpp | 2 +- lib/Analysis/BasicAliasAnalysis.cpp | 4 ++-- lib/Analysis/DataStructure/DataStructureAA.cpp | 2 +- lib/Analysis/DataStructure/Steensgaard.cpp | 2 +- lib/Analysis/IPA/Andersens.cpp | 2 +- lib/Analysis/IPA/CallGraph.cpp | 2 +- lib/Analysis/IPA/GlobalsModRef.cpp | 2 +- lib/Analysis/LoadValueNumbering.cpp | 2 +- lib/Analysis/ProfileInfo.cpp | 2 +- lib/Analysis/ProfileInfoLoaderPass.cpp | 2 +- lib/Analysis/ValueNumbering.cpp | 2 +- lib/System/Mutex.cpp | 2 +- .../Instrumentation/BlockProfiling.cpp | 4 ++-- lib/Transforms/Instrumentation/RSProfiling.cpp | 2 +- 15 files changed, 21 insertions(+), 29 deletions(-) diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h index 5f8a1458c2b..4921848aba3 100644 --- a/include/llvm/PassSupport.h +++ b/include/llvm/PassSupport.h @@ -241,23 +241,15 @@ public: ~RegisterAGBase(); }; - -template +template struct RegisterAnalysisGroup : public RegisterAGBase { - RegisterAnalysisGroup() : RegisterAGBase(typeid(Interface), - &typeid(DefaultImplementationPass), - Default) { + RegisterAnalysisGroup(RegisterPassBase &RPB) + : RegisterAGBase(typeid(Interface), &RPB.getPassInfo()->getTypeInfo(), + Default) { } -}; -/// Define a specialization of RegisterAnalysisGroup that is used to set the -/// name for the analysis group. -/// -template -struct RegisterAnalysisGroup : public RegisterAGBase { RegisterAnalysisGroup(const char *Name) - : RegisterAGBase(typeid(Interface)) { + : RegisterAGBase(typeid(Interface)) { setGroupName(Name); } }; diff --git a/lib/Analysis/AliasAnalysisCounter.cpp b/lib/Analysis/AliasAnalysisCounter.cpp index 562b4f50b88..25ace732e2d 100644 --- a/lib/Analysis/AliasAnalysisCounter.cpp +++ b/lib/Analysis/AliasAnalysisCounter.cpp @@ -111,7 +111,7 @@ namespace { RegisterPass X("count-aa", "Count Alias Analysis Query Responses"); - RegisterAnalysisGroup Y; + RegisterAnalysisGroup Y(X); } ModulePass *llvm::createAliasAnalysisCounterPass() { diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 2c5fc81b150..167d3b0c02c 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -76,7 +76,7 @@ namespace { U("no-aa", "No Alias Analysis (always returns 'may' alias)"); // Declare that we implement the AliasAnalysis interface - RegisterAnalysisGroup V; + RegisterAnalysisGroup V(U); } // End of anonymous namespace ImmutablePass *llvm::createNoAAPass() { return new NoAA(); } @@ -121,7 +121,7 @@ namespace { X("basicaa", "Basic Alias Analysis (default AA impl)"); // Declare that we implement the AliasAnalysis interface - RegisterAnalysisGroup Y; + RegisterAnalysisGroup Y(X); } // End of anonymous namespace ImmutablePass *llvm::createBasicAliasAnalysisPass() { diff --git a/lib/Analysis/DataStructure/DataStructureAA.cpp b/lib/Analysis/DataStructure/DataStructureAA.cpp index bbb2ba21f34..6e9f07bdd20 100644 --- a/lib/Analysis/DataStructure/DataStructureAA.cpp +++ b/lib/Analysis/DataStructure/DataStructureAA.cpp @@ -99,7 +99,7 @@ namespace { RegisterPass X("ds-aa", "Data Structure Graph Based Alias Analysis"); // Register as an implementation of AliasAnalysis - RegisterAnalysisGroup Y; + RegisterAnalysisGroup Y(X); } ModulePass *llvm::createDSAAPass() { return new DSAA(); } diff --git a/lib/Analysis/DataStructure/Steensgaard.cpp b/lib/Analysis/DataStructure/Steensgaard.cpp index 8a98022869d..c7e32202cf7 100644 --- a/lib/Analysis/DataStructure/Steensgaard.cpp +++ b/lib/Analysis/DataStructure/Steensgaard.cpp @@ -77,7 +77,7 @@ namespace { "Steensgaard's alias analysis (DSGraph based)"); // Register as an implementation of AliasAnalysis - RegisterAnalysisGroup Y; + RegisterAnalysisGroup Y(X); } ModulePass *llvm::createSteensgaardPass() { return new Steens(); } diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index bc80f5b9568..c9f5871b725 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -338,7 +338,7 @@ namespace { RegisterPass X("anders-aa", "Andersen's Interprocedural Alias Analysis"); - RegisterAnalysisGroup Y; + RegisterAnalysisGroup Y(X); } ModulePass *llvm::createAndersensPass() { return new Andersens(); } diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index 8836807bfc6..dab6867d323 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -183,7 +183,7 @@ private: RegisterAnalysisGroup X("Call Graph"); RegisterPass Y("basiccg", "Basic CallGraph Construction"); -RegisterAnalysisGroup Z; +RegisterAnalysisGroup Z(Y); } //End anonymous namespace diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index 6739dfbf0ee..2db4ed89c99 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -137,7 +137,7 @@ namespace { RegisterPass X("globalsmodref-aa", "Simple mod/ref analysis for globals"); - RegisterAnalysisGroup Y; + RegisterAnalysisGroup Y(X); } Pass *llvm::createGlobalsModRefPass() { return new GlobalsModRef(); } diff --git a/lib/Analysis/LoadValueNumbering.cpp b/lib/Analysis/LoadValueNumbering.cpp index bac80c8d986..3fbf23806ce 100644 --- a/lib/Analysis/LoadValueNumbering.cpp +++ b/lib/Analysis/LoadValueNumbering.cpp @@ -84,7 +84,7 @@ namespace { RegisterPass X("load-vn", "Load Value Numbering"); // Declare that we implement the ValueNumbering interface - RegisterAnalysisGroup Y; + RegisterAnalysisGroup Y(X); } FunctionPass *llvm::createLoadValueNumberingPass() { return new LoadVN(); } diff --git a/lib/Analysis/ProfileInfo.cpp b/lib/Analysis/ProfileInfo.cpp index b8ab88b8f2e..c35d00ca059 100644 --- a/lib/Analysis/ProfileInfo.cpp +++ b/lib/Analysis/ProfileInfo.cpp @@ -89,7 +89,7 @@ namespace { X("no-profile", "No Profile Information"); // Declare that we implement the ProfileInfo interface - RegisterAnalysisGroup Y; + RegisterAnalysisGroup Y(X); } // End of anonymous namespace ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); } diff --git a/lib/Analysis/ProfileInfoLoaderPass.cpp b/lib/Analysis/ProfileInfoLoaderPass.cpp index 57e3627c53c..b5cb95433fc 100644 --- a/lib/Analysis/ProfileInfoLoaderPass.cpp +++ b/lib/Analysis/ProfileInfoLoaderPass.cpp @@ -52,7 +52,7 @@ namespace { RegisterPass X("profile-loader", "Load profile information from llvmprof.out"); - RegisterAnalysisGroup Y; + RegisterAnalysisGroup Y(X); } // End of anonymous namespace ModulePass *llvm::createProfileLoaderPass() { return new LoaderPass(); } diff --git a/lib/Analysis/ValueNumbering.cpp b/lib/Analysis/ValueNumbering.cpp index fb3bed05531..0224a0132fd 100644 --- a/lib/Analysis/ValueNumbering.cpp +++ b/lib/Analysis/ValueNumbering.cpp @@ -64,7 +64,7 @@ namespace { X("basicvn", "Basic Value Numbering (default GVN impl)"); // Declare that we implement the ValueNumbering interface - RegisterAnalysisGroup Y; + RegisterAnalysisGroup Y(X); /// BVNImpl - Implement BasicVN in terms of a visitor class that /// handles the different types of instructions as appropriate. diff --git a/lib/System/Mutex.cpp b/lib/System/Mutex.cpp index 44e3332d179..467bc8522bb 100644 --- a/lib/System/Mutex.cpp +++ b/lib/System/Mutex.cpp @@ -53,7 +53,7 @@ using namespace sys; // is configured into the LIBS variable. // Note: this line of code generates a warning if pthread_mutex_init is not // declared with weak linkage. It's safe to ignore the warning. -static const bool pthread_enabled = static_cast(pthread_mutex_init); +static const bool pthread_enabled = true; // Construct a Mutex using pthread calls Mutex::Mutex( bool recursive) diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp index 859f596fa62..7e1f5cc76ca 100644 --- a/lib/Transforms/Instrumentation/BlockProfiling.cpp +++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp @@ -37,7 +37,7 @@ namespace { RegisterPass X("insert-function-profiling", "Insert instrumentation for function profiling"); - RegisterAnalysisGroup XG; + RegisterAnalysisGroup XG(X); } @@ -83,7 +83,7 @@ namespace { RegisterPass Y("insert-block-profiling", "Insert instrumentation for block profiling"); - RegisterAnalysisGroup YG; + RegisterAnalysisGroup YG(Y); } ModulePass *llvm::createBlockProfilerPass() { return new BlockProfiler(); } diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp index 984190a611b..54a9ef7003b 100644 --- a/lib/Transforms/Instrumentation/RSProfiling.cpp +++ b/lib/Transforms/Instrumentation/RSProfiling.cpp @@ -89,7 +89,7 @@ namespace { static RegisterAnalysisGroup A("Profiling passes"); static RegisterPass NP("insert-null-profiling-rs", "Measure profiling framework overhead"); - static RegisterAnalysisGroup NPT; + static RegisterAnalysisGroup NPT(NP); /// Chooser - Something that chooses when to make a sample of the profiled code class Chooser {