//
// The LLVM Compiler Infrastructure
//
-// This file was developed by Andrew Lenharth and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
std::set<const Value*> Vals;
public:
+ static char ID; // Class identification, replacement for typeinfo
+ AliasDebugger() : ModulePass(&ID) {}
+
bool runOnModule(Module &M) {
InitializeAliasAnalysis(this); // set up super class
for(Module::global_iterator I = M.global_begin(),
- E = M.global_end(); I != E; ++I)
+ E = M.global_end(); I != E; ++I) {
Vals.insert(&*I);
+ for (User::const_op_iterator OI = I->op_begin(),
+ OE = I->op_end(); OI != OE; ++OI)
+ Vals.insert(*OI);
+ }
for(Module::iterator I = M.begin(),
E = M.end(); I != E; ++I){
Vals.insert(&*I);
- if(!I->isExternal()) {
+ if(!I->isDeclaration()) {
for (Function::arg_iterator AI = I->arg_begin(), AE = I->arg_end();
AI != AE; ++AI)
Vals.insert(&*AI);
for (Function::const_iterator FI = I->begin(), FE = I->end();
FI != FE; ++FI)
for (BasicBlock::const_iterator BI = FI->begin(), BE = FI->end();
- BI != BE; ++BI)
+ BI != BE; ++BI) {
Vals.insert(&*BI);
+ for (User::const_op_iterator OI = BI->op_begin(),
+ OE = BI->op_end(); OI != OE; ++OI)
+ Vals.insert(*OI);
+ }
}
}
AU.setPreservesAll(); // Does not transform code
}
+ /// getAdjustedAnalysisPointer - This method is used when a pass implements
+ /// an analysis interface through multiple inheritance. If needed, it
+ /// should override this to adjust the this pointer as needed for the
+ /// specified pass info.
+ virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
+ if (PI->isPassID(&AliasAnalysis::ID))
+ return (AliasAnalysis*)this;
+ return this;
+ }
+
//------------------------------------------------
// Implement the AliasAnalysis API
//
return AliasAnalysis::getModRefInfo(CS1,CS2);
}
- void getMustAliases(Value *P, std::vector<Value*> &RetVals) {
- assert(Vals.find(P) != Vals.end() && "Never seen value in AA before");
- return AliasAnalysis::getMustAliases(P, RetVals);
- }
-
bool pointsToConstantMemory(const Value *P) {
assert(Vals.find(P) != Vals.end() && "Never seen value in AA before");
return AliasAnalysis::pointsToConstantMemory(P);
}
- /// getModRefBehavior - Return the behavior of the specified function if
- /// called from the specified call site. The call site may be null in which
- /// case the most generic behavior of this function should be returned.
- virtual ModRefBehavior getModRefBehavior(Function *F, CallSite CS,
- std::vector<PointerAccessInfo> *Info) {
- assert(Vals.find(F) != Vals.end() && "Never seen value in AA before");
- return AliasAnalysis::getModRefBehavior(F, CS, Info);
- }
-
virtual void deleteValue(Value *V) {
assert(Vals.find(V) != Vals.end() && "Never seen value in AA before");
AliasAnalysis::deleteValue(V);
}
};
-
- RegisterPass<AliasDebugger> X("debug-aa", "AA use debugger");
- RegisterAnalysisGroup<AliasAnalysis> Y(X);
}
+char AliasDebugger::ID = 0;
+static RegisterPass<AliasDebugger>
+X("debug-aa", "AA use debugger", false, true);
+static RegisterAnalysisGroup<AliasAnalysis> Y(X);
+
Pass *llvm::createAliasDebugger() { return new AliasDebugger(); }