2010-10-19 23:09:08 +00:00
|
|
|
//===- NoAliasAnalysis.cpp - Minimal Alias Analysis Impl ------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the default implementation of the Alias Analysis interface
|
|
|
|
// that simply returns "I don't know" for all queries.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Analysis/Passes.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/Analysis/AliasAnalysis.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/DataLayout.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/Pass.h"
|
2010-10-19 23:09:08 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
/// NoAA - This class implements the -no-aa pass, which always returns "I
|
|
|
|
/// don't know" for alias queries. NoAA is unlike other alias analysis
|
|
|
|
/// implementations, in that it does not chain to a previous analysis. As
|
|
|
|
/// such it doesn't follow many of the rules that other alias analyses must.
|
|
|
|
///
|
|
|
|
struct NoAA : public ImmutablePass, public AliasAnalysis {
|
|
|
|
static char ID; // Class identification, replacement for typeinfo
|
|
|
|
NoAA() : ImmutablePass(ID) {
|
|
|
|
initializeNoAAPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void initializePass() {
|
|
|
|
// Note: NoAA does not call InitializeAliasAnalysis because it's
|
|
|
|
// special and does not support chaining.
|
2012-10-08 16:38:25 +00:00
|
|
|
TD = getAnalysisIfAvailable<DataLayout>();
|
2010-10-19 23:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual AliasResult alias(const Location &LocA, const Location &LocB) {
|
|
|
|
return MayAlias;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS) {
|
|
|
|
return UnknownModRefBehavior;
|
|
|
|
}
|
|
|
|
virtual ModRefBehavior getModRefBehavior(const Function *F) {
|
|
|
|
return UnknownModRefBehavior;
|
|
|
|
}
|
|
|
|
|
2010-11-08 16:45:26 +00:00
|
|
|
virtual bool pointsToConstantMemory(const Location &Loc,
|
|
|
|
bool OrLocal) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-10-19 23:09:08 +00:00
|
|
|
virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
|
|
|
|
const Location &Loc) {
|
|
|
|
return ModRef;
|
|
|
|
}
|
|
|
|
virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
|
|
|
|
ImmutableCallSite CS2) {
|
|
|
|
return ModRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void deleteValue(Value *V) {}
|
|
|
|
virtual void copyValue(Value *From, Value *To) {}
|
2011-01-03 23:51:43 +00:00
|
|
|
virtual void addEscapingUse(Use &U) {}
|
2010-10-19 23:09:08 +00:00
|
|
|
|
|
|
|
/// 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 void *ID) {
|
|
|
|
if (ID == &AliasAnalysis::ID)
|
|
|
|
return (AliasAnalysis*)this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // End of anonymous namespace
|
|
|
|
|
|
|
|
// Register this pass...
|
|
|
|
char NoAA::ID = 0;
|
|
|
|
INITIALIZE_AG_PASS(NoAA, AliasAnalysis, "no-aa",
|
|
|
|
"No Alias Analysis (always returns 'may' alias)",
|
|
|
|
true, true, true)
|
|
|
|
|
|
|
|
ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }
|