summaryrefslogtreecommitdiff
path: root/lib/Analysis/AliasSetTracker.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2007-12-01 07:51:45 +0000
committerDuncan Sands <baldrick@free.fr>2007-12-01 07:51:45 +0000
commitdff6710717b159f089c76a07eda074eb6347eb92 (patch)
tree7bbd754ebe64f5d4bbc6000e0e66bdd99f9c847f /lib/Analysis/AliasSetTracker.cpp
parente3110d0825e6316fd2dd21d6a4e593295cd413f1 (diff)
downloadllvm-dff6710717b159f089c76a07eda074eb6347eb92.tar.gz
llvm-dff6710717b159f089c76a07eda074eb6347eb92.tar.bz2
llvm-dff6710717b159f089c76a07eda074eb6347eb92.tar.xz
Integrate the readonly/readnone logic more deeply
into alias analysis. This meant updating the API which now has versions of the getModRefBehavior, doesNotAccessMemory and onlyReadsMemory methods which take a callsite parameter. These should be used unless the callsite is not known, since in general they can do a better job than the versions that take a function. Also, users should no longer call the version of getModRefBehavior that takes both a function and a callsite. To reduce the chance of misuse it is now protected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44487 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/AliasSetTracker.cpp')
-rw-r--r--lib/Analysis/AliasSetTracker.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp
index fcdd1b3399..1b20c7aebf 100644
--- a/lib/Analysis/AliasSetTracker.cpp
+++ b/lib/Analysis/AliasSetTracker.cpp
@@ -114,15 +114,13 @@ void AliasSet::addPointer(AliasSetTracker &AST, HashNodePair &Entry,
void AliasSet::addCallSite(CallSite CS, AliasAnalysis &AA) {
CallSites.push_back(CS);
- if (Function *F = CS.getCalledFunction()) {
- AliasAnalysis::ModRefBehavior Behavior = AA.getModRefBehavior(F, CS);
- if (Behavior == AliasAnalysis::DoesNotAccessMemory)
- return;
- else if (Behavior == AliasAnalysis::OnlyReadsMemory) {
- AliasTy = MayAlias;
- AccessTy |= Refs;
- return;
- }
+ AliasAnalysis::ModRefBehavior Behavior = AA.getModRefBehavior(CS);
+ if (Behavior == AliasAnalysis::DoesNotAccessMemory)
+ return;
+ else if (Behavior == AliasAnalysis::OnlyReadsMemory) {
+ AliasTy = MayAlias;
+ AccessTy |= Refs;
+ return;
}
// FIXME: This should use mod/ref information to make this not suck so bad
@@ -166,9 +164,8 @@ bool AliasSet::aliasesPointer(const Value *Ptr, unsigned Size,
}
bool AliasSet::aliasesCallSite(CallSite CS, AliasAnalysis &AA) const {
- if (Function *F = CS.getCalledFunction())
- if (AA.doesNotAccessMemory(F))
- return false;
+ if (AA.doesNotAccessMemory(CS))
+ return false;
if (AA.hasNoModRefInfoForCalls())
return true;
@@ -297,9 +294,8 @@ bool AliasSetTracker::add(FreeInst *FI) {
bool AliasSetTracker::add(CallSite CS) {
- if (Function *F = CS.getCalledFunction())
- if (AA.doesNotAccessMemory(F))
- return true; // doesn't alias anything
+ if (AA.doesNotAccessMemory(CS))
+ return true; // doesn't alias anything
AliasSet *AS = findAliasSetForCallSite(CS);
if (!AS) {
@@ -419,9 +415,8 @@ bool AliasSetTracker::remove(FreeInst *FI) {
}
bool AliasSetTracker::remove(CallSite CS) {
- if (Function *F = CS.getCalledFunction())
- if (AA.doesNotAccessMemory(F))
- return false; // doesn't alias anything
+ if (AA.doesNotAccessMemory(CS))
+ return false; // doesn't alias anything
AliasSet *AS = findAliasSetForCallSite(CS);
if (!AS) return false;
@@ -455,13 +450,10 @@ void AliasSetTracker::deleteValue(Value *PtrVal) {
// If this is a call instruction, remove the callsite from the appropriate
// AliasSet.
CallSite CS = CallSite::get(PtrVal);
- if (CS.getInstruction()) {
- Function *F = CS.getCalledFunction();
- if (!F || !AA.doesNotAccessMemory(F)) {
+ if (CS.getInstruction())
+ if (!AA.doesNotAccessMemory(CS))
if (AliasSet *AS = findAliasSetForCallSite(CS))
AS->removeCallSite(CS);
- }
- }
// First, look up the PointerRec for this pointer.
hash_map<Value*, AliasSet::PointerRec>::iterator I = PointerMap.find(PtrVal);