diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2007-08-06 20:57:16 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2007-08-06 20:57:16 +0000 |
commit | a583990ec83a4773608084a9694943ddd268e571 (patch) | |
tree | 0003775900ff0a0121087c0aff4d76e98679290c | |
parent | b1183c1ff3b17689c036d5e7443b7343074d2f6f (diff) | |
download | external_llvm-a583990ec83a4773608084a9694943ddd268e571.zip external_llvm-a583990ec83a4773608084a9694943ddd268e571.tar.gz external_llvm-a583990ec83a4773608084a9694943ddd268e571.tar.bz2 |
This resolves a regression of BasicAA which failed to find any memory information for overloaded intrinsics (PR1600). This resolves that issue, and improves the matching scheme to use a BitVector rather than a binary search.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40872 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 27 | ||||
-rw-r--r-- | test/Analysis/BasicAA/2007-08-05-GetOverloadedModRef.ll | 17 | ||||
-rw-r--r-- | utils/TableGen/IntrinsicEmitter.cpp | 4 |
3 files changed, 42 insertions, 6 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index a1bf69e..c4aa3b5 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -21,10 +21,12 @@ #include "llvm/ParameterAttributes.h" #include "llvm/GlobalVariable.h" #include "llvm/Instructions.h" +#include "llvm/Intrinsics.h" #include "llvm/Pass.h" #include "llvm/Target/TargetData.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/BitVector.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/ManagedStatic.h" @@ -874,6 +876,9 @@ static const char *OnlyReadsMemoryFns[] = { static ManagedStatic<std::vector<const char*> > NoMemoryTable; static ManagedStatic<std::vector<const char*> > OnlyReadsMemoryTable; +static ManagedStatic<BitVector> NoMemoryIntrinsics; +static ManagedStatic<BitVector> OnlyReadsMemoryIntrinsics; + AliasAnalysis::ModRefBehavior BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS, @@ -891,16 +896,30 @@ BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS, 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(NoMemoryTable->begin(), NoMemoryTable->end(), StringCompare()); std::sort(OnlyReadsMemoryTable->begin(), OnlyReadsMemoryTable->end(), StringCompare()); + + NoMemoryIntrinsics->resize(Intrinsic::num_intrinsics); + OnlyReadsMemoryIntrinsics->resize(Intrinsic::num_intrinsics); +#define GET_MODREF_BEHAVIOR +#include "llvm/Intrinsics.gen" +#undef GET_MODREF_BEHAVIOR + Initialized = true; } + + // If this is an intrinsic, we can use lookup tables + if (unsigned id = F->getIntrinsicID()) { + if (NoMemoryIntrinsics->test(id)) + return DoesNotAccessMemory; + if (OnlyReadsMemoryIntrinsics->test(id)) + return OnlyReadsMemory; + + return UnknownModRefBehavior; + } ValueName *Name = F->getValueName(); unsigned NameLen = Name->getKeyLength(); diff --git a/test/Analysis/BasicAA/2007-08-05-GetOverloadedModRef.ll b/test/Analysis/BasicAA/2007-08-05-GetOverloadedModRef.ll new file mode 100644 index 0000000..c555f63 --- /dev/null +++ b/test/Analysis/BasicAA/2007-08-05-GetOverloadedModRef.ll @@ -0,0 +1,17 @@ +; PR1600 +; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | \ +; RUN: grep {ret i32 0} +; END. + +declare i16 @llvm.cttz.i16(i16) + +define i32 @test(i32* %P, i16* %Q) { + %A = load i16* %Q ; <i16> [#uses=1] + %x = load i32* %P ; <i32> [#uses=1] + %B = call i16 @llvm.cttz.i16( i16 %A ) ; <i16> [#uses=1] + %y = load i32* %P ; <i32> [#uses=1] + store i16 %B, i16* %Q + %z = sub i32 %x, %y ; <i32> [#uses=1] + ret i32 %z +} + diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index ebc0c32..f5df933 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -299,11 +299,11 @@ void IntrinsicEmitter::EmitModRefInfo(const std::vector<CodeGenIntrinsic> &Ints, switch (Ints[i].ModRef) { default: break; case CodeGenIntrinsic::NoMem: - OS << " NoMemoryTable->push_back(\"" << Ints[i].Name << "\");\n"; + OS << " NoMemoryIntrinsics->set(Intrinsic::" << Ints[i].EnumName << ");\n"; break; case CodeGenIntrinsic::ReadArgMem: case CodeGenIntrinsic::ReadMem: - OS << " OnlyReadsMemoryTable->push_back(\"" << Ints[i].Name << "\");\n"; + OS << " OnlyReadsMemoryIntrinsics->set(Intrinsic::" << Ints[i].EnumName << ");\n"; break; } } |