diff options
author | Chris Lattner <sabre@nondot.org> | 2006-10-04 21:52:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-10-04 21:52:35 +0000 |
commit | 90aa839c88776e3dd0b3a798a98ea30d85b6b53c (patch) | |
tree | e5035d118521b402ff91f1980ebadcd8a71ba5ee /lib/Analysis/BasicAliasAnalysis.cpp | |
parent | b336409673c614843cc19b8f61db6afb9d8c5ac3 (diff) |
Fix more static dtor issues
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30725 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 167d3b0c02..fdc452b44f 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -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 @@ static const char *OnlyReadsMemoryFns[] = { "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 @@ BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS, #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; |