[llvm-commits] CVS: llvm/lib/Analysis/BasicAliasAnalysis.cpp

Chris Lattner sabre at nondot.org
Wed Oct 4 14:52:52 PDT 2006



Changes in directory llvm/lib/Analysis:

BasicAliasAnalysis.cpp updated: 1.85 -> 1.86
---
Log message:

Fix more static dtor issues


---
Diffs of the changes:  (+17 -14)

 BasicAliasAnalysis.cpp |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)


Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.85 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.86
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.85	Sun Aug 27 19:42:29 2006
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp	Wed Oct  4 16:52:35 2006
@@ -22,8 +22,9 @@
 #include "llvm/Instructions.h"
 #include "llvm/Pass.h"
 #include "llvm/Target/TargetData.h"
-#include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/GetElementPtrTypeIterator.h"
+#include "llvm/Support/ManagedStatic.h"
 #include <algorithm>
 using namespace llvm;
 
@@ -801,21 +802,23 @@
   "feof_unlocked", "ferror_unlocked", "fileno_unlocked"
 };
 
+static ManagedStatic<std::vector<const char*> > NoMemoryTable;
+static ManagedStatic<std::vector<const char*> > OnlyReadsMemoryTable;
+
+
 AliasAnalysis::ModRefBehavior
 BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,
                                       std::vector<PointerAccessInfo> *Info) {
   if (!F->isExternal()) return UnknownModRefBehavior;
 
-  static std::vector<const char*> NoMemoryTable, OnlyReadsMemoryTable;
-
   static bool Initialized = false;
   if (!Initialized) {
-    NoMemoryTable.insert(NoMemoryTable.end(),
-                         DoesntAccessMemoryFns, 
-                         DoesntAccessMemoryFns+
+    NoMemoryTable->insert(NoMemoryTable->end(),
+                          DoesntAccessMemoryFns, 
+                          DoesntAccessMemoryFns+
                 sizeof(DoesntAccessMemoryFns)/sizeof(DoesntAccessMemoryFns[0]));
 
-    OnlyReadsMemoryTable.insert(OnlyReadsMemoryTable.end(),
+    OnlyReadsMemoryTable->insert(OnlyReadsMemoryTable->end(),
                                 OnlyReadsMemoryFns, 
                                 OnlyReadsMemoryFns+
                       sizeof(OnlyReadsMemoryFns)/sizeof(OnlyReadsMemoryFns[0]));
@@ -824,22 +827,22 @@
 #undef GET_MODREF_BEHAVIOR
     
     // Sort the table the first time through.
-    std::sort(NoMemoryTable.begin(), NoMemoryTable.end(), StringCompare());
-    std::sort(OnlyReadsMemoryTable.begin(), OnlyReadsMemoryTable.end(),
+    std::sort(NoMemoryTable->begin(), NoMemoryTable->end(), StringCompare());
+    std::sort(OnlyReadsMemoryTable->begin(), OnlyReadsMemoryTable->end(),
               StringCompare());
     Initialized = true;
   }
 
   std::vector<const char*>::iterator Ptr =
-    std::lower_bound(NoMemoryTable.begin(), NoMemoryTable.end(),
+    std::lower_bound(NoMemoryTable->begin(), NoMemoryTable->end(),
                      F->getName().c_str(), StringCompare());
-  if (Ptr != NoMemoryTable.end() && *Ptr == F->getName())
+  if (Ptr != NoMemoryTable->end() && *Ptr == F->getName())
     return DoesNotAccessMemory;
 
-  Ptr = std::lower_bound(OnlyReadsMemoryTable.begin(),
-                         OnlyReadsMemoryTable.end(),
+  Ptr = std::lower_bound(OnlyReadsMemoryTable->begin(),
+                         OnlyReadsMemoryTable->end(),
                          F->getName().c_str(), StringCompare());
-  if (Ptr != OnlyReadsMemoryTable.end() && *Ptr == F->getName())
+  if (Ptr != OnlyReadsMemoryTable->end() && *Ptr == F->getName())
     return OnlyReadsMemory;
 
   return UnknownModRefBehavior;






More information about the llvm-commits mailing list