Clean up the use of static and anonymous namespaces. This turned up
[oota-llvm.git] / lib / Analysis / IPA / GlobalsModRef.cpp
index 6ac040b56fb87862a7ee91ec24ecfbc95f38d392..6d6282029aee4f28588227cf7599207d0cfa7619 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -23,8 +23,9 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/CallGraph.h"
-#include "llvm/Support/InstIterator.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InstIterator.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/SCCIterator.h"
 #include <set>
@@ -42,7 +43,7 @@ namespace {
   /// function in the program.  Later, the entries for these functions are
   /// removed if the function is found to call an external function (in which
   /// case we know nothing about it.
-  struct FunctionRecord {
+  struct VISIBILITY_HIDDEN FunctionRecord {
     /// GlobalInfo - Maintain mod/ref info for all of the globals without
     /// addresses taken that are read or written (transitively) by this
     /// function.
@@ -63,7 +64,8 @@ namespace {
   };
 
   /// GlobalsModRef - The actual analysis pass.
-  class GlobalsModRef : public ModulePass, public AliasAnalysis {
+  class VISIBILITY_HIDDEN GlobalsModRef 
+      : public ModulePass, public AliasAnalysis {
     /// NonAddressTakenGlobals - The globals that do not have their addresses
     /// taken.
     std::set<GlobalValue*> NonAddressTakenGlobals;
@@ -81,6 +83,9 @@ namespace {
     std::map<Function*, FunctionRecord> FunctionInfo;
 
   public:
+    static char ID;
+    GlobalsModRef() : ModulePass((intptr_t)&ID) {}
+
     bool runOnModule(Module &M) {
       InitializeAliasAnalysis(this);                 // set up super class
       AnalyzeGlobals(M);                          // find non-addr taken globals
@@ -110,11 +115,12 @@ namespace {
     /// case the most generic behavior of this function should be returned.
     virtual ModRefBehavior getModRefBehavior(Function *F, CallSite CS,
                                          std::vector<PointerAccessInfo> *Info) {
-      if (FunctionRecord *FR = getFunctionInfo(F))
+      if (FunctionRecord *FR = getFunctionInfo(F)) {
         if (FR->FunctionEffect == 0)
           return DoesNotAccessMemory;
         else if ((FR->FunctionEffect & Mod) == 0)
           return OnlyReadsMemory;
+      }
       return AliasAnalysis::getModRefBehavior(F, CS, Info);
     }
 
@@ -140,12 +146,13 @@ namespace {
                               GlobalValue *OkayStoreDest = 0);
     bool AnalyzeIndirectGlobalMemory(GlobalValue *GV);
   };
-
-  RegisterPass<GlobalsModRef> X("globalsmodref-aa",
-                                "Simple mod/ref analysis for globals");
-  RegisterAnalysisGroup<AliasAnalysis> Y(X);
 }
 
+char GlobalsModRef::ID = 0;
+static RegisterPass<GlobalsModRef>
+X("globalsmodref-aa", "Simple mod/ref analysis for globals", false, true);
+static RegisterAnalysisGroup<AliasAnalysis> Y(X);
+
 Pass *llvm::createGlobalsModRefPass() { return new GlobalsModRef(); }
 
 /// getUnderlyingObject - This traverses the use chain to figure out what object
@@ -388,7 +395,7 @@ void GlobalsModRef::AnalyzeSCC(std::vector<CallGraphNode *> &SCC) {
           // Okay, if we can't say anything about it, maybe some other alias
           // analysis can.
           ModRefBehavior MRB =
-            AliasAnalysis::getModRefBehavior(Callee, CallSite());
+            AliasAnalysis::getModRefBehavior(Callee);
           if (MRB != DoesNotAccessMemory) {
             // FIXME: could make this more aggressive for functions that just
             // read memory.  We should just say they read all globals.
@@ -542,7 +549,10 @@ void GlobalsModRef::deleteValue(Value *V) {
   // Otherwise, if this is an allocation related to an indirect global, remove
   // it.
   AllocsForIndirectGlobals.erase(V);
+  
+  AliasAnalysis::deleteValue(V);
 }
 
 void GlobalsModRef::copyValue(Value *From, Value *To) {
+  AliasAnalysis::copyValue(From, To);
 }