diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp index 04ad7de7bd3..be42f749b4d 100644 --- a/lib/Analysis/AliasAnalysis.cpp +++ b/lib/Analysis/AliasAnalysis.cpp @@ -34,9 +34,7 @@ using namespace llvm; // Register the AliasAnalysis interface, providing a nice name to refer to. -namespace { - RegisterAnalysisGroup Z("Alias Analysis"); -} +static RegisterAnalysisGroup Z("Alias Analysis"); char AliasAnalysis::ID = 0; //===----------------------------------------------------------------------===// diff --git a/lib/Analysis/AliasAnalysisCounter.cpp b/lib/Analysis/AliasAnalysisCounter.cpp index 9c42902a04c..48f00ad2225 100644 --- a/lib/Analysis/AliasAnalysisCounter.cpp +++ b/lib/Analysis/AliasAnalysisCounter.cpp @@ -21,12 +21,12 @@ #include "llvm/Support/Streams.h" using namespace llvm; -namespace { - static cl::opt - PrintAll("count-aa-print-all-queries", cl::ReallyHidden); - static cl::opt - PrintAllFailures("count-aa-print-all-failed-queries", cl::ReallyHidden); +static cl::opt +PrintAll("count-aa-print-all-queries", cl::ReallyHidden); +static cl::opt +PrintAllFailures("count-aa-print-all-failed-queries", cl::ReallyHidden); +namespace { class VISIBILITY_HIDDEN AliasAnalysisCounter : public ModulePass, public AliasAnalysis { unsigned No, May, Must; @@ -113,13 +113,13 @@ namespace { return AliasAnalysis::getModRefInfo(CS1,CS2); } }; - - char AliasAnalysisCounter::ID = 0; - RegisterPass - X("count-aa", "Count Alias Analysis Query Responses", false, true); - RegisterAnalysisGroup Y(X); } +char AliasAnalysisCounter::ID = 0; +static RegisterPass +X("count-aa", "Count Alias Analysis Query Responses", false, true); +static RegisterAnalysisGroup Y(X); + ModulePass *llvm::createAliasAnalysisCounterPass() { return new AliasAnalysisCounter(); } diff --git a/lib/Analysis/AliasAnalysisEvaluator.cpp b/lib/Analysis/AliasAnalysisEvaluator.cpp index 704ab8273cc..af15d0f4adf 100644 --- a/lib/Analysis/AliasAnalysisEvaluator.cpp +++ b/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -34,19 +34,18 @@ #include using namespace llvm; +static cl::opt PrintAll("print-all-alias-modref-info", cl::ReallyHidden); + +static cl::opt PrintNoAlias("print-no-aliases", cl::ReallyHidden); +static cl::opt PrintMayAlias("print-may-aliases", cl::ReallyHidden); +static cl::opt PrintMustAlias("print-must-aliases", cl::ReallyHidden); + +static cl::opt PrintNoModRef("print-no-modref", cl::ReallyHidden); +static cl::opt PrintMod("print-mod", cl::ReallyHidden); +static cl::opt PrintRef("print-ref", cl::ReallyHidden); +static cl::opt PrintModRef("print-modref", cl::ReallyHidden); + namespace { - static cl::opt - PrintAll("print-all-alias-modref-info", cl::ReallyHidden); - - static cl::opt PrintNoAlias("print-no-aliases", cl::ReallyHidden); - static cl::opt PrintMayAlias("print-may-aliases", cl::ReallyHidden); - static cl::opt PrintMustAlias("print-must-aliases", cl::ReallyHidden); - - static cl::opt PrintNoModRef("print-no-modref", cl::ReallyHidden); - static cl::opt PrintMod("print-mod", cl::ReallyHidden); - static cl::opt PrintRef("print-ref", cl::ReallyHidden); - static cl::opt PrintModRef("print-modref", cl::ReallyHidden); - class VISIBILITY_HIDDEN AAEval : public FunctionPass { unsigned NoAlias, MayAlias, MustAlias; unsigned NoModRef, Mod, Ref, ModRef; @@ -74,12 +73,12 @@ namespace { bool runOnFunction(Function &F); bool doFinalization(Module &M); }; - - char AAEval::ID = 0; - static RegisterPass - X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true); } +char AAEval::ID = 0; +static RegisterPass +X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true); + FunctionPass *llvm::createAAEvalPass() { return new AAEval(); } static void PrintResults(const char *Msg, bool P, const Value *V1, const Value *V2, diff --git a/lib/Analysis/AliasDebugger.cpp b/lib/Analysis/AliasDebugger.cpp index 491c4b091ea..06a43b11dd5 100644 --- a/lib/Analysis/AliasDebugger.cpp +++ b/lib/Analysis/AliasDebugger.cpp @@ -121,11 +121,12 @@ namespace { } }; - - char AliasDebugger::ID = 0; - RegisterPass X("debug-aa", "AA use debugger", false, true); - RegisterAnalysisGroup Y(X); } +char AliasDebugger::ID = 0; +static RegisterPass +X("debug-aa", "AA use debugger", false, true); +static RegisterAnalysisGroup Y(X); + Pass *llvm::createAliasDebugger() { return new AliasDebugger(); } diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp index 01e700b7681..68603e53b64 100644 --- a/lib/Analysis/AliasSetTracker.cpp +++ b/lib/Analysis/AliasSetTracker.cpp @@ -585,6 +585,8 @@ namespace { return false; } }; - char AliasSetPrinter::ID = 0; - RegisterPass X("print-alias-sets", "Alias Set Printer", false, true); } + +char AliasSetPrinter::ID = 0; +static RegisterPass +X("print-alias-sets", "Alias Set Printer", false, true); diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 97dd56aa031..21108c64535 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -79,16 +79,16 @@ namespace { virtual void deleteValue(Value *V) {} virtual void copyValue(Value *From, Value *To) {} }; - - // Register this pass... - char NoAA::ID = 0; - RegisterPass - U("no-aa", "No Alias Analysis (always returns 'may' alias)", true, true); - - // Declare that we implement the AliasAnalysis interface - RegisterAnalysisGroup V(U); } // End of anonymous namespace +// Register this pass... +char NoAA::ID = 0; +static RegisterPass +U("no-aa", "No Alias Analysis (always returns 'may' alias)", true, true); + +// Declare that we implement the AliasAnalysis interface +static RegisterAnalysisGroup V(U); + ImmutablePass *llvm::createNoAAPass() { return new NoAA(); } namespace { @@ -124,16 +124,16 @@ namespace { const Type *BasePtr2Ty, Value **GEP2Ops, unsigned NumGEP2Ops, unsigned G2Size); }; - - // Register this pass... - char BasicAliasAnalysis::ID = 0; - RegisterPass - X("basicaa", "Basic Alias Analysis (default AA impl)", false, true); - - // Declare that we implement the AliasAnalysis interface - RegisterAnalysisGroup Y(X); } // End of anonymous namespace +// Register this pass... +char BasicAliasAnalysis::ID = 0; +static RegisterPass +X("basicaa", "Basic Alias Analysis (default AA impl)", false, true); + +// Declare that we implement the AliasAnalysis interface +static RegisterAnalysisGroup Y(X); + ImmutablePass *llvm::createBasicAliasAnalysisPass() { return new BasicAliasAnalysis(); } diff --git a/lib/Analysis/CFGPrinter.cpp b/lib/Analysis/CFGPrinter.cpp index f293555a693..e20a0a2f876 100644 --- a/lib/Analysis/CFGPrinter.cpp +++ b/lib/Analysis/CFGPrinter.cpp @@ -105,11 +105,13 @@ namespace { AU.setPreservesAll(); } }; +} - char CFGViewer::ID = 0; - RegisterPass V0("view-cfg", - "View CFG of function", false, true); +char CFGViewer::ID = 0; +static RegisterPass +V0("view-cfg", "View CFG of function", false, true); +namespace { struct VISIBILITY_HIDDEN CFGOnlyViewer : public FunctionPass { static char ID; // Pass identifcation, replacement for typeid CFGOnlyViewer() : FunctionPass((intptr_t)&ID) {} @@ -127,11 +129,14 @@ namespace { AU.setPreservesAll(); } }; +} - char CFGOnlyViewer::ID = 0; - RegisterPass V1("view-cfg-only", - "View CFG of function (with no function bodies)", false, true); +char CFGOnlyViewer::ID = 0; +static RegisterPass +V1("view-cfg-only", + "View CFG of function (with no function bodies)", false, true); +namespace { struct VISIBILITY_HIDDEN CFGPrinter : public FunctionPass { static char ID; // Pass identification, replacement for typeid CFGPrinter() : FunctionPass((intptr_t)&ID) {} @@ -156,11 +161,13 @@ namespace { AU.setPreservesAll(); } }; +} - char CFGPrinter::ID = 0; - RegisterPass P1("print-cfg", - "Print CFG of function to 'dot' file", false, true); +char CFGPrinter::ID = 0; +static RegisterPass +P1("print-cfg", "Print CFG of function to 'dot' file", false, true); +namespace { struct VISIBILITY_HIDDEN CFGOnlyPrinter : public CFGPrinter { static char ID; // Pass identification, replacement for typeid CFGOnlyPrinter() : CFGPrinter((intptr_t)&ID) {} @@ -177,13 +184,13 @@ namespace { AU.setPreservesAll(); } }; - - char CFGOnlyPrinter::ID = 0; - RegisterPass - P2("print-cfg-only", - "Print CFG of function to 'dot' file (with no function bodies)", false, true); } +char CFGOnlyPrinter::ID = 0; +static RegisterPass +P2("print-cfg-only", + "Print CFG of function to 'dot' file (with no function bodies)", false, true); + /// viewCFG - This function is meant for use from the debugger. You can just /// say 'call F->viewCFG()' and a ghostview window should pop up from the /// program, displaying the CFG of the current function. This depends on there diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index ab80bab95c7..823a32f85fe 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -89,14 +89,14 @@ STATISTIC(NumNodes , "Number of nodes"); STATISTIC(NumUnified , "Number of variables unified"); STATISTIC(NumErased , "Number of redundant constraints erased"); -namespace { - const unsigned SelfRep = (unsigned)-1; - const unsigned Unvisited = (unsigned)-1; - // Position of the function return node relative to the function node. - const unsigned CallReturnPos = 1; - // Position of the function call node relative to the function node. - const unsigned CallFirstArgPos = 2; +static const unsigned SelfRep = (unsigned)-1; +static const unsigned Unvisited = (unsigned)-1; +// Position of the function return node relative to the function node. +static const unsigned CallReturnPos = 1; +// Position of the function call node relative to the function node. +static const unsigned CallFirstArgPos = 2; +namespace { struct BitmapKeyInfo { static inline SparseBitVector<> *getEmptyKey() { return reinterpret_cast *>(-1); @@ -608,17 +608,16 @@ namespace { PrintPointsToGraph(); } }; - - char Andersens::ID = 0; - RegisterPass X("anders-aa", - "Andersen's Interprocedural Alias Analysis", false, - true); - RegisterAnalysisGroup Y(X); - - // Initialize Timestamp Counter (static). - unsigned Andersens::Node::Counter = 0; } +char Andersens::ID = 0; +static RegisterPass +X("anders-aa", "Andersen's Interprocedural Alias Analysis", false, true); +static RegisterAnalysisGroup Y(X); + +// Initialize Timestamp Counter (static). +unsigned Andersens::Node::Counter = 0; + ModulePass *llvm::createAndersensPass() { return new Andersens(); } //===----------------------------------------------------------------------===// diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index f0dd1880ff4..eaa0d0181af 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -190,12 +190,13 @@ private: } }; -RegisterAnalysisGroup X("Call Graph"); -RegisterPass Y("basiccg", "Basic CallGraph Construction", false, true); -RegisterAnalysisGroup Z(Y); - } //End anonymous namespace +static RegisterAnalysisGroup X("Call Graph"); +static RegisterPass +Y("basiccg", "Basic CallGraph Construction", false, true); +static RegisterAnalysisGroup Z(Y); + char CallGraph::ID = 0; char BasicCallGraph::ID = 0; diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp index 99954d632d4..112f9c2e5df 100644 --- a/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -27,6 +27,8 @@ using namespace llvm; // /// CGPassManager manages FPPassManagers and CalLGraphSCCPasses. +namespace { + class CGPassManager : public ModulePass, public PMDataManager { public: @@ -73,6 +75,8 @@ public: } }; +} + char CGPassManager::ID = 0; /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index 6ce320964e9..6d6282029ae 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -146,14 +146,13 @@ namespace { GlobalValue *OkayStoreDest = 0); bool AnalyzeIndirectGlobalMemory(GlobalValue *GV); }; - - char GlobalsModRef::ID = 0; - RegisterPass X("globalsmodref-aa", - "Simple mod/ref analysis for globals", false, - true); - RegisterAnalysisGroup Y(X); } +char GlobalsModRef::ID = 0; +static RegisterPass +X("globalsmodref-aa", "Simple mod/ref analysis for globals", false, true); +static RegisterAnalysisGroup Y(X); + Pass *llvm::createGlobalsModRefPass() { return new GlobalsModRef(); } /// getUnderlyingObject - This traverses the use chain to figure out what object diff --git a/lib/Analysis/InstCount.cpp b/lib/Analysis/InstCount.cpp index c4f36d3874c..5f33a60e6fd 100644 --- a/lib/Analysis/InstCount.cpp +++ b/lib/Analysis/InstCount.cpp @@ -62,12 +62,12 @@ namespace { virtual void print(std::ostream &O, const Module *M) const {} }; - - char InstCount::ID = 0; - RegisterPass X("instcount", - "Counts the various types of Instructions", false, true); } +char InstCount::ID = 0; +static RegisterPass +X("instcount", "Counts the various types of Instructions", false, true); + FunctionPass *llvm::createInstCountPass() { return new InstCount(); } // InstCount::run - This is the main Analysis entry point for a diff --git a/lib/Analysis/LoadValueNumbering.cpp b/lib/Analysis/LoadValueNumbering.cpp index bbb1e1e1b0d..0317ddbc914 100644 --- a/lib/Analysis/LoadValueNumbering.cpp +++ b/lib/Analysis/LoadValueNumbering.cpp @@ -82,15 +82,16 @@ namespace { void getCallEqualNumberNodes(CallInst *CI, std::vector &RetVals) const; }; - - char LoadVN::ID = 0; - // Register this pass... - RegisterPass X("load-vn", "Load Value Numbering", false, true); - - // Declare that we implement the ValueNumbering interface - RegisterAnalysisGroup Y(X); } +char LoadVN::ID = 0; +// Register this pass... +static RegisterPass +X("load-vn", "Load Value Numbering", false, true); + +// Declare that we implement the ValueNumbering interface +static RegisterAnalysisGroup Y(X); + FunctionPass *llvm::createLoadValueNumberingPass() { return new LoadVN(); } diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index 8a59c3a7431..4af7b42fb79 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -28,14 +28,12 @@ using namespace llvm; -namespace { - // Control the calculation of non-local dependencies by only examining the - // predecessors if the basic block has less than X amount (50 by default). - static cl::opt - PredLimit("nonlocaldep-threshold", cl::Hidden, cl::init(50), - cl::desc("Control the calculation of non-local" - "dependencies (default = 50)")); -} +// Control the calculation of non-local dependencies by only examining the +// predecessors if the basic block has less than X amount (50 by default). +static cl::opt +PredLimit("nonlocaldep-threshold", cl::Hidden, cl::init(50), + cl::desc("Control the calculation of non-local" + "dependencies (default = 50)")); STATISTIC(NumCacheNonlocal, "Number of cached non-local responses"); STATISTIC(NumUncacheNonlocal, "Number of uncached non-local responses"); diff --git a/lib/Analysis/ProfileInfo.cpp b/lib/Analysis/ProfileInfo.cpp index 2ee398d1aa4..047491baeee 100644 --- a/lib/Analysis/ProfileInfo.cpp +++ b/lib/Analysis/ProfileInfo.cpp @@ -21,9 +21,7 @@ using namespace llvm; // Register the ProfileInfo interface, providing a nice name to refer to. -namespace { - RegisterAnalysisGroup Z("Profile Information"); -} +static RegisterAnalysisGroup Z("Profile Information"); char ProfileInfo::ID = 0; ProfileInfo::~ProfileInfo() {} @@ -89,14 +87,14 @@ namespace { static char ID; // Class identification, replacement for typeinfo NoProfileInfo() : ImmutablePass((intptr_t)&ID) {} }; - - char NoProfileInfo::ID = 0; - // Register this pass... - RegisterPass - X("no-profile", "No Profile Information", false, true); - - // Declare that we implement the ProfileInfo interface - RegisterAnalysisGroup Y(X); } // End of anonymous namespace +char NoProfileInfo::ID = 0; +// Register this pass... +static RegisterPass +X("no-profile", "No Profile Information", false, true); + +// Declare that we implement the ProfileInfo interface +static RegisterAnalysisGroup Y(X); + ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); } diff --git a/lib/Analysis/ProfileInfoLoaderPass.cpp b/lib/Analysis/ProfileInfoLoaderPass.cpp index e7612e1d821..b2fa9e45e71 100644 --- a/lib/Analysis/ProfileInfoLoaderPass.cpp +++ b/lib/Analysis/ProfileInfoLoaderPass.cpp @@ -23,12 +23,12 @@ #include "llvm/Support/Streams.h" using namespace llvm; -namespace { - static cl::opt - ProfileInfoFilename("profile-info-file", cl::init("llvmprof.out"), - cl::value_desc("filename"), - cl::desc("Profile file loaded by -profile-loader")); +static cl::opt +ProfileInfoFilename("profile-info-file", cl::init("llvmprof.out"), + cl::value_desc("filename"), + cl::desc("Profile file loaded by -profile-loader")); +namespace { class VISIBILITY_HIDDEN LoaderPass : public ModulePass, public ProfileInfo { std::string Filename; public: @@ -49,14 +49,14 @@ namespace { /// run - Load the profile information from the specified file. virtual bool runOnModule(Module &M); }; - - char LoaderPass::ID = 0; - RegisterPass - X("profile-loader", "Load profile information from llvmprof.out", false, true); - - RegisterAnalysisGroup Y(X); } // End of anonymous namespace +char LoaderPass::ID = 0; +static RegisterPass +X("profile-loader", "Load profile information from llvmprof.out", false, true); + +static RegisterAnalysisGroup Y(X); + ModulePass *llvm::createProfileLoaderPass() { return new LoaderPass(); } /// createProfileLoaderPass - This function returns a Pass that loads the diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index b757531bc11..26010ebaa2f 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -95,16 +95,14 @@ STATISTIC(NumTripCountsNotComputed, STATISTIC(NumBruteForceTripCountsComputed, "Number of loops with trip counts computed by force"); -cl::opt +static cl::opt MaxBruteForceIterations("scalar-evolution-max-iterations", cl::ReallyHidden, cl::desc("Maximum number of iterations SCEV will " "symbolically execute a constant derived loop"), cl::init(100)); -namespace { - RegisterPass - R("scalar-evolution", "Scalar Evolution Analysis", false, true); -} +static RegisterPass +R("scalar-evolution", "Scalar Evolution Analysis", false, true); char ScalarEvolution::ID = 0; //===----------------------------------------------------------------------===// diff --git a/lib/Analysis/ValueNumbering.cpp b/lib/Analysis/ValueNumbering.cpp index 6c3ffdf224c..1e4b306f62e 100644 --- a/lib/Analysis/ValueNumbering.cpp +++ b/lib/Analysis/ValueNumbering.cpp @@ -24,7 +24,7 @@ using namespace llvm; char ValueNumbering::ID = 0; // Register the ValueNumbering interface, providing a nice name to refer to. -static RegisterAnalysisGroup X("Value Numbering"); +static RegisterAnalysisGroup V("Value Numbering"); /// ValueNumbering destructor: DO NOT move this to the header file for /// ValueNumbering or else clients of the ValueNumbering class may not depend on @@ -64,15 +64,17 @@ namespace { virtual void getEqualNumberNodes(Value *V1, std::vector &RetVals) const; }; +} - char BasicVN::ID = 0; - // Register this pass... - RegisterPass - X("basicvn", "Basic Value Numbering (default GVN impl)", false, true); +char BasicVN::ID = 0; +// Register this pass... +static RegisterPass +X("basicvn", "Basic Value Numbering (default GVN impl)", false, true); - // Declare that we implement the ValueNumbering interface - RegisterAnalysisGroup Y(X); +// Declare that we implement the ValueNumbering interface +static RegisterAnalysisGroup Y(X); +namespace { /// BVNImpl - Implement BasicVN in terms of a visitor class that /// handles the different types of instructions as appropriate. /// diff --git a/lib/Archive/ArchiveReader.cpp b/lib/Archive/ArchiveReader.cpp index fd0e30a71bf..1ded9e5c4cc 100644 --- a/lib/Archive/ArchiveReader.cpp +++ b/lib/Archive/ArchiveReader.cpp @@ -19,7 +19,7 @@ using namespace llvm; /// Read a variable-bit-rate encoded unsigned integer -inline unsigned readInteger(const char*&At, const char*End){ +static inline unsigned readInteger(const char*&At, const char*End) { unsigned Shift = 0; unsigned Result = 0; diff --git a/lib/Archive/ArchiveWriter.cpp b/lib/Archive/ArchiveWriter.cpp index d3861f32cbe..c5d54fba7e0 100644 --- a/lib/Archive/ArchiveWriter.cpp +++ b/lib/Archive/ArchiveWriter.cpp @@ -25,7 +25,7 @@ using namespace llvm; // Write an integer using variable bit rate encoding. This saves a few bytes // per entry in the symbol table. -inline void writeInteger(unsigned num, std::ofstream& ARFile) { +static inline void writeInteger(unsigned num, std::ofstream& ARFile) { while (1) { if (num < 0x80) { // done? ARFile << (unsigned char)num; @@ -41,7 +41,7 @@ inline void writeInteger(unsigned num, std::ofstream& ARFile) { // Compute how many bytes are taken by a given VBR encoded value. This is needed // to pre-compute the size of the symbol table. -inline unsigned numVbrBytes(unsigned num) { +static inline unsigned numVbrBytes(unsigned num) { // Note that the following nested ifs are somewhat equivalent to a binary // search. We split it in half by comparing against 2^14 first. This allows diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index 09a1db3d628..92271ce2b91 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -114,19 +114,21 @@ ValueEnumerator::ValueEnumerator(const Module *M) { } // Optimize constant ordering. -struct CstSortPredicate { - ValueEnumerator &VE; - CstSortPredicate(ValueEnumerator &ve) : VE(ve) {} - bool operator()(const std::pair &LHS, - const std::pair &RHS) { - // Sort by plane. - if (LHS.first->getType() != RHS.first->getType()) - return VE.getTypeID(LHS.first->getType()) < - VE.getTypeID(RHS.first->getType()); - // Then by frequency. - return LHS.second > RHS.second; - } -}; +namespace { + struct CstSortPredicate { + ValueEnumerator &VE; + explicit CstSortPredicate(ValueEnumerator &ve) : VE(ve) {} + bool operator()(const std::pair &LHS, + const std::pair &RHS) { + // Sort by plane. + if (LHS.first->getType() != RHS.first->getType()) + return VE.getTypeID(LHS.first->getType()) < + VE.getTypeID(RHS.first->getType()); + // Then by frequency. + return LHS.second > RHS.second; + } + }; +} /// OptimizeConstants - Reorder constant pool for denser encoding. void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) { diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index 1807f98cb13..e935898f196 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/lib/CodeGen/BranchFolding.cpp @@ -38,13 +38,13 @@ STATISTIC(NumBranchOpts, "Number of branches optimized"); STATISTIC(NumTailMerge , "Number of block tails merged"); static cl::opt FlagEnableTailMerge("enable-tail-merge", cl::init(cl::BOU_UNSET), cl::Hidden); -namespace { - // Throttle for huge numbers of predecessors (compile speed problems) - static cl::opt - TailMergeThreshold("tail-merge-threshold", - cl::desc("Max number of predecessors to consider tail merging"), - cl::init(100), cl::Hidden); +// Throttle for huge numbers of predecessors (compile speed problems) +static cl::opt +TailMergeThreshold("tail-merge-threshold", + cl::desc("Max number of predecessors to consider tail merging"), + cl::init(100), cl::Hidden); +namespace { struct VISIBILITY_HIDDEN BranchFolder : public MachineFunctionPass { static char ID; explicit BranchFolder(bool defaultEnableTailMerge) : diff --git a/lib/CodeGen/CollectorMetadata.cpp b/lib/CodeGen/CollectorMetadata.cpp index 80085cd29de..7a5a699a117 100644 --- a/lib/CodeGen/CollectorMetadata.cpp +++ b/lib/CodeGen/CollectorMetadata.cpp @@ -51,11 +51,11 @@ namespace { bool doFinalization(Module &M); }; - RegisterPass - X("collector-metadata", "Create Garbage Collector Module Metadata"); - } +static RegisterPass +X("collector-metadata", "Create Garbage Collector Module Metadata"); + // ----------------------------------------------------------------------------- CollectorMetadata::CollectorMetadata(const Function &F, Collector &C) diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 87c854bd027..8b25344b477 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -36,16 +36,14 @@ #include using namespace llvm; -namespace { - // Hidden options for help debugging. - static cl::opt DisableReMat("disable-rematerialization", - cl::init(false), cl::Hidden); +// Hidden options for help debugging. +static cl::opt DisableReMat("disable-rematerialization", + cl::init(false), cl::Hidden); - static cl::opt SplitAtBB("split-intervals-at-bb", - cl::init(true), cl::Hidden); - static cl::opt SplitLimit("split-limit", - cl::init(-1), cl::Hidden); -} +static cl::opt SplitAtBB("split-intervals-at-bb", + cl::init(true), cl::Hidden); +static cl::opt SplitLimit("split-limit", + cl::init(-1), cl::Hidden); STATISTIC(numIntervals, "Number of original intervals"); STATISTIC(numIntervalsAfter, "Number of intervals after coalescing"); @@ -53,9 +51,7 @@ STATISTIC(numFolds , "Number of loads/stores folded into instructions"); STATISTIC(numSplits , "Number of intervals split"); char LiveIntervals::ID = 0; -namespace { - RegisterPass X("liveintervals", "Live Interval Analysis"); -} +static RegisterPass X("liveintervals", "Live Interval Analysis"); void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const { AU.addPreserved(); @@ -1078,20 +1074,22 @@ static const VNInfo *findDefinedVNInfo(const LiveInterval &li, unsigned DefIdx) /// RewriteInfo - Keep track of machine instrs that will be rewritten /// during spilling. -struct RewriteInfo { - unsigned Index; - MachineInstr *MI; - bool HasUse; - bool HasDef; - RewriteInfo(unsigned i, MachineInstr *mi, bool u, bool d) - : Index(i), MI(mi), HasUse(u), HasDef(d) {} -}; +namespace { + struct RewriteInfo { + unsigned Index; + MachineInstr *MI; + bool HasUse; + bool HasDef; + RewriteInfo(unsigned i, MachineInstr *mi, bool u, bool d) + : Index(i), MI(mi), HasUse(u), HasDef(d) {} + }; -struct RewriteInfoCompare { - bool operator()(const RewriteInfo &LHS, const RewriteInfo &RHS) const { - return LHS.Index < RHS.Index; - } -}; + struct RewriteInfoCompare { + bool operator()(const RewriteInfo &LHS, const RewriteInfo &RHS) const { + return LHS.Index < RHS.Index; + } + }; +} void LiveIntervals:: rewriteInstructionsForSpills(const LiveInterval &li, bool TrySplit, diff --git a/lib/CodeGen/MachineDominators.cpp b/lib/CodeGen/MachineDominators.cpp index 9b53bdb8b3f..0710c10d967 100644 --- a/lib/CodeGen/MachineDominators.cpp +++ b/lib/CodeGen/MachineDominators.cpp @@ -22,9 +22,7 @@ TEMPLATE_INSTANTIATION(class DominatorTreeBase); char MachineDominatorTree::ID = 0; -namespace { - RegisterPass - E("machinedomtree", "MachineDominator Tree Construction", true); -} +static RegisterPass +E("machinedomtree", "MachineDominator Tree Construction", true); const PassInfo *llvm::MachineDominatorsID = E.getPassInfo(); diff --git a/lib/CodeGen/MachineLICM.cpp b/lib/CodeGen/MachineLICM.cpp index c2adb1e8b73..7f48ab5499f 100644 --- a/lib/CodeGen/MachineLICM.cpp +++ b/lib/CodeGen/MachineLICM.cpp @@ -150,12 +150,12 @@ namespace { /// void Hoist(MachineInstr &MI); }; - - char MachineLICM::ID = 0; - RegisterPass X("machine-licm", - "Machine Loop Invariant Code Motion"); } // end anonymous namespace +char MachineLICM::ID = 0; +static RegisterPass +X("machine-licm", "Machine Loop Invariant Code Motion"); + FunctionPass *llvm::createMachineLICMPass() { return new MachineLICM(); } /// Hoist expressions out of the specified loop. Note, alias info for inner loop diff --git a/lib/CodeGen/MachineLoopInfo.cpp b/lib/CodeGen/MachineLoopInfo.cpp index 007317ccb59..ac3df435008 100644 --- a/lib/CodeGen/MachineLoopInfo.cpp +++ b/lib/CodeGen/MachineLoopInfo.cpp @@ -23,10 +23,8 @@ TEMPLATE_INSTANTIATION(class LoopBase); TEMPLATE_INSTANTIATION(class LoopInfoBase); char MachineLoopInfo::ID = 0; -namespace { - RegisterPass - X("machine-loops", "Machine Natural Loop Construction", true); -} +static RegisterPass +X("machine-loops", "Machine Natural Loop Construction", true); const PassInfo *llvm::MachineLoopInfoID = X.getPassInfo(); diff --git a/lib/CodeGen/MachineModuleInfo.cpp b/lib/CodeGen/MachineModuleInfo.cpp index 0cfcc61b780..2bad6bba836 100644 --- a/lib/CodeGen/MachineModuleInfo.cpp +++ b/lib/CodeGen/MachineModuleInfo.cpp @@ -27,9 +27,8 @@ using namespace llvm; using namespace llvm::dwarf; // Handle the Pass registration stuff necessary to use TargetData's. -namespace { - RegisterPass X("machinemoduleinfo", "Module Information"); -} +static RegisterPass +X("machinemoduleinfo", "Module Information"); char MachineModuleInfo::ID = 0; //===----------------------------------------------------------------------===// @@ -160,6 +159,8 @@ void DIVisitor::ApplyToFields(DebugInfoDesc *DD) { DD->ApplyToFields(this); } +namespace { + //===----------------------------------------------------------------------===// /// DICountVisitor - This DIVisitor counts all the fields in the supplied debug /// the supplied DebugInfoDesc. @@ -479,6 +480,7 @@ public: } }; +} //===----------------------------------------------------------------------===// diff --git a/lib/CodeGen/MachineSink.cpp b/lib/CodeGen/MachineSink.cpp index 97a4df5497f..b4e72fed28d 100644 --- a/lib/CodeGen/MachineSink.cpp +++ b/lib/CodeGen/MachineSink.cpp @@ -50,10 +50,11 @@ namespace { bool SinkInstruction(MachineInstr *MI, bool &SawStore); bool AllUsesDominatedByBlock(unsigned Reg, MachineBasicBlock *MBB) const; }; - - char MachineSinking::ID = 0; - RegisterPass X("machine-sink", "Machine code sinking"); } // end anonymous namespace + +char MachineSinking::ID = 0; +static RegisterPass +X("machine-sink", "Machine code sinking"); FunctionPass *llvm::createMachineSinkingPass() { return new MachineSinking(); } diff --git a/lib/CodeGen/OcamlCollector.cpp b/lib/CodeGen/OcamlCollector.cpp index 95022a9ed4d..6b947b10507 100644 --- a/lib/CodeGen/OcamlCollector.cpp +++ b/lib/CodeGen/OcamlCollector.cpp @@ -35,11 +35,11 @@ namespace { const TargetAsmInfo &TAI); }; - CollectorRegistry::Add - X("ocaml", "ocaml 3.10-compatible collector"); - } +static CollectorRegistry::Add +X("ocaml", "ocaml 3.10-compatible collector"); + // ----------------------------------------------------------------------------- static void EmitCamlGlobal(const Module &M, std::ostream &OS, AsmPrinter &AP, diff --git a/lib/CodeGen/PHIElimination.cpp b/lib/CodeGen/PHIElimination.cpp index 601bfd65d75..4a9077a0638 100644 --- a/lib/CodeGen/PHIElimination.cpp +++ b/lib/CodeGen/PHIElimination.cpp @@ -73,12 +73,12 @@ namespace { // Defs of PHI sources which are implicit_def. SmallPtrSet ImpDefs; }; - - char PNE::ID = 0; - RegisterPass X("phi-node-elimination", - "Eliminate PHI nodes for register allocation"); } +char PNE::ID = 0; +static RegisterPass +X("phi-node-elimination", "Eliminate PHI nodes for register allocation"); + const PassInfo *llvm::PHIEliminationID = X.getPassInfo(); bool PNE::runOnMachineFunction(MachineFunction &Fn) { diff --git a/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp index bcd67c5037f..f67eb79be3e 100644 --- a/lib/CodeGen/Passes.cpp +++ b/lib/CodeGen/Passes.cpp @@ -30,14 +30,11 @@ MachinePassRegistry RegisterRegAlloc::Registry; /// RegAlloc command line options. /// //===---------------------------------------------------------------------===// -namespace { - static - cl::opt > - RegAlloc("regalloc", - cl::init(&createLinearScanRegisterAllocator), - cl::desc("Register allocator to use: (default = linearscan)")); -} +static cl::opt > +RegAlloc("regalloc", + cl::init(&createLinearScanRegisterAllocator), + cl::desc("Register allocator to use: (default = linearscan)")); //===---------------------------------------------------------------------===// diff --git a/lib/CodeGen/RegAllocBigBlock.cpp b/lib/CodeGen/RegAllocBigBlock.cpp index 0c6c25439a7..215f9430997 100644 --- a/lib/CodeGen/RegAllocBigBlock.cpp +++ b/lib/CodeGen/RegAllocBigBlock.cpp @@ -52,11 +52,11 @@ STATISTIC(NumStores, "Number of stores added"); STATISTIC(NumLoads , "Number of loads added"); STATISTIC(NumFolded, "Number of loads/stores folded into instructions"); -namespace { - static RegisterRegAlloc - bigBlockRegAlloc("bigblock", " Big-block register allocator", - createBigBlockRegisterAllocator); +static RegisterRegAlloc + bigBlockRegAlloc("bigblock", " Big-block register allocator", + createBigBlockRegisterAllocator); +namespace { /// VRegKeyInfo - Defines magic values required to use VirtRegs as DenseMap /// keys. struct VRegKeyInfo { diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp index 3281a2c3daf..18e7656bd46 100644 --- a/lib/CodeGen/RegAllocLocal.cpp +++ b/lib/CodeGen/RegAllocLocal.cpp @@ -37,12 +37,11 @@ using namespace llvm; STATISTIC(NumStores, "Number of stores added"); STATISTIC(NumLoads , "Number of loads added"); +static RegisterRegAlloc + localRegAlloc("local", " local register allocator", + createLocalRegisterAllocator); + namespace { - static RegisterRegAlloc - localRegAlloc("local", " local register allocator", - createLocalRegisterAllocator); - - class VISIBILITY_HIDDEN RALocal : public MachineFunctionPass { public: static char ID; diff --git a/lib/CodeGen/RegisterCoalescer.cpp b/lib/CodeGen/RegisterCoalescer.cpp index 9d25d2af890..1131e3db4e7 100644 --- a/lib/CodeGen/RegisterCoalescer.cpp +++ b/lib/CodeGen/RegisterCoalescer.cpp @@ -22,9 +22,7 @@ using namespace llvm; // Register the RegisterCoalescer interface, providing a nice name to refer to. -namespace { - RegisterAnalysisGroup Z("Register Coalescer"); -} +static RegisterAnalysisGroup Z("Register Coalescer"); char RegisterCoalescer::ID = 0; // RegisterCoalescer destructor: DO NOT move this to the header file diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index d2fe4718da4..f05f4445a8f 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -318,7 +318,7 @@ static void AddNodeIDOpcode(FoldingSetNodeID &ID, unsigned OpC) { /// AddNodeIDValueTypes - Value type lists are intern'd so we can represent them /// solely with their pointer. -void AddNodeIDValueTypes(FoldingSetNodeID &ID, SDVTList VTList) { +static void AddNodeIDValueTypes(FoldingSetNodeID &ID, SDVTList VTList) { ID.AddPointer(VTList.VTs); } diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 241ad7e8a95..f79ad0290a7 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -74,18 +74,16 @@ MachinePassRegistry RegisterScheduler::Registry; /// ISHeuristic command line option for instruction schedulers. /// //===---------------------------------------------------------------------===// -namespace { - static cl::opt > - ISHeuristic("pre-RA-sched", - cl::init(&createDefaultScheduler), - cl::desc("Instruction schedulers available (before register" - " allocation):")); +static cl::opt > +ISHeuristic("pre-RA-sched", + cl::init(&createDefaultScheduler), + cl::desc("Instruction schedulers available (before register" + " allocation):")); - static RegisterScheduler - defaultListDAGScheduler("default", " Best scheduler for the target", - createDefaultScheduler); -} // namespace +static RegisterScheduler +defaultListDAGScheduler("default", " Best scheduler for the target", + createDefaultScheduler); namespace { struct SDISelAsmOperandInfo; } diff --git a/lib/CodeGen/ShadowStackCollector.cpp b/lib/CodeGen/ShadowStackCollector.cpp index 092671ce562..568fe44c30e 100644 --- a/lib/CodeGen/ShadowStackCollector.cpp +++ b/lib/CodeGen/ShadowStackCollector.cpp @@ -66,11 +66,14 @@ namespace { static GetElementPtrInst *CreateGEP(IRBuilder &B, Value *BasePtr, int Idx1, int Idx2, const char *Name); }; + +} - CollectorRegistry::Add - Y("shadow-stack", - "Very portable collector for uncooperative code generators"); +static CollectorRegistry::Add +Y("shadow-stack", + "Very portable collector for uncooperative code generators"); +namespace { /// EscapeEnumerator - This is a little algorithm to find all escape points /// from a function so that "finally"-style code can be inserted. In addition /// to finding the existing return and unwind instructions, it also (if diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp index 6a110f0b87d..2526d4d8461 100644 --- a/lib/CodeGen/SimpleRegisterCoalescing.cpp +++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp @@ -42,23 +42,21 @@ STATISTIC(numPeep , "Number of identity moves eliminated after coalescing"); STATISTIC(numAborts , "Number of times interval joining aborted"); char SimpleRegisterCoalescing::ID = 0; -namespace { - static cl::opt - EnableJoining("join-liveintervals", - cl::desc("Coalesce copies (default=true)"), - cl::init(true)); +static cl::opt +EnableJoining("join-liveintervals", + cl::desc("Coalesce copies (default=true)"), + cl::init(true)); - static cl::opt - NewHeuristic("new-coalescer-heuristic", - cl::desc("Use new coalescer heuristic"), - cl::init(false)); +static cl::opt +NewHeuristic("new-coalescer-heuristic", + cl::desc("Use new coalescer heuristic"), + cl::init(false)); - RegisterPass - X("simple-register-coalescing", "Simple Register Coalescing"); +static RegisterPass +X("simple-register-coalescing", "Simple Register Coalescing"); - // Declare that we implement the RegisterCoalescer interface - RegisterAnalysisGroup V(X); -} +// Declare that we implement the RegisterCoalescer interface +static RegisterAnalysisGroup V(X); const PassInfo *llvm::SimpleRegisterCoalescingID = X.getPassInfo(); diff --git a/lib/CodeGen/StrongPHIElimination.cpp b/lib/CodeGen/StrongPHIElimination.cpp index a632da6de09..79f8f507c68 100644 --- a/lib/CodeGen/StrongPHIElimination.cpp +++ b/lib/CodeGen/StrongPHIElimination.cpp @@ -140,12 +140,13 @@ namespace { SmallPtrSet& v); void mergeLiveIntervals(unsigned primary, unsigned secondary, unsigned VN); }; - - char StrongPHIElimination::ID = 0; - RegisterPass X("strong-phi-node-elimination", - "Eliminate PHI nodes for register allocation, intelligently"); } +char StrongPHIElimination::ID = 0; +static RegisterPass +X("strong-phi-node-elimination", + "Eliminate PHI nodes for register allocation, intelligently"); + const PassInfo *llvm::StrongPHIEliminationID = X.getPassInfo(); /// computeDFS - Computes the DFS-in and DFS-out numbers of the dominator tree @@ -192,6 +193,8 @@ void StrongPHIElimination::computeDFS(MachineFunction& MF) { } } +namespace { + /// PreorderSorter - a helper class that is used to sort registers /// according to the preorder number of their defining blocks class PreorderSorter { @@ -219,6 +222,8 @@ public: } }; +} + /// computeDomForest - compute the subforest of the DomTree corresponding /// to the defining blocks of the registers in question std::vector diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp index 5dc1d699831..f343ff40d81 100644 --- a/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -75,12 +75,12 @@ namespace { /// runOnMachineFunction - Pass entry point. bool runOnMachineFunction(MachineFunction&); }; - - char TwoAddressInstructionPass::ID = 0; - RegisterPass - X("twoaddressinstruction", "Two-Address instruction pass"); } +char TwoAddressInstructionPass::ID = 0; +static RegisterPass +X("twoaddressinstruction", "Two-Address instruction pass"); + const PassInfo *llvm::TwoAddressInstructionPassID = X.getPassInfo(); /// Sink3AddrInstruction - A two-address instruction has been converted to a diff --git a/lib/CodeGen/UnreachableBlockElim.cpp b/lib/CodeGen/UnreachableBlockElim.cpp index 9672dacd506..3ba920204ac 100644 --- a/lib/CodeGen/UnreachableBlockElim.cpp +++ b/lib/CodeGen/UnreachableBlockElim.cpp @@ -38,10 +38,10 @@ namespace { static char ID; // Pass identification, replacement for typeid UnreachableBlockElim() : FunctionPass((intptr_t)&ID) {} }; - char UnreachableBlockElim::ID = 0; - RegisterPass - X("unreachableblockelim", "Remove unreachable blocks from the CFG"); } +char UnreachableBlockElim::ID = 0; +static RegisterPass +X("unreachableblockelim", "Remove unreachable blocks from the CFG"); FunctionPass *llvm::createUnreachableBlockEliminationPass() { return new UnreachableBlockElim(); diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp index fe8b6a5a63a..609e12d53ec 100644 --- a/lib/CodeGen/VirtRegMap.cpp +++ b/lib/CodeGen/VirtRegMap.cpp @@ -48,17 +48,17 @@ STATISTIC(NumDSS , "Number of dead spill slots removed"); namespace { enum SpillerName { simple, local }; - - static cl::opt - SpillerOpt("spiller", - cl::desc("Spiller to use: (default: local)"), - cl::Prefix, - cl::values(clEnumVal(simple, " simple spiller"), - clEnumVal(local, " local spiller"), - clEnumValEnd), - cl::init(local)); } +static cl::opt +SpillerOpt("spiller", + cl::desc("Spiller to use: (default: local)"), + cl::Prefix, + cl::values(clEnumVal(simple, " simple spiller"), + clEnumVal(local, " local spiller"), + clEnumValEnd), + cl::init(local)); + //===----------------------------------------------------------------------===// // VirtRegMap implementation //===----------------------------------------------------------------------===// diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/lib/ExecutionEngine/Interpreter/Interpreter.cpp index 5d7f9018542..4234bd9d8c7 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.cpp +++ b/lib/ExecutionEngine/Interpreter/Interpreter.cpp @@ -21,10 +21,14 @@ #include using namespace llvm; +namespace { + static struct RegisterInterp { RegisterInterp() { Interpreter::Register(); } } InterpRegistrator; +} + namespace llvm { void LinkInInterpreter() { } diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 9e89e3c0e1d..e95c8a0996c 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -52,10 +52,14 @@ using namespace llvm; extern void *__dso_handle __attribute__ ((__visibility__ ("hidden"))); #endif +namespace { + static struct RegisterJIT { RegisterJIT() { JIT::Register(); } } JITRegistrator; +} + namespace llvm { void LinkInJIT() { } diff --git a/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp b/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp index b73b0bd76c3..3b10a952d7f 100644 --- a/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp @@ -172,6 +172,8 @@ static bool PadLT(const LandingPadInfo *L, const LandingPadInfo *R) { return LSize < RSize; } +namespace { + struct KeyInfo { static inline unsigned getEmptyKey() { return -1U; } static inline unsigned getTombstoneKey() { return -2U; } @@ -205,6 +207,8 @@ struct CallSiteEntry { unsigned Action; }; +} + unsigned char* JITDwarfEmitter::EmitExceptionTable(MachineFunction* MF, unsigned char* StartFunction, unsigned char* EndFunction) const { diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp index 4516ebc6b34..13acc1b0fa1 100644 --- a/lib/Support/Statistic.cpp +++ b/lib/Support/Statistic.cpp @@ -70,6 +70,8 @@ void Statistic::RegisterStatistic() { Initialized = true; } +namespace { + struct NameCompare { bool operator()(const Statistic *LHS, const Statistic *RHS) const { int Cmp = std::strcmp(LHS->getName(), RHS->getName()); @@ -80,6 +82,8 @@ struct NameCompare { } }; +} + // Print information when destroyed, iff command line option is specified. StatisticInfo::~StatisticInfo() { // Statistics not enabled? diff --git a/lib/System/Unix/Unix.h b/lib/System/Unix/Unix.h index a7030fc7b27..b2c3160a415 100644 --- a/lib/System/Unix/Unix.h +++ b/lib/System/Unix/Unix.h @@ -70,7 +70,7 @@ /// string and the Unix error number given by \p errnum. If errnum is -1, the /// default then the value of errno is used. /// @brief Make an error message -inline bool MakeErrMsg( +static inline bool MakeErrMsg( std::string* ErrMsg, const std::string& prefix, int errnum = -1) { if (!ErrMsg) return true; diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp index d084fffa22f..913ebe0fa5e 100644 --- a/lib/Target/ARM/ARMTargetMachine.cpp +++ b/lib/Target/ARM/ARMTargetMachine.cpp @@ -27,11 +27,9 @@ static cl::opt DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden, static cl::opt DisableIfConversion("disable-arm-if-conversion",cl::Hidden, cl::desc("Disable if-conversion pass")); -namespace { - // Register the target. - RegisterTarget X("arm", " ARM"); - RegisterTarget Y("thumb", " Thumb"); -} +// Register the target. +static RegisterTarget X("arm", " ARM"); +static RegisterTarget Y("thumb", " Thumb"); /// ThumbTargetMachine - Create an Thumb architecture model. /// diff --git a/lib/Target/Alpha/AlphaTargetMachine.cpp b/lib/Target/Alpha/AlphaTargetMachine.cpp index 0887b952bb5..e986a64c090 100644 --- a/lib/Target/Alpha/AlphaTargetMachine.cpp +++ b/lib/Target/Alpha/AlphaTargetMachine.cpp @@ -20,10 +20,8 @@ using namespace llvm; -namespace { - // Register the targets - RegisterTarget X("alpha", " Alpha (incomplete)"); -} +// Register the targets +static RegisterTarget X("alpha", " Alpha (incomplete)"); const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const { return new AlphaTargetAsmInfo(*this); diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index d6ccefc8467..dcc920a64c2 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -47,10 +47,10 @@ #include using namespace llvm; -namespace { - // Register the target. - RegisterTarget X("c", " C backend"); +// Register the target. +static RegisterTarget X("c", " C backend"); +namespace { /// CBackendNameAllUsedStructsAndMergeFunctions - This pass inserts names for /// any unnamed structure types that are used by the program, and merges /// external functions with the same name. diff --git a/lib/Target/CellSPU/SPUISelDAGToDAG.cpp b/lib/Target/CellSPU/SPUISelDAGToDAG.cpp index 49a5e864d3e..c6628aca63a 100644 --- a/lib/Target/CellSPU/SPUISelDAGToDAG.cpp +++ b/lib/Target/CellSPU/SPUISelDAGToDAG.cpp @@ -214,6 +214,8 @@ namespace { } } +namespace { + //===--------------------------------------------------------------------===// /// SPUDAGToDAGISel - Cell SPU-specific code to select SPU machine /// instructions for SelectionDAG operations. @@ -336,6 +338,8 @@ public: #include "SPUGenDAGISel.inc" }; +} + /// InstructionSelectBasicBlock - This callback is invoked by /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. void diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index b42001fa284..2ba5fa66808 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -70,10 +70,10 @@ static cl::opt NameToGenerate("cppfor", cl::Optional, cl::desc("Specify the name of the thing to generate"), cl::init("!bad!")); -namespace { - // Register the target. - RegisterTarget X("cpp", " C++ backend"); +// Register the target. +static RegisterTarget X("cpp", " C++ backend"); +namespace { typedef std::vector TypeList; typedef std::map TypeMap; typedef std::map ValueMap; diff --git a/lib/Target/IA64/IA64TargetMachine.cpp b/lib/Target/IA64/IA64TargetMachine.cpp index d472b5cc5c7..7a0e4567bc0 100644 --- a/lib/Target/IA64/IA64TargetMachine.cpp +++ b/lib/Target/IA64/IA64TargetMachine.cpp @@ -26,9 +26,7 @@ using namespace llvm; extern "C" int IA64TargetMachineModule; int IA64TargetMachineModule = 0; -namespace { - RegisterTarget X("ia64", " IA-64 (Itanium)"); -} +static RegisterTarget X("ia64", " IA-64 (Itanium)"); const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const { return new IA64TargetAsmInfo(*this); diff --git a/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp index 187dd4a8af4..2b7e69e4de0 100644 --- a/lib/Target/MSIL/MSILWriter.cpp +++ b/lib/Target/MSIL/MSILWriter.cpp @@ -46,7 +46,7 @@ namespace { } -RegisterTarget X("msil", " MSIL backend"); +static RegisterTarget X("msil", " MSIL backend"); bool MSILModule::runOnModule(Module &M) { ModulePtr = &M; diff --git a/lib/Target/Mips/MipsTargetMachine.cpp b/lib/Target/Mips/MipsTargetMachine.cpp index 09e058f34f3..40de5dff1b5 100644 --- a/lib/Target/Mips/MipsTargetMachine.cpp +++ b/lib/Target/Mips/MipsTargetMachine.cpp @@ -19,10 +19,8 @@ #include "llvm/Target/TargetMachineRegistry.h" using namespace llvm; -namespace { - // Register the target. - RegisterTarget X("mips", " Mips"); -} +// Register the target. +static RegisterTarget X("mips", " Mips"); const TargetAsmInfo *MipsTargetMachine:: createTargetAsmInfo() const diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp index 37b8e7bb114..097e256c4a3 100644 --- a/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/lib/Target/PowerPC/PPCISelLowering.cpp @@ -1920,6 +1920,8 @@ static SDNode *isBLACompatibleAddress(SDOperand Op, SelectionDAG &DAG) { DAG.getTargetLoweringInfo().getPointerTy()).Val; } +namespace { + struct TailCallArgumentInfo { SDOperand Arg; SDOperand FrameIdxOp; @@ -1928,6 +1930,8 @@ struct TailCallArgumentInfo { TailCallArgumentInfo() : FrameIdx(0) {} }; +} + /// StoreTailCallArgumentsToStackSlot - Stores arguments to their stack slot. static void StoreTailCallArgumentsToStackSlot(SelectionDAG &DAG, diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp index a77cc15d8f8..cfec534ac20 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -19,13 +19,11 @@ #include "llvm/Target/TargetMachineRegistry.h" using namespace llvm; -namespace { - // Register the targets - RegisterTarget - X("ppc32", " PowerPC 32"); - RegisterTarget - Y("ppc64", " PowerPC 64"); -} +// Register the targets +static RegisterTarget +X("ppc32", " PowerPC 32"); +static RegisterTarget +Y("ppc64", " PowerPC 64"); const TargetAsmInfo *PPCTargetMachine::createTargetAsmInfo() const { if (Subtarget.isDarwin()) diff --git a/lib/Target/Sparc/SparcTargetMachine.cpp b/lib/Target/Sparc/SparcTargetMachine.cpp index 38f6d6a9014..a916b5c8ebd 100644 --- a/lib/Target/Sparc/SparcTargetMachine.cpp +++ b/lib/Target/Sparc/SparcTargetMachine.cpp @@ -18,10 +18,8 @@ #include "llvm/Target/TargetMachineRegistry.h" using namespace llvm; -namespace { - // Register the target. - RegisterTarget X("sparc", " SPARC"); -} +// Register the target. +static RegisterTarget X("sparc", " SPARC"); const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const { return new SparcTargetAsmInfo(*this); diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 215a4f6d388..69a8ca902b4 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -30,11 +30,10 @@ using namespace llvm; // Handle the Pass registration stuff necessary to use TargetData's. -namespace { - // Register the default SparcV9 implementation... - RegisterPass X("targetdata", "Target Data Layout", false, - true); -} + +// Register the default SparcV9 implementation... +static RegisterPass X("targetdata", "Target Data Layout", false, + true); char TargetData::ID = 0; //===----------------------------------------------------------------------===// @@ -318,6 +317,8 @@ unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType, : Alignments[BestMatchIdx].PrefAlign; } +namespace { + /// LayoutInfo - The lazy cache of structure layout information maintained by /// TargetData. Note that the struct types must have been free'd before /// llvm_shutdown is called (and thus this is deallocated) because all the @@ -342,8 +343,10 @@ struct DenseMapLayoutKeyInfo { }; typedef DenseMap LayoutInfoTy; -static ManagedStatic LayoutInfo; +} + +static ManagedStatic LayoutInfo; TargetData::~TargetData() { if (LayoutInfo.isConstructed()) { diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index 1065b095bc8..6e8831bf1f9 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -39,117 +39,116 @@ namespace llvm { bool RealignStack; unsigned StackAlignment; } -namespace { - static cl::opt PrintCode("print-machineinstrs", - cl::desc("Print generated machine code"), - cl::location(PrintMachineCode), cl::init(false)); - static cl::opt - DisableFPElim("disable-fp-elim", - cl::desc("Disable frame pointer elimination optimization"), - cl::location(NoFramePointerElim), - cl::init(false)); - static cl::opt - DisableExcessPrecision("disable-excess-fp-precision", - cl::desc("Disable optimizations that may increase FP precision"), - cl::location(NoExcessFPPrecision), - cl::init(false)); - static cl::opt - EnableUnsafeFPMath("enable-unsafe-fp-math", - cl::desc("Enable optimizations that may decrease FP precision"), - cl::location(UnsafeFPMath), - cl::init(false)); - static cl::opt - EnableFiniteOnlyFPMath("enable-finite-only-fp-math", - cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"), - cl::location(FiniteOnlyFPMathOption), - cl::init(false)); - static cl::opt - EnableHonorSignDependentRoundingFPMath(cl::Hidden, - "enable-sign-dependent-rounding-fp-math", - cl::desc("Force codegen to assume rounding mode can change dynamically"), - cl::location(HonorSignDependentRoundingFPMathOption), - cl::init(false)); +static cl::opt PrintCode("print-machineinstrs", + cl::desc("Print generated machine code"), + cl::location(PrintMachineCode), cl::init(false)); - static cl::opt - GenerateSoftFloatCalls("soft-float", - cl::desc("Generate software floating point library calls"), - cl::location(UseSoftFloat), - cl::init(false)); - static cl::opt - DontPlaceZerosInBSS("nozero-initialized-in-bss", - cl::desc("Don't place zero-initialized symbols into bss section"), - cl::location(NoZerosInBSS), - cl::init(false)); - static cl::opt - EnableExceptionHandling("enable-eh", - cl::desc("Emit DWARF exception handling (default if target supports)"), - cl::location(ExceptionHandling), - cl::init(false)); - static cl::opt - EnableUnwindTables("unwind-tables", - cl::desc("Generate unwinding tables for all functions"), - cl::location(UnwindTablesMandatory), - cl::init(false)); +static cl::opt + DisableFPElim("disable-fp-elim", + cl::desc("Disable frame pointer elimination optimization"), + cl::location(NoFramePointerElim), + cl::init(false)); +static cl::opt +DisableExcessPrecision("disable-excess-fp-precision", + cl::desc("Disable optimizations that may increase FP precision"), + cl::location(NoExcessFPPrecision), + cl::init(false)); +static cl::opt +EnableUnsafeFPMath("enable-unsafe-fp-math", + cl::desc("Enable optimizations that may decrease FP precision"), + cl::location(UnsafeFPMath), + cl::init(false)); +static cl::opt +EnableFiniteOnlyFPMath("enable-finite-only-fp-math", + cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"), + cl::location(FiniteOnlyFPMathOption), + cl::init(false)); +static cl::opt +EnableHonorSignDependentRoundingFPMath(cl::Hidden, + "enable-sign-dependent-rounding-fp-math", + cl::desc("Force codegen to assume rounding mode can change dynamically"), + cl::location(HonorSignDependentRoundingFPMathOption), + cl::init(false)); - static cl::opt - DefRelocationModel( - "relocation-model", - cl::desc("Choose relocation model"), - cl::location(RelocationModel), - cl::init(Reloc::Default), - cl::values( - clEnumValN(Reloc::Default, "default", - " Target default relocation model"), - clEnumValN(Reloc::Static, "static", - " Non-relocatable code"), - clEnumValN(Reloc::PIC_, "pic", - " Fully relocatable, position independent code"), - clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic", - " Relocatable external references, non-relocatable code"), - clEnumValEnd)); - static cl::opt - DefCodeModel( - "code-model", - cl::desc("Choose code model"), - cl::location(CMModel), - cl::init(CodeModel::Default), - cl::values( - clEnumValN(CodeModel::Default, "default", - " Target default code model"), - clEnumValN(CodeModel::Small, "small", - " Small code model"), - clEnumValN(CodeModel::Kernel, "kernel", - " Kernel code model"), - clEnumValN(CodeModel::Medium, "medium", - " Medium code model"), - clEnumValN(CodeModel::Large, "large", - " Large code model"), - clEnumValEnd)); +static cl::opt +GenerateSoftFloatCalls("soft-float", + cl::desc("Generate software floating point library calls"), + cl::location(UseSoftFloat), + cl::init(false)); +static cl::opt +DontPlaceZerosInBSS("nozero-initialized-in-bss", + cl::desc("Don't place zero-initialized symbols into bss section"), + cl::location(NoZerosInBSS), + cl::init(false)); +static cl::opt +EnableExceptionHandling("enable-eh", + cl::desc("Emit DWARF exception handling (default if target supports)"), + cl::location(ExceptionHandling), + cl::init(false)); +static cl::opt +EnableUnwindTables("unwind-tables", + cl::desc("Generate unwinding tables for all functions"), + cl::location(UnwindTablesMandatory), + cl::init(false)); - static cl::opt - EnablePerformTailCallOpt("tailcallopt", - cl::desc("Turn on tail call optimization."), - cl::location(PerformTailCallOpt), - cl::init(false)); - static cl::opt - EnableOptimizeForSize("optimize-size", - cl::desc("Optimize for size."), - cl::location(OptimizeForSize), - cl::init(false)); +static cl::opt +DefRelocationModel( + "relocation-model", + cl::desc("Choose relocation model"), + cl::location(RelocationModel), + cl::init(Reloc::Default), + cl::values( + clEnumValN(Reloc::Default, "default", + " Target default relocation model"), + clEnumValN(Reloc::Static, "static", + " Non-relocatable code"), + clEnumValN(Reloc::PIC_, "pic", + " Fully relocatable, position independent code"), + clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic", + " Relocatable external references, non-relocatable code"), + clEnumValEnd)); +static cl::opt +DefCodeModel( + "code-model", + cl::desc("Choose code model"), + cl::location(CMModel), + cl::init(CodeModel::Default), + cl::values( + clEnumValN(CodeModel::Default, "default", + " Target default code model"), + clEnumValN(CodeModel::Small, "small", + " Small code model"), + clEnumValN(CodeModel::Kernel, "kernel", + " Kernel code model"), + clEnumValN(CodeModel::Medium, "medium", + " Medium code model"), + clEnumValN(CodeModel::Large, "large", + " Large code model"), + clEnumValEnd)); - static cl::opt - EnableRealignStack("realign-stack", - cl::desc("Realign stack if needed"), - cl::location(RealignStack), - cl::init(true)); +static cl::opt +EnablePerformTailCallOpt("tailcallopt", + cl::desc("Turn on tail call optimization."), + cl::location(PerformTailCallOpt), + cl::init(false)); +static cl::opt +EnableOptimizeForSize("optimize-size", + cl::desc("Optimize for size."), + cl::location(OptimizeForSize), + cl::init(false)); - static cl::opt - OverrideStackAlignment("stack-alignment", - cl::desc("Override default stack alignment"), - cl::location(StackAlignment), - cl::init(0)); -} +static cl::opt +EnableRealignStack("realign-stack", + cl::desc("Realign stack if needed"), + cl::location(RealignStack), + cl::init(true)); + +static cl::opt +OverrideStackAlignment("stack-alignment", + cl::desc("Override default stack alignment"), + cl::location(StackAlignment), + cl::init(0)); //--------------------------------------------------------------------------- // TargetMachine Class diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp index c0040779a9a..98d80c84a0a 100644 --- a/lib/Target/X86/X86Subtarget.cpp +++ b/lib/Target/X86/X86Subtarget.cpp @@ -19,7 +19,7 @@ #include "llvm/Target/TargetOptions.h" using namespace llvm; -cl::opt +static cl::opt AsmWriterFlavor("x86-asm-syntax", cl::init(X86Subtarget::Unset), cl::desc("Choose style of code to emit from X86 backend:"), cl::values( diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp index 218f356b921..a60ce09ab9c 100644 --- a/lib/Target/X86/X86TargetMachine.cpp +++ b/lib/Target/X86/X86TargetMachine.cpp @@ -30,13 +30,11 @@ using namespace llvm; extern "C" int X86TargetMachineModule; int X86TargetMachineModule = 0; -namespace { - // Register the target. - RegisterTarget - X("x86", " 32-bit X86: Pentium-Pro and above"); - RegisterTarget - Y("x86-64", " 64-bit X86: EM64T and AMD64"); -} +// Register the target. +static RegisterTarget +X("x86", " 32-bit X86: Pentium-Pro and above"); +static RegisterTarget +Y("x86-64", " 64-bit X86: EM64T and AMD64"); const TargetAsmInfo *X86TargetMachine::createTargetAsmInfo() const { return new X86TargetAsmInfo(*this); diff --git a/lib/Transforms/Hello/Hello.cpp b/lib/Transforms/Hello/Hello.cpp index 5f27e04683c..f2a8322550f 100644 --- a/lib/Transforms/Hello/Hello.cpp +++ b/lib/Transforms/Hello/Hello.cpp @@ -36,10 +36,12 @@ namespace { return false; } }; +} - char Hello::ID = 0; - RegisterPass X("hello", "Hello World Pass"); +char Hello::ID = 0; +static RegisterPass X("hello", "Hello World Pass"); +namespace { // Hello2 - The second implementation with getAnalysisUsage implemented. struct Hello2 : public FunctionPass { static char ID; // Pass identification, replacement for typeid @@ -58,7 +60,8 @@ namespace { AU.setPreservesAll(); }; }; - char Hello2::ID = 0; - RegisterPass Y("hello2", - "Hello World Pass (with getAnalysisUsage implemented)"); } + +char Hello2::ID = 0; +static RegisterPass +Y("hello2", "Hello World Pass (with getAnalysisUsage implemented)"); diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index c6e27b4d627..264f080787c 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -77,12 +77,12 @@ namespace { /// The maximum number of elements to expand, or 0 for unlimited. unsigned maxElements; }; - - char ArgPromotion::ID = 0; - RegisterPass X("argpromotion", - "Promote 'by reference' arguments to scalars"); } +char ArgPromotion::ID = 0; +static RegisterPass +X("argpromotion", "Promote 'by reference' arguments to scalars"); + Pass *llvm::createArgumentPromotionPass(unsigned maxElements) { return new ArgPromotion(maxElements); } diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index a8a14923755..86cfcc4624a 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -38,11 +38,12 @@ namespace { // bool runOnModule(Module &M); }; - - char ConstantMerge::ID = 0; - RegisterPassX("constmerge","Merge Duplicate Global Constants"); } +char ConstantMerge::ID = 0; +static RegisterPass +X("constmerge", "Merge Duplicate Global Constants"); + ModulePass *llvm::createConstantMergePass() { return new ConstantMerge(); } bool ConstantMerge::runOnModule(Module &M) { diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index 6cd128b7c45..9b3efe0962b 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -97,9 +97,13 @@ namespace { void RemoveDeadArgumentsFromFunction(Function *F); }; - char DAE::ID = 0; - RegisterPass X("deadargelim", "Dead Argument Elimination"); +} +char DAE::ID = 0; +static RegisterPass +X("deadargelim", "Dead Argument Elimination"); + +namespace { /// DAH - DeadArgumentHacking pass - Same as dead argument elimination, but /// deletes arguments to functions which are external. This is only for use /// by bugpoint. @@ -107,11 +111,12 @@ namespace { static char ID; virtual bool ShouldHackArguments() const { return true; } }; - char DAH::ID = 0; - RegisterPass Y("deadarghaX0r", - "Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)"); } +char DAH::ID = 0; +static RegisterPass +Y("deadarghaX0r", "Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)"); + /// createDeadArgEliminationPass - This pass removes arguments from functions /// which are not used by the body of the function. /// diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index b9d9b547ea3..3cb658ef72f 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -43,10 +43,11 @@ namespace { AU.addRequired(); } }; - char DTE::ID = 0; - RegisterPass X("deadtypeelim", "Dead Type Elimination"); } +char DTE::ID = 0; +static RegisterPass X("deadtypeelim", "Dead Type Elimination"); + ModulePass *llvm::createDeadTypeEliminationPass() { return new DTE(); } diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index 4e30c105475..98202eb0b34 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -49,10 +49,11 @@ namespace { bool SafeToDestroyConstant(Constant* C); bool RemoveUnusedGlobalValue(GlobalValue &GV); }; - char GlobalDCE::ID = 0; - RegisterPass X("globaldce", "Dead Global Elimination"); } +char GlobalDCE::ID = 0; +static RegisterPass X("globaldce", "Dead Global Elimination"); + ModulePass *llvm::createGlobalDCEPass() { return new GlobalDCE(); } bool GlobalDCE::runOnModule(Module &M) { diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 600be26620a..e822d9c7b95 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -68,13 +68,15 @@ namespace { bool OptimizeGlobalCtorsList(GlobalVariable *&GCL); bool ProcessInternalGlobal(GlobalVariable *GV,Module::global_iterator &GVI); }; - - char GlobalOpt::ID = 0; - RegisterPass X("globalopt", "Global Variable Optimizer"); } +char GlobalOpt::ID = 0; +static RegisterPass X("globalopt", "Global Variable Optimizer"); + ModulePass *llvm::createGlobalOptimizerPass() { return new GlobalOpt(); } +namespace { + /// GlobalStatus - As we analyze each global, keep track of some information /// about it. If we find out that the address of the global is taken, none of /// this info will be accurate. @@ -129,7 +131,7 @@ struct VISIBILITY_HIDDEN GlobalStatus { HasNonInstructionUser(false), HasPHIUser(false) {} }; - +} /// ConstantIsDead - Return true if the specified constant is (transitively) /// dead. The constant may be used by other constants (e.g. constant arrays and diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp index c51c023c686..792fa980a60 100644 --- a/lib/Transforms/IPO/IPConstantPropagation.cpp +++ b/lib/Transforms/IPO/IPConstantPropagation.cpp @@ -42,10 +42,12 @@ namespace { bool PropagateConstantsIntoArguments(Function &F); bool PropagateConstantReturn(Function &F); }; - char IPCP::ID = 0; - RegisterPass X("ipconstprop", "Interprocedural constant propagation"); } +char IPCP::ID = 0; +static RegisterPass +X("ipconstprop", "Interprocedural constant propagation"); + ModulePass *llvm::createIPConstantPropagationPass() { return new IPCP(); } bool IPCP::runOnModule(Module &M) { diff --git a/lib/Transforms/IPO/IndMemRemoval.cpp b/lib/Transforms/IPO/IndMemRemoval.cpp index 2f9c34d5cf6..a623135bc1e 100644 --- a/lib/Transforms/IPO/IndMemRemoval.cpp +++ b/lib/Transforms/IPO/IndMemRemoval.cpp @@ -37,10 +37,11 @@ namespace { virtual bool runOnModule(Module &M); }; - char IndMemRemPass::ID = 0; - RegisterPass X("indmemrem","Indirect Malloc and Free Removal"); } // end anonymous namespace +char IndMemRemPass::ID = 0; +static RegisterPass +X("indmemrem","Indirect Malloc and Free Removal"); bool IndMemRemPass::runOnModule(Module &M) { //in Theory, all direct calls of malloc and free should be promoted diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index a007103a599..63a4798cce1 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -45,10 +45,12 @@ namespace { } virtual bool doInitialization(CallGraph &CG); }; - char SimpleInliner::ID = 0; - RegisterPass X("inline", "Function Integration/Inlining"); } +char SimpleInliner::ID = 0; +static RegisterPass +X("inline", "Function Integration/Inlining"); + Pass *llvm::createFunctionInliningPass() { return new SimpleInliner(); } Pass *llvm::createFunctionInliningPass(int Threshold) { diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index f44e78429b6..1c3d5a81f36 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -30,11 +30,9 @@ using namespace llvm; STATISTIC(NumInlined, "Number of functions inlined"); STATISTIC(NumDeleted, "Number of functions deleted because all callers found"); -namespace { - static cl::opt - InlineLimit("inline-threshold", cl::Hidden, cl::init(200), +static cl::opt +InlineLimit("inline-threshold", cl::Hidden, cl::init(200), cl::desc("Control the amount of inlining to perform (default = 200)")); -} Inliner::Inliner(const void *ID) : CallGraphSCCPass((intptr_t)ID), InlineThreshold(InlineLimit) {} diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index f3adb5692f1..453b4945e73 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -28,20 +28,19 @@ using namespace llvm; STATISTIC(NumFunctions, "Number of functions internalized"); STATISTIC(NumGlobals , "Number of global vars internalized"); +// APIFile - A file which contains a list of symbols that should not be marked +// external. +static cl::opt +APIFile("internalize-public-api-file", cl::value_desc("filename"), + cl::desc("A file containing list of symbol names to preserve")); + +// APIList - A list of symbols that should not be marked internal. +static cl::list +APIList("internalize-public-api-list", cl::value_desc("list"), + cl::desc("A list of symbol names to preserve"), + cl::CommaSeparated); + namespace { - - // APIFile - A file which contains a list of symbols that should not be marked - // external. - static cl::opt - APIFile("internalize-public-api-file", cl::value_desc("filename"), - cl::desc("A file containing list of symbol names to preserve")); - - // APIList - A list of symbols that should not be marked internal. - static cl::list - APIList("internalize-public-api-list", cl::value_desc("list"), - cl::desc("A list of symbol names to preserve"), - cl::CommaSeparated); - class VISIBILITY_HIDDEN InternalizePass : public ModulePass { std::set ExternalNames; bool DontInternalize; @@ -52,10 +51,12 @@ namespace { void LoadFile(const char *Filename); virtual bool runOnModule(Module &M); }; - char InternalizePass::ID = 0; - RegisterPass X("internalize", "Internalize Global Symbols"); } // end anonymous namespace +char InternalizePass::ID = 0; +static RegisterPass +X("internalize", "Internalize Global Symbols"); + InternalizePass::InternalizePass(bool InternalizeEverything) : ModulePass((intptr_t)&ID), DontInternalize(false){ if (!APIFile.empty()) // If a filename is specified, use it diff --git a/lib/Transforms/IPO/LoopExtractor.cpp b/lib/Transforms/IPO/LoopExtractor.cpp index 54fc44252e7..10ec3065af7 100644 --- a/lib/Transforms/IPO/LoopExtractor.cpp +++ b/lib/Transforms/IPO/LoopExtractor.cpp @@ -52,22 +52,24 @@ namespace { AU.addRequired(); } }; +} - char LoopExtractor::ID = 0; - RegisterPass - X("loop-extract", "Extract loops into new functions"); +char LoopExtractor::ID = 0; +static RegisterPass +X("loop-extract", "Extract loops into new functions"); +namespace { /// SingleLoopExtractor - For bugpoint. struct SingleLoopExtractor : public LoopExtractor { static char ID; // Pass identification, replacement for typeid SingleLoopExtractor() : LoopExtractor(1) {} }; - - char SingleLoopExtractor::ID = 0; - RegisterPass - Y("loop-extract-single", "Extract at most one loop into a new function"); } // End anonymous namespace +char SingleLoopExtractor::ID = 0; +static RegisterPass +Y("loop-extract-single", "Extract at most one loop into a new function"); + // createLoopExtractorPass - This pass extracts all natural loops from the // program into a function if it can. // @@ -146,14 +148,14 @@ FunctionPass *llvm::createSingleLoopExtractorPass() { } -namespace { - // BlockFile - A file which contains a list of blocks that should not be - // extracted. - static cl::opt - BlockFile("extract-blocks-file", cl::value_desc("filename"), - cl::desc("A file containing list of basic blocks to not extract"), - cl::Hidden); +// BlockFile - A file which contains a list of blocks that should not be +// extracted. +static cl::opt +BlockFile("extract-blocks-file", cl::value_desc("filename"), + cl::desc("A file containing list of basic blocks to not extract"), + cl::Hidden); +namespace { /// BlockExtractorPass - This pass is used by bugpoint to extract all blocks /// from the module into their own functions except for those specified by the /// BlocksToNotExtract list. @@ -173,12 +175,12 @@ namespace { bool runOnModule(Module &M); }; - - char BlockExtractorPass::ID = 0; - RegisterPass - XX("extract-blocks", "Extract Basic Blocks From Module (for bugpoint use)"); } +char BlockExtractorPass::ID = 0; +static RegisterPass +XX("extract-blocks", "Extract Basic Blocks From Module (for bugpoint use)"); + // createBlockExtractorPass - This pass extracts all blocks (except those // specified in the argument list) from the functions in the module. // diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index 2db8257b84f..0faaeb1a611 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -122,11 +122,11 @@ namespace { bool runOnModule(Module& M); bool doInitialization(Module& M); }; - - char LowerSetJmp::ID = 0; - RegisterPass X("lowersetjmp", "Lower Set Jump"); } // end anonymous namespace +char LowerSetJmp::ID = 0; +static RegisterPass X("lowersetjmp", "Lower Set Jump"); + // run - Run the transformation on the program. We grab the function // prototypes for longjmp and setjmp. If they are used in the program, // then we can go directly to the places they're at and transform them. diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index 01816052569..ceb9e3e54e8 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -43,11 +43,12 @@ namespace { bool SimplifyFunction(Function *F); void DeleteBasicBlock(BasicBlock *BB); }; - - char PruneEH::ID = 0; - RegisterPass X("prune-eh", "Remove unused exception handling info"); } +char PruneEH::ID = 0; +static RegisterPass +X("prune-eh", "Remove unused exception handling info"); + Pass *llvm::createPruneEHPass() { return new PruneEH(); } diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index 1f12fcf79d3..0931dec0105 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -48,12 +48,11 @@ namespace { // bool runOnModule(Module &M); }; - - char RaiseAllocations::ID = 0; - RegisterPass - X("raiseallocs", "Raise allocations from calls to instructions"); } // end anonymous namespace +char RaiseAllocations::ID = 0; +static RegisterPass +X("raiseallocs", "Raise allocations from calls to instructions"); // createRaiseAllocationsPass - The interface to this file... ModulePass *llvm::createRaiseAllocationsPass() { diff --git a/lib/Transforms/IPO/StripDeadPrototypes.cpp b/lib/Transforms/IPO/StripDeadPrototypes.cpp index ca8a436844a..7db0aa8d129 100644 --- a/lib/Transforms/IPO/StripDeadPrototypes.cpp +++ b/lib/Transforms/IPO/StripDeadPrototypes.cpp @@ -34,12 +34,12 @@ public: virtual bool runOnModule(Module &M); }; -char StripDeadPrototypesPass::ID = 0; -RegisterPass X("strip-dead-prototypes", - "Strip Unused Function Prototypes"); - } // end anonymous namespace +char StripDeadPrototypesPass::ID = 0; +static RegisterPass +X("strip-dead-prototypes", "Strip Unused Function Prototypes"); + bool StripDeadPrototypesPass::runOnModule(Module &M) { bool MadeChange = false; diff --git a/lib/Transforms/IPO/StripSymbols.cpp b/lib/Transforms/IPO/StripSymbols.cpp index cd2396258c4..63e1a7beb04 100644 --- a/lib/Transforms/IPO/StripSymbols.cpp +++ b/lib/Transforms/IPO/StripSymbols.cpp @@ -46,11 +46,12 @@ namespace { AU.setPreservesAll(); } }; - - char StripSymbols::ID = 0; - RegisterPass X("strip", "Strip all symbols from a module"); } +char StripSymbols::ID = 0; +static RegisterPass +X("strip", "Strip all symbols from a module"); + ModulePass *llvm::createStripSymbolsPass(bool OnlyDebugInfo) { return new StripSymbols(OnlyDebugInfo); } diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp index 34d977452c6..4f4f5748ebd 100644 --- a/lib/Transforms/IPO/StructRetPromotion.cpp +++ b/lib/Transforms/IPO/StructRetPromotion.cpp @@ -58,12 +58,12 @@ namespace { void updateCallSites(Function *F, Function *NF); bool nestedStructType(const StructType *STy); }; - - char SRETPromotion::ID = 0; - RegisterPass X("sretpromotion", - "Promote sret arguments to multiple ret values"); } +char SRETPromotion::ID = 0; +static RegisterPass +X("sretpromotion", "Promote sret arguments to multiple ret values"); + Pass *llvm::createStructRetPromotionPass() { return new SRETPromotion(); } diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp index 7068db281de..acde01888ca 100644 --- a/lib/Transforms/Instrumentation/BlockProfiling.cpp +++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp @@ -36,15 +36,15 @@ namespace { static char ID; bool runOnModule(Module &M); }; - - char FunctionProfiler::ID = 0; - - RegisterPass X("insert-function-profiling", - "Insert instrumentation for function profiling"); - RegisterAnalysisGroup XG(X); - } +char FunctionProfiler::ID = 0; + +static RegisterPass +X("insert-function-profiling", + "Insert instrumentation for function profiling"); +static RegisterAnalysisGroup XG(X); + ModulePass *llvm::createFunctionProfilerPass() { return new FunctionProfiler(); } @@ -86,13 +86,13 @@ namespace { public: static char ID; }; - - char BlockProfiler::ID = 0; - RegisterPass Y("insert-block-profiling", - "Insert instrumentation for block profiling"); - RegisterAnalysisGroup YG(Y); } +char BlockProfiler::ID = 0; +static RegisterPass +Y("insert-block-profiling", "Insert instrumentation for block profiling"); +static RegisterAnalysisGroup YG(Y); + ModulePass *llvm::createBlockProfilerPass() { return new BlockProfiler(); } bool BlockProfiler::runOnModule(Module &M) { diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp index 72f43e51247..2cf824b25f5 100644 --- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp +++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp @@ -36,12 +36,12 @@ namespace { static char ID; // Pass identification, replacement for typeid EdgeProfiler() : ModulePass((intptr_t)&ID) {} }; - - char EdgeProfiler::ID = 0; - RegisterPass X("insert-edge-profiling", - "Insert instrumentation for edge profiling"); } +char EdgeProfiler::ID = 0; +static RegisterPass +X("insert-edge-profiling", "Insert instrumentation for edge profiling"); + ModulePass *llvm::createEdgeProfilerPass() { return new EdgeProfiler(); } bool EdgeProfiler::runOnModule(Module &M) { diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp index c22a29ff7a4..62c9ddd6b2c 100644 --- a/lib/Transforms/Instrumentation/RSProfiling.cpp +++ b/lib/Transforms/Instrumentation/RSProfiling.cpp @@ -55,16 +55,18 @@ namespace { enum RandomMeth { GBV, GBVO, HOSTCC }; +} - static cl::opt RandomMethod("profile-randomness", - cl::desc("How to randomly choose to profile:"), - cl::values( - clEnumValN(GBV, "global", "global counter"), - clEnumValN(GBVO, "ra_global", - "register allocated global counter"), - clEnumValN(HOSTCC, "rdcc", "cycle counter"), - clEnumValEnd)); +static cl::opt RandomMethod("profile-randomness", + cl::desc("How to randomly choose to profile:"), + cl::values( + clEnumValN(GBV, "global", "global counter"), + clEnumValN(GBVO, "ra_global", + "register allocated global counter"), + clEnumValN(HOSTCC, "rdcc", "cycle counter"), + clEnumValEnd)); +namespace { /// NullProfilerRS - The basic profiler that does nothing. It is the default /// profiler and thus terminates RSProfiler chains. It is useful for /// measuring framework overhead @@ -81,12 +83,14 @@ namespace { AU.setPreservesAll(); } }; +} - static RegisterAnalysisGroup A("Profiling passes"); - static RegisterPass NP("insert-null-profiling-rs", - "Measure profiling framework overhead"); - static RegisterAnalysisGroup NPT(NP); +static RegisterAnalysisGroup A("Profiling passes"); +static RegisterPass NP("insert-null-profiling-rs", + "Measure profiling framework overhead"); +static RegisterAnalysisGroup NPT(NP); +namespace { /// Chooser - Something that chooses when to make a sample of the profiled code class VISIBILITY_HIDDEN Chooser { public: @@ -158,11 +162,12 @@ namespace { bool doInitialization(Module &M); virtual void getAnalysisUsage(AnalysisUsage &AU) const; }; - - RegisterPass X("insert-rs-profiling-framework", - "Insert random sampling instrumentation framework"); } +static RegisterPass +X("insert-rs-profiling-framework", + "Insert random sampling instrumentation framework"); + char RSProfilers::ID = 0; char NullProfilerRS::ID = 0; char ProfilerRS::ID = 0; diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index d909d0227c0..c633f930581 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -106,11 +106,11 @@ private: markInstructionLive(const_cast(BB->getTerminator())); } }; - - char ADCE::ID = 0; - RegisterPass X("adce", "Aggressive Dead Code Elimination"); } // End of anonymous namespace +char ADCE::ID = 0; +static RegisterPass X("adce", "Aggressive Dead Code Elimination"); + FunctionPass *llvm::createAggressiveDCEPass() { return new ADCE(); } void ADCE::markBlockAlive(BasicBlock *BB) { diff --git a/lib/Transforms/Scalar/BasicBlockPlacement.cpp b/lib/Transforms/Scalar/BasicBlockPlacement.cpp index 9bde7490357..041bed234b6 100644 --- a/lib/Transforms/Scalar/BasicBlockPlacement.cpp +++ b/lib/Transforms/Scalar/BasicBlockPlacement.cpp @@ -72,12 +72,12 @@ namespace { /// successors. void PlaceBlocks(BasicBlock *BB); }; - - char BlockPlacement::ID = 0; - RegisterPass X("block-placement", - "Profile Guided Basic Block Placement"); } +char BlockPlacement::ID = 0; +static RegisterPass +X("block-placement", "Profile Guided Basic Block Placement"); + FunctionPass *llvm::createBlockPlacementPass() { return new BlockPlacement(); } bool BlockPlacement::runOnFunction(Function &F) { diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp index bc19114fa2d..2dfd4d7a3d3 100644 --- a/lib/Transforms/Scalar/CodeGenPrepare.cpp +++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp @@ -483,6 +483,7 @@ static void EraseDeadInstructions(Value *V) { } } +namespace { /// ExtAddrMode - This is an extended version of TargetLowering::AddrMode which /// holds actual Value*'s for register values. @@ -517,6 +518,8 @@ void ExtAddrMode::dump() const { cerr << *this << "\n"; } +} + static bool TryMatchingScaledValue(Value *ScaleReg, int64_t Scale, const Type *AccessTy, ExtAddrMode &AddrMode, SmallVector &AddrModeInsts, diff --git a/lib/Transforms/Scalar/CondPropagate.cpp b/lib/Transforms/Scalar/CondPropagate.cpp index bed2b359a0e..c1e419569f4 100644 --- a/lib/Transforms/Scalar/CondPropagate.cpp +++ b/lib/Transforms/Scalar/CondPropagate.cpp @@ -48,10 +48,10 @@ namespace { void SimplifyPredecessors(SwitchInst *SI); void RevectorBlockTo(BasicBlock *FromBB, BasicBlock *ToBB); }; - - char CondProp::ID = 0; - RegisterPass X("condprop", "Conditional Propagation"); } + +char CondProp::ID = 0; +static RegisterPass X("condprop", "Conditional Propagation"); FunctionPass *llvm::createCondPropagationPass() { return new CondProp(); diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index 60b915a1b5e..90e8dad4f8a 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -43,12 +43,12 @@ namespace { AU.setPreservesCFG(); } }; - - char ConstantPropagation::ID = 0; - RegisterPass X("constprop", - "Simple constant propagation"); } +char ConstantPropagation::ID = 0; +static RegisterPass +X("constprop", "Simple constant propagation"); + FunctionPass *llvm::createConstantPropagationPass() { return new ConstantPropagation(); } diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 539dd22d47d..a63fcb6589f 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -52,11 +52,12 @@ namespace { AU.setPreservesCFG(); } }; - - char DeadInstElimination::ID = 0; - RegisterPass X("die", "Dead Instruction Elimination"); } +char DeadInstElimination::ID = 0; +static RegisterPass +X("die", "Dead Instruction Elimination"); + Pass *llvm::createDeadInstEliminationPass() { return new DeadInstElimination(); } @@ -76,11 +77,11 @@ namespace { AU.setPreservesCFG(); } }; - - char DCE::ID = 0; - RegisterPass Y("dce", "Dead Code Elimination"); } +char DCE::ID = 0; +static RegisterPass Y("dce", "Dead Code Elimination"); + bool DCE::runOnFunction(Function &F) { // Start out with all of the instructions in the worklist... std::vector WorkList; diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp index 89afa911e75..bbb3a8a3447 100644 --- a/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -92,10 +92,11 @@ namespace { AU.addPreserved(); } }; - char DSE::ID = 0; - RegisterPass X("dse", "Dead Store Elimination"); } +char DSE::ID = 0; +static RegisterPass X("dse", "Dead Store Elimination"); + FunctionPass *llvm::createDeadStoreEliminationPass() { return new DSE(); } bool DSE::runOnBasicBlock(BasicBlock &BB) { diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp index 39a1b257258..35752bb6796 100644 --- a/lib/Transforms/Scalar/GCSE.cpp +++ b/lib/Transforms/Scalar/GCSE.cpp @@ -52,11 +52,12 @@ namespace { AU.addRequired(); } }; - - char GCSE::ID = 0; - RegisterPass X("gcse", "Global Common Subexpression Elimination"); } +char GCSE::ID = 0; +static RegisterPass +X("gcse", "Global Common Subexpression Elimination"); + // createGCSEPass - The public interface to this file... FunctionPass *llvm::createGCSEPass() { return new GCSE(); } diff --git a/lib/Transforms/Scalar/GVNPRE.cpp b/lib/Transforms/Scalar/GVNPRE.cpp index 3bd6bff5d60..80d74e6004b 100644 --- a/lib/Transforms/Scalar/GVNPRE.cpp +++ b/lib/Transforms/Scalar/GVNPRE.cpp @@ -45,6 +45,8 @@ using namespace llvm; // ValueTable Class //===----------------------------------------------------------------------===// +namespace { + /// This class holds the mapping between values and value numbers. It is used /// as an efficient mechanism to determine the expression-wise equivalence of /// two values. @@ -123,6 +125,7 @@ struct Expression { } }; +} namespace { class VISIBILITY_HIDDEN ValueTable { @@ -596,6 +599,8 @@ unsigned ValueTable::size() { return nextValueNumber; } +namespace { + //===----------------------------------------------------------------------===// // ValueNumberedSet Class //===----------------------------------------------------------------------===// @@ -652,6 +657,8 @@ class ValueNumberedSet { } }; +} + //===----------------------------------------------------------------------===// // GVNPRE Pass //===----------------------------------------------------------------------===// diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 43054227aea..4de19a94fb4 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -94,11 +94,12 @@ namespace { void DeleteTriviallyDeadInstructions(std::set &Insts); }; - - char IndVarSimplify::ID = 0; - RegisterPass X("indvars", "Canonicalize Induction Variables"); } +char IndVarSimplify::ID = 0; +static RegisterPass +X("indvars", "Canonicalize Induction Variables"); + LoopPass *llvm::createIndVarSimplifyPass() { return new IndVarSimplify(); } diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index f3591879f7b..06620557daa 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// // // InstructionCombining - Combine instructions to form fewer, simple -// instructions. This pass does not modify the CFG This pass is where algebraic -// simplification happens. +// instructions. This pass does not modify the CFG. This pass is where +// algebraic simplification happens. // // This pass combines things like: // %Y = add i32 %X, 1 @@ -384,11 +384,12 @@ namespace { unsigned GetOrEnforceKnownAlignment(Value *V, unsigned PrefAlign = 0); }; - - char InstCombiner::ID = 0; - RegisterPass X("instcombine", "Combine redundant instructions"); } +char InstCombiner::ID = 0; +static RegisterPass +X("instcombine", "Combine redundant instructions"); + // getComplexity: Assign a complexity or rank value to LLVM Values... // 0 -> undef, 1 -> Const, 2 -> Other, 3 -> Arg, 3 -> Unary, 4 -> OtherInst static unsigned getComplexity(Value *V) { @@ -2151,6 +2152,7 @@ Instruction *AssociativeOpt(BinaryOperator &Root, const Functor &F) { return 0; } +namespace { // AddRHS - Implements: X + X --> X << 1 struct AddRHS { @@ -2178,6 +2180,8 @@ struct AddMaskingAnd { } }; +} + static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO, InstCombiner *IC) { if (CastInst *CI = dyn_cast(&I)) { @@ -4635,6 +4639,8 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { return Changed ? &I : 0; } +namespace { + // XorSelf - Implements: X ^ X --> 0 struct XorSelf { Value *RHS; @@ -4645,6 +4651,7 @@ struct XorSelf { } }; +} Instruction *InstCombiner::visitXor(BinaryOperator &I) { bool Changed = SimplifyCommutative(I); diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp index 991b11110b4..d79a6cea3b1 100644 --- a/lib/Transforms/Scalar/JumpThreading.cpp +++ b/lib/Transforms/Scalar/JumpThreading.cpp @@ -63,10 +63,12 @@ namespace { bool ProcessBranchOnLogical(Value *V, BasicBlock *BB, bool isAnd); bool ProcessBranchOnCompare(CmpInst *Cmp, BasicBlock *BB); }; - char JumpThreading::ID = 0; - RegisterPass X("jump-threading", "Jump Threading"); } +char JumpThreading::ID = 0; +static RegisterPass +X("jump-threading", "Jump Threading"); + // Public interface to the Jump Threading pass FunctionPass *llvm::createJumpThreadingPass() { return new JumpThreading(); } diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index 2d535326d2a..695a4fb0159 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -58,11 +58,11 @@ STATISTIC(NumMovedLoads, "Number of load insts hoisted or sunk"); STATISTIC(NumMovedCalls, "Number of call insts hoisted or sunk"); STATISTIC(NumPromoted , "Number of memory locations promoted to registers"); -namespace { - static cl::opt - DisablePromotion("disable-licm-promotion", cl::Hidden, - cl::desc("Disable memory promotion in LICM pass")); +static cl::opt +DisablePromotion("disable-licm-promotion", cl::Hidden, + cl::desc("Disable memory promotion in LICM pass")); +namespace { struct VISIBILITY_HIDDEN LICM : public LoopPass { static char ID; // Pass identification, replacement for typeid LICM() : LoopPass((intptr_t)&ID) {} @@ -216,11 +216,11 @@ namespace { std::vector > &PromotedValues, std::map &Val2AlMap); }; - - char LICM::ID = 0; - RegisterPass X("licm", "Loop Invariant Code Motion"); } +char LICM::ID = 0; +static RegisterPass X("licm", "Loop Invariant Code Motion"); + LoopPass *llvm::createLICMPass() { return new LICM(); } /// Hoist expressions out of the specified loop. Note, alias info for inner diff --git a/lib/Transforms/Scalar/LoopDeletion.cpp b/lib/Transforms/Scalar/LoopDeletion.cpp index 02a5ca98d97..c26a66c721e 100644 --- a/lib/Transforms/Scalar/LoopDeletion.cpp +++ b/lib/Transforms/Scalar/LoopDeletion.cpp @@ -52,10 +52,10 @@ namespace { AU.addPreservedID(LCSSAID); } }; - - char LoopDeletion::ID = 0; - RegisterPass X ("loop-deletion", "Delete dead loops"); } + +char LoopDeletion::ID = 0; +static RegisterPass X("loop-deletion", "Delete dead loops"); LoopPass* llvm::createLoopDeletionPass() { return new LoopDeletion(); diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp index a6bd9ff20a9..6113b24a298 100644 --- a/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -195,11 +195,12 @@ namespace { // Induction variable's final loop exit value operand number in exit condition.. unsigned ExitValueNum; }; - - char LoopIndexSplit::ID = 0; - RegisterPass X ("loop-index-split", "Index Split Loops"); } +char LoopIndexSplit::ID = 0; +static RegisterPass +X("loop-index-split", "Index Split Loops"); + LoopPass *llvm::createLoopIndexSplitPass() { return new LoopIndexSplit(); } diff --git a/lib/Transforms/Scalar/LoopRotation.cpp b/lib/Transforms/Scalar/LoopRotation.cpp index 91a96bcedac..d8362a55006 100644 --- a/lib/Transforms/Scalar/LoopRotation.cpp +++ b/lib/Transforms/Scalar/LoopRotation.cpp @@ -102,10 +102,10 @@ namespace { LPPassManager *LPM_Ptr; SmallVector LoopHeaderInfo; }; - - char LoopRotate::ID = 0; - RegisterPass X ("loop-rotate", "Rotate Loops"); } + +char LoopRotate::ID = 0; +static RegisterPass X("loop-rotate", "Rotate Loops"); LoopPass *llvm::createLoopRotatePass() { return new LoopRotate(); } diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 4dc7d60b0cb..6d66d14ec9a 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -194,10 +194,12 @@ private: Loop *L, bool isOnlyStride); void DeleteTriviallyDeadInstructions(SmallPtrSet &Insts); }; - char LoopStrengthReduce::ID = 0; - RegisterPass X("loop-reduce", "Loop Strength Reduction"); } +char LoopStrengthReduce::ID = 0; +static RegisterPass +X("loop-reduce", "Loop Strength Reduction"); + LoopPass *llvm::createLoopStrengthReducePass(const TargetLowering *TLI) { return new LoopStrengthReduce(TLI); } diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp index 0db964125ad..d3299702043 100644 --- a/lib/Transforms/Scalar/LoopUnroll.cpp +++ b/lib/Transforms/Scalar/LoopUnroll.cpp @@ -44,17 +44,15 @@ using namespace llvm; STATISTIC(NumCompletelyUnrolled, "Number of loops completely unrolled"); STATISTIC(NumUnrolled, "Number of loops unrolled (completely or otherwise)"); +static cl::opt +UnrollThreshold("unroll-threshold", cl::init(100), cl::Hidden, + cl::desc("The cut-off point for automatic loop unrolling")); + +static cl::opt +UnrollCount("unroll-count", cl::init(0), cl::Hidden, + cl::desc("Use this unroll count for all loops, for testing purposes")); + namespace { - static cl::opt - UnrollThreshold - ("unroll-threshold", cl::init(100), cl::Hidden, - cl::desc("The cut-off point for automatic loop unrolling")); - - static cl::opt - UnrollCount - ("unroll-count", cl::init(0), cl::Hidden, - cl::desc("Use this unroll count for all loops, for testing purposes")); - class VISIBILITY_HIDDEN LoopUnroll : public LoopPass { LoopInfo *LI; // The current loop information public: @@ -81,10 +79,11 @@ namespace { AU.addPreserved(); } }; - char LoopUnroll::ID = 0; - RegisterPass X("loop-unroll", "Unroll loops"); } +char LoopUnroll::ID = 0; +static RegisterPass X("loop-unroll", "Unroll loops"); + LoopPass *llvm::createLoopUnrollPass() { return new LoopUnroll(); } /// ApproximateLoopSize - Approximate the size of the loop. diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 5af0a57a80f..78069870507 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -54,11 +54,11 @@ STATISTIC(NumSelects , "Number of selects unswitched"); STATISTIC(NumTrivial , "Number of unswitches that are trivial"); STATISTIC(NumSimplify, "Number of simplifications of unswitched code"); -namespace { - static cl::opt - Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"), - cl::init(10), cl::Hidden); +static cl::opt +Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"), + cl::init(10), cl::Hidden); +namespace { class VISIBILITY_HIDDEN LoopUnswitch : public LoopPass { LoopInfo *LI; // Loop information LPPassManager *LPM; @@ -144,9 +144,9 @@ namespace { std::vector &Worklist, Loop *l); void RemoveLoopFromHierarchy(Loop *L); }; - char LoopUnswitch::ID = 0; - RegisterPass X("loop-unswitch", "Unswitch loops"); } +char LoopUnswitch::ID = 0; +static RegisterPass X("loop-unswitch", "Unswitch loops"); LoopPass *llvm::createLoopUnswitchPass(bool Os) { return new LoopUnswitch(Os); @@ -459,11 +459,11 @@ static inline void RemapInstruction(Instruction *I, // OrigPreheader is loop pre-header before this pass started // updating CFG. NewPrehader is loops new pre-header. However, after CFG // manipulation, loop L may not exist. So rely on input parameter NewPreheader. -void CloneDomInfo(BasicBlock *NewBB, BasicBlock *Orig, - BasicBlock *NewPreheader, BasicBlock *OrigPreheader, - BasicBlock *OrigHeader, - DominatorTree *DT, DominanceFrontier *DF, - DenseMap &VM) { +static void CloneDomInfo(BasicBlock *NewBB, BasicBlock *Orig, + BasicBlock *NewPreheader, BasicBlock *OrigPreheader, + BasicBlock *OrigHeader, + DominatorTree *DT, DominanceFrontier *DF, + DenseMap &VM) { // If NewBB alreay has found its place in domiantor tree then no need to do // anything. diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp index 1b36d84a7bd..5c79444dc51 100644 --- a/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -2646,12 +2646,12 @@ namespace { } } } - - char PredicateSimplifier::ID = 0; - RegisterPass X("predsimplify", - "Predicate Simplifier"); } +char PredicateSimplifier::ID = 0; +static RegisterPass +X("predsimplify", "Predicate Simplifier"); + FunctionPass *llvm::createPredicateSimplifierPass() { return new PredicateSimplifier(); } diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 0a118cd338b..e2d133ce351 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -64,7 +64,7 @@ static void PrintOps(Instruction *I, const std::vector &Ops) { << "," << Ops[i].Rank; } -namespace { +namespace { class VISIBILITY_HIDDEN Reassociate : public FunctionPass { std::map RankMap; std::map ValueRankMap; @@ -92,11 +92,11 @@ namespace { void RemoveDeadBinaryOp(Value *V); }; - - char Reassociate::ID = 0; - RegisterPass X("reassociate", "Reassociate expressions"); } +char Reassociate::ID = 0; +static RegisterPass X("reassociate", "Reassociate expressions"); + // Public interface to the Reassociate pass FunctionPass *llvm::createReassociatePass() { return new Reassociate(); } diff --git a/lib/Transforms/Scalar/Reg2Mem.cpp b/lib/Transforms/Scalar/Reg2Mem.cpp index eda0c0e93a1..b31b1d1fa6e 100644 --- a/lib/Transforms/Scalar/Reg2Mem.cpp +++ b/lib/Transforms/Scalar/Reg2Mem.cpp @@ -111,10 +111,11 @@ namespace { return false; } }; - - char RegToMem::ID = 0; - RegisterPass X("reg2mem", "Demote all values to stack slots"); } + +char RegToMem::ID = 0; +static RegisterPass +X("reg2mem", "Demote all values to stack slots"); // createDemoteRegisterToMemory - Provide an entry point to create this pass. // diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 168e54484da..9c17b77954e 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -1435,11 +1435,11 @@ namespace { AU.setPreservesCFG(); } }; - - char SCCP::ID = 0; - RegisterPass X("sccp", "Sparse Conditional Constant Propagation"); } // end anonymous namespace +char SCCP::ID = 0; +static RegisterPass +X("sccp", "Sparse Conditional Constant Propagation"); // createSCCPPass - This is the public interface to this file... FunctionPass *llvm::createSCCPPass() { @@ -1543,12 +1543,12 @@ namespace { IPSCCP() : ModulePass((intptr_t)&ID) {} bool runOnModule(Module &M); }; - - char IPSCCP::ID = 0; - RegisterPass - Y("ipsccp", "Interprocedural Sparse Conditional Constant Propagation"); } // end anonymous namespace +char IPSCCP::ID = 0; +static RegisterPass +Y("ipsccp", "Interprocedural Sparse Conditional Constant Propagation"); + // createIPSCCPPass - This is the public interface to this file... ModulePass *llvm::createIPSCCPPass() { return new IPSCCP(); diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 51aad84c072..0cd10ef0c16 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -124,11 +124,11 @@ namespace { unsigned Offset); static Instruction *isOnlyCopiedFromConstantGlobal(AllocationInst *AI); }; - - char SROA::ID = 0; - RegisterPass X("scalarrepl", "Scalar Replacement of Aggregates"); } +char SROA::ID = 0; +static RegisterPass X("scalarrepl", "Scalar Replacement of Aggregates"); + // Public interface to the ScalarReplAggregates pass FunctionPass *llvm::createScalarReplAggregatesPass(signed int Threshold) { return new SROA(Threshold); diff --git a/lib/Transforms/Scalar/SimplifyCFG.cpp b/lib/Transforms/Scalar/SimplifyCFG.cpp index 48342bdc11f..a42bc34040e 100644 --- a/lib/Transforms/Scalar/SimplifyCFG.cpp +++ b/lib/Transforms/Scalar/SimplifyCFG.cpp @@ -45,10 +45,11 @@ namespace { virtual bool runOnFunction(Function &F); }; - char CFGSimplifyPass::ID = 0; - RegisterPass X("simplifycfg", "Simplify the CFG"); } +char CFGSimplifyPass::ID = 0; +static RegisterPass X("simplifycfg", "Simplify the CFG"); + // Public interface to the CFGSimplification pass FunctionPass *llvm::createCFGSimplificationPass() { return new CFGSimplifyPass(); diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index f9b8ace11f3..40da808f671 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/lib/Transforms/Scalar/TailDuplication.cpp @@ -37,10 +37,11 @@ using namespace llvm; STATISTIC(NumEliminated, "Number of unconditional branches eliminated"); +static cl::opt +Threshold("taildup-threshold", cl::desc("Max block size to tail duplicate"), + cl::init(6), cl::Hidden); + namespace { - cl::opt - Threshold("taildup-threshold", cl::desc("Max block size to tail duplicate"), - cl::init(6), cl::Hidden); class VISIBILITY_HIDDEN TailDup : public FunctionPass { bool runOnFunction(Function &F); public: @@ -51,10 +52,11 @@ namespace { inline bool shouldEliminateUnconditionalBranch(TerminatorInst *TI); inline void eliminateUnconditionalBranch(BranchInst *BI); }; - char TailDup::ID = 0; - RegisterPass X("tailduplicate", "Tail Duplication"); } +char TailDup::ID = 0; +static RegisterPass X("tailduplicate", "Tail Duplication"); + // Public interface to the Tail Duplication pass FunctionPass *llvm::createTailDuplicationPass() { return new TailDup(); } diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index 78b088a6444..b9de782b270 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -80,10 +80,11 @@ namespace { bool CanMoveAboveCall(Instruction *I, CallInst *CI); Value *CanTransformAccumulatorRecursion(Instruction *I, CallInst *CI); }; - char TailCallElim::ID = 0; - RegisterPass X("tailcallelim", "Tail Call Elimination"); } +char TailCallElim::ID = 0; +static RegisterPass X("tailcallelim", "Tail Call Elimination"); + // Public interface to the TailCallElimination pass FunctionPass *llvm::createTailCallEliminationPass() { return new TailCallElim(); diff --git a/lib/Transforms/Utils/BasicInliner.cpp b/lib/Transforms/Utils/BasicInliner.cpp index a3f294d3421..5c2c6989b71 100644 --- a/lib/Transforms/Utils/BasicInliner.cpp +++ b/lib/Transforms/Utils/BasicInliner.cpp @@ -26,11 +26,9 @@ using namespace llvm; -namespace { - static cl::opt - BasicInlineThreshold("inline-threshold", cl::Hidden, cl::init(200), - cl::desc("Control the amount of basic inlining to perform (default = 200)")); -} +static cl::opt +BasicInlineThreshold("inline-threshold", cl::Hidden, cl::init(200), + cl::desc("Control the amount of basic inlining to perform (default = 200)")); namespace llvm { diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp index e230ca68304..4bf7bac4e22 100644 --- a/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -48,12 +48,12 @@ namespace { AU.addPreservedID(LoopSimplifyID); } }; - - char BreakCriticalEdges::ID = 0; - RegisterPass X("break-crit-edges", - "Break critical edges in CFG"); } +char BreakCriticalEdges::ID = 0; +static RegisterPass +X("break-crit-edges", "Break critical edges in CFG"); + // Publically exposed interface to pass... const PassInfo *llvm::BreakCriticalEdgesID = X.getPassInfo(); FunctionPass *llvm::createBreakCriticalEdgesPass() { diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp index 39314678bd4..ff5f863645b 100644 --- a/lib/Transforms/Utils/LCSSA.cpp +++ b/lib/Transforms/Utils/LCSSA.cpp @@ -94,10 +94,10 @@ namespace { return std::binary_search(LoopBlocks.begin(), LoopBlocks.end(), B); } }; - - char LCSSA::ID = 0; - RegisterPass X("lcssa", "Loop-Closed SSA Form Pass"); } + +char LCSSA::ID = 0; +static RegisterPass X("lcssa", "Loop-Closed SSA Form Pass"); LoopPass *llvm::createLCSSAPass() { return new LCSSA(); } const PassInfo *llvm::LCSSAID = X.getPassInfo(); diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index 8e30e042862..9351837aca5 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -95,12 +95,12 @@ namespace { SmallVectorImpl &SplitPreds, Loop *L); }; - - char LoopSimplify::ID = 0; - RegisterPass - X("loopsimplify", "Canonicalize natural loops", true); } +char LoopSimplify::ID = 0; +static RegisterPass +X("loopsimplify", "Canonicalize natural loops", true); + // Publically exposed interface to pass... const PassInfo *llvm::LoopSimplifyID = X.getPassInfo(); FunctionPass *llvm::createLoopSimplifyPass() { return new LoopSimplify(); } diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index 8708f994fee..edce5e144c7 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -66,12 +66,12 @@ namespace { /// bool runOnBasicBlock(BasicBlock &BB); }; - - char LowerAllocations::ID = 0; - RegisterPass - X("lowerallocs", "Lower allocations from instructions to calls"); } +char LowerAllocations::ID = 0; +static RegisterPass +X("lowerallocs", "Lower allocations from instructions to calls"); + // Publically exposed interface to pass... const PassInfo *llvm::LowerAllocationsID = X.getPassInfo(); // createLowerAllocationsPass - Interface to this file... diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 3d356b78aee..0530e52173d 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -98,12 +98,12 @@ namespace { AllocaInst *InvokeNum, SwitchInst *CatchSwitch); bool insertExpensiveEHSupport(Function &F); }; - - char LowerInvoke::ID = 0; - RegisterPass - X("lowerinvoke", "Lower invoke and unwind, for unwindless code generators"); } +char LowerInvoke::ID = 0; +static RegisterPass +X("lowerinvoke", "Lower invoke and unwind, for unwindless code generators"); + const PassInfo *llvm::LowerInvokePassID = X.getPassInfo(); // Public Interface To the LowerInvoke pass. diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index d75880f585c..9ddb2cd1d9d 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -77,12 +77,12 @@ namespace { return CI1->getValue().slt(CI2->getValue()); } }; - - char LowerSwitch::ID = 0; - RegisterPass - X("lowerswitch", "Lower SwitchInst's to branches"); } +char LowerSwitch::ID = 0; +static RegisterPass +X("lowerswitch", "Lower SwitchInst's to branches"); + // Publically exposed interface to pass... const PassInfo *llvm::LowerSwitchID = X.getPassInfo(); // createLowerSwitchPass - Interface to this file... diff --git a/lib/Transforms/Utils/Mem2Reg.cpp b/lib/Transforms/Utils/Mem2Reg.cpp index f9b1d8d4994..e402bb93570 100644 --- a/lib/Transforms/Utils/Mem2Reg.cpp +++ b/lib/Transforms/Utils/Mem2Reg.cpp @@ -48,11 +48,11 @@ namespace { AU.addPreservedID(LowerAllocationsID); } }; - - char PromotePass::ID = 0; - RegisterPass X("mem2reg", "Promote Memory to Register"); } // end of anonymous namespace +char PromotePass::ID = 0; +static RegisterPass X("mem2reg", "Promote Memory to Register"); + bool PromotePass::runOnFunction(Function &F) { std::vector Allocas; diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 974678b2c0e..b327a6a855a 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -1514,6 +1514,8 @@ void UndefValue::destroyConstant() { //---- ConstantExpr::get() implementations... // +namespace { + struct ExprMapKeyType { explicit ExprMapKeyType(unsigned opc, std::vector ops, unsigned short pred = 0) : opcode(opc), predicate(pred), operands(ops) { } @@ -1537,6 +1539,8 @@ struct ExprMapKeyType { } }; +} + namespace llvm { template<> struct ConstantCreator { diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 312379479d6..add652986d1 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -360,10 +360,10 @@ public: } }; -static TimingInfo *TheTimeInfo; - } // End of anon namespace +static TimingInfo *TheTimeInfo; + //===----------------------------------------------------------------------===// // PMTopLevelManager implementation diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 633991299b2..d7fe2d1cfbe 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -550,6 +550,7 @@ void DerivedType::dropAllTypeUses() { } +namespace { /// TypePromotionGraph and graph traits - this is designed to allow us to do /// efficient SCC processing of type graphs. This is the exact same as @@ -560,6 +561,8 @@ struct TypePromotionGraph { TypePromotionGraph(Type *T) : Ty(T) {} }; +} + namespace llvm { template <> struct GraphTraits { typedef Type NodeType; diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index aec5974209b..4c6f9e00f7c 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -92,11 +92,14 @@ namespace { // Anonymous namespace for class return false; } }; +} - char PreVerifier::ID = 0; - RegisterPass PreVer("preverify", "Preliminary module verification"); - const PassInfo *PreVerifyID = PreVer.getPassInfo(); +char PreVerifier::ID = 0; +static RegisterPass +PreVer("preverify", "Preliminary module verification"); +static const PassInfo *PreVerifyID = PreVer.getPassInfo(); +namespace { struct VISIBILITY_HIDDEN Verifier : public FunctionPass, InstVisitor { static char ID; // Pass ID, replacement for typeid @@ -305,11 +308,10 @@ namespace { // Anonymous namespace for class Broken = true; } }; - - char Verifier::ID = 0; - RegisterPass X("verify", "Module Verifier"); } // End anonymous namespace +char Verifier::ID = 0; +static RegisterPass X("verify", "Module Verifier"); // Assert - We know that cond should be true, if not print an error message. #define Assert(C, M) \