aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-03-09 22:31:29 +0000
committerChris Lattner <sabre@nondot.org>2006-03-09 22:31:29 +0000
commitcad25379d30b80c7d1a61271aed18938b01617e2 (patch)
tree9ccc39105a73220683585b9f81010bbd77b5cee3
parent6448ee44c6f232f215d5d9f145a0d71a983c4a3f (diff)
downloadexternal_llvm-cad25379d30b80c7d1a61271aed18938b01617e2.zip
external_llvm-cad25379d30b80c7d1a61271aed18938b01617e2.tar.gz
external_llvm-cad25379d30b80c7d1a61271aed18938b01617e2.tar.bz2
Use autogenerated mod/ref info for intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26670 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp48
1 files changed, 26 insertions, 22 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index 9a839ff..2a37ab8 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -741,12 +741,7 @@ namespace {
// Note that this list cannot contain libm functions (such as acos and sqrt)
// that set errno on a domain or other error.
-static const char *DoesntAccessMemoryTable[] = {
- // LLVM intrinsics:
- "llvm.frameaddress", "llvm.returnaddress", "llvm.readport",
- "llvm.isunordered", "llvm.sqrt", "llvm.bswap.i16", "llvm.bswap.i32",
- "llvm.bswap.i64", "llvm.ctpop", "llvm.ctlz", "llvm.cttz",
-
+static const char *DoesntAccessMemoryFns[] = {
"abs", "labs", "llabs", "imaxabs", "fabs", "fabsf", "fabsl",
"trunc", "truncf", "truncl", "ldexp",
@@ -783,10 +778,8 @@ static const char *DoesntAccessMemoryTable[] = {
"__signbit", "__signbitf", "__signbitl",
};
-static const unsigned DAMTableSize =
- sizeof(DoesntAccessMemoryTable)/sizeof(DoesntAccessMemoryTable[0]);
-static const char *OnlyReadsMemoryTable[] = {
+static const char *OnlyReadsMemoryFns[] = {
"atoi", "atol", "atof", "atoll", "atoq", "a64l",
"bcmp", "memcmp", "memchr", "memrchr", "wmemcmp", "wmemchr",
@@ -810,34 +803,45 @@ static const char *OnlyReadsMemoryTable[] = {
"feof_unlocked", "ferror_unlocked", "fileno_unlocked"
};
-static const unsigned ORMTableSize =
- sizeof(OnlyReadsMemoryTable)/sizeof(OnlyReadsMemoryTable[0]);
-
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+
+ sizeof(DoesntAccessMemoryFns)/sizeof(DoesntAccessMemoryFns[0]));
+
+ OnlyReadsMemoryTable.insert(OnlyReadsMemoryTable.end(),
+ OnlyReadsMemoryFns,
+ OnlyReadsMemoryFns+
+ sizeof(OnlyReadsMemoryFns)/sizeof(OnlyReadsMemoryFns[0]));
+#define GET_MODREF_BEHAVIOR
+#include "llvm/Intrinsics.gen"
+#undef GET_MODREF_BEHAVIOR
+
// Sort the table the first time through.
- std::sort(DoesntAccessMemoryTable, DoesntAccessMemoryTable+DAMTableSize,
- StringCompare());
- std::sort(OnlyReadsMemoryTable, OnlyReadsMemoryTable+ORMTableSize,
+ std::sort(NoMemoryTable.begin(), NoMemoryTable.end(), StringCompare());
+ std::sort(OnlyReadsMemoryTable.begin(), OnlyReadsMemoryTable.end(),
StringCompare());
Initialized = true;
}
- const char **Ptr = std::lower_bound(DoesntAccessMemoryTable,
- DoesntAccessMemoryTable+DAMTableSize,
- F->getName().c_str(), StringCompare());
- if (Ptr != DoesntAccessMemoryTable+DAMTableSize && *Ptr == F->getName())
+ std::vector<const char*>::iterator Ptr =
+ std::lower_bound(NoMemoryTable.begin(), NoMemoryTable.end(),
+ F->getName().c_str(), StringCompare());
+ if (Ptr != NoMemoryTable.end() && *Ptr == F->getName())
return DoesNotAccessMemory;
- Ptr = std::lower_bound(OnlyReadsMemoryTable,
- OnlyReadsMemoryTable+ORMTableSize,
+ Ptr = std::lower_bound(OnlyReadsMemoryTable.begin(),
+ OnlyReadsMemoryTable.end(),
F->getName().c_str(), StringCompare());
- if (Ptr != OnlyReadsMemoryTable+ORMTableSize && *Ptr == F->getName())
+ if (Ptr != OnlyReadsMemoryTable.end() && *Ptr == F->getName())
return OnlyReadsMemory;
return UnknownModRefBehavior;