[llvm-commits] CVS: llvm/lib/Analysis/AliasSetTracker.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Jul 20 22:18:14 PDT 2004
Changes in directory llvm/lib/Analysis:
AliasSetTracker.cpp updated: 1.17 -> 1.18
---
Log message:
Make the AST interface a bit richer by returning whether an insertion caused
an insertion or not (because the pointer set already existed).
---
Diffs of the changes: (+32 -19)
Index: llvm/lib/Analysis/AliasSetTracker.cpp
diff -u llvm/lib/Analysis/AliasSetTracker.cpp:1.17 llvm/lib/Analysis/AliasSetTracker.cpp:1.18
--- llvm/lib/Analysis/AliasSetTracker.cpp:1.17 Sun Jul 4 07:19:55 2004
+++ llvm/lib/Analysis/AliasSetTracker.cpp Wed Jul 21 00:18:04 2004
@@ -189,7 +189,8 @@
/// getAliasSetForPointer - Return the alias set that the specified pointer
/// lives in...
-AliasSet &AliasSetTracker::getAliasSetForPointer(Value *Pointer, unsigned Size){
+AliasSet &AliasSetTracker::getAliasSetForPointer(Value *Pointer, unsigned Size,
+ bool *New) {
AliasSet::HashNodePair &Entry = getEntryFor(Pointer);
// Check to see if the pointer is already known...
@@ -201,6 +202,7 @@
AS->addPointer(*this, Entry, Size);
return *AS;
} else {
+ if (New) *New = true;
// Otherwise create a new alias set to hold the loaded pointer...
AliasSets.push_back(AliasSet());
AliasSets.back().addPointer(*this, Entry, Size);
@@ -208,45 +210,55 @@
}
}
-void AliasSetTracker::add(LoadInst *LI) {
- AliasSet &AS =
- addPointer(LI->getOperand(0),
- AA.getTargetData().getTypeSize(LI->getType()), AliasSet::Refs);
+bool AliasSetTracker::add(LoadInst *LI) {
+ bool NewPtr;
+ AliasSet &AS = addPointer(LI->getOperand(0),
+ AA.getTargetData().getTypeSize(LI->getType()),
+ AliasSet::Refs, NewPtr);
if (LI->isVolatile()) AS.setVolatile();
+ return NewPtr;
}
-void AliasSetTracker::add(StoreInst *SI) {
- AliasSet &AS =
- addPointer(SI->getOperand(1),
- AA.getTargetData().getTypeSize(SI->getOperand(0)->getType()),
- AliasSet::Mods);
+bool AliasSetTracker::add(StoreInst *SI) {
+ bool NewPtr;
+ Value *Val = SI->getOperand(0);
+ AliasSet &AS = addPointer(SI->getOperand(1),
+ AA.getTargetData().getTypeSize(Val->getType()),
+ AliasSet::Mods, NewPtr);
if (SI->isVolatile()) AS.setVolatile();
+ return NewPtr;
}
-void AliasSetTracker::add(CallSite CS) {
+bool AliasSetTracker::add(CallSite CS) {
+ bool NewPtr;
if (Function *F = CS.getCalledFunction())
if (AA.doesNotAccessMemory(F))
- return;
+ return true; // doesn't alias anything
AliasSet *AS = findAliasSetForCallSite(CS);
if (!AS) {
AliasSets.push_back(AliasSet());
AS = &AliasSets.back();
+ AS->addCallSite(CS, AA);
+ return true;
+ } else {
+ AS->addCallSite(CS, AA);
+ return false;
}
- AS->addCallSite(CS, AA);
}
-void AliasSetTracker::add(Instruction *I) {
+bool AliasSetTracker::add(Instruction *I) {
// Dispatch to one of the other add methods...
if (LoadInst *LI = dyn_cast<LoadInst>(I))
- add(LI);
+ return add(LI);
else if (StoreInst *SI = dyn_cast<StoreInst>(I))
- add(SI);
+ return add(SI);
else if (CallInst *CI = dyn_cast<CallInst>(I))
- add(CI);
+ return add(CI);
else if (InvokeInst *II = dyn_cast<InvokeInst>(I))
- add(II);
+ return add(II);
+ return true;
}
void AliasSetTracker::add(BasicBlock &BB) {
@@ -271,9 +283,10 @@
// Loop over all of the pointers in this alias set...
AliasSet::iterator I = AS.begin(), E = AS.end();
+ bool X;
for (; I != E; ++I)
addPointer(I->first, I->second.getSize(),
- (AliasSet::AccessType)AS.AccessTy);
+ (AliasSet::AccessType)AS.AccessTy, X);
}
}
More information about the llvm-commits
mailing list