56 class AliasScopeNode {
60 AliasScopeNode() : Node(0) {}
61 explicit AliasScopeNode(
const MDNode *
N) : Node(N) {}
64 const MDNode *getNode()
const {
return Node; }
67 const MDNode *getDomain()
const {
68 if (Node->getNumOperands() < 2)
70 return dyn_cast_or_null<MDNode>(Node->getOperand(1));
83 bool doInitialization(
Module &M)
override;
89 void *getAdjustedAnalysisPointer(
const void *PI)
override {
104 bool pointsToConstantMemory(
const MemoryLocation &Loc,
bool OrLocal)
override;
117 "Scoped NoAlias Alias Analysis",
false,
true,
false)
120 return new ScopedNoAliasAA();
123 bool ScopedNoAliasAA::doInitialization(
Module &M) {
135 ScopedNoAliasAA::collectMDInDomain(
const MDNode *
List,
const MDNode *Domain,
139 if (AliasScopeNode(MD).getDomain() == Domain)
144 ScopedNoAliasAA::mayAliasInScopes(
const MDNode *Scopes,
146 if (!Scopes || !NoAlias)
151 for (
unsigned i = 0, ie = NoAlias->
getNumOperands(); i != ie; ++i)
153 if (
const MDNode *Domain = AliasScopeNode(NAMD).getDomain())
158 for (
const MDNode *Domain : Domains) {
160 collectMDInDomain(NoAlias, Domain, NANodes);
161 collectMDInDomain(Scopes, Domain, ScopeNodes);
162 if (!ScopeNodes.
size())
166 bool FoundAll =
true;
167 for (
const MDNode *SMD : ScopeNodes)
168 if (!NANodes.
count(SMD)) {
192 if (!mayAliasInScopes(AScopes, BNoAlias))
195 if (!mayAliasInScopes(BScopes, ANoAlias))
202 bool ScopedNoAliasAA::pointsToConstantMemory(
const MemoryLocation &Loc,
213 ScopedNoAliasAA::getModRefBehavior(
const Function *
F) {
227 if (!mayAliasInScopes(
240 if (!mayAliasInScopes(
245 if (!mayAliasInScopes(
INITIALIZE_AG_PASS(ScopedNoAliasAA, AliasAnalysis,"scoped-noalias","Scoped NoAlias Alias Analysis", false, true, false) ImmutablePass *llvm
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
MDNode * Scope
The tag for alias scope specification (used with noalias).
A Module instance is used to store all the information related to an LLVM module. ...
InstrTy * getInstruction() const
unsigned getNumOperands() const
Return number of MDNode operands.
ModRefBehavior
ModRefBehavior - Summary of how a function affects memory in the program.
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
The two locations do not alias at all.
virtual bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal=false)
pointsToConstantMemory - If the specified memory location is known to be constant, return true.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
static cl::opt< bool > EnableScopedNoAlias("enable-scoped-noalias", cl::init(true))
ImmutablePass * createScopedNoAliasAAPass()
initializer< Ty > init(const Ty &Val)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
AliasResult
The possible results of an alias query.
Represent the analysis usage information of a pass.
virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS)
getModRefBehavior - Return the behavior when calling the given call site.
void initializeScopedNoAliasAAPass(PassRegistry &)
Representation for a specific memory location.
const MDOperand & getOperand(unsigned I) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
ImmutablePass class - This class is used to provide information that does not need to be run...
virtual AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Alias Queries...
Module.h This file contains the declarations for the Module class.
MDNode * getMetadata(unsigned KindID) const
getMetadata - Get the metadata of given kind attached to this Instruction.
ModRefResult getModRefInfo(const Instruction *I)
getModRefInfo - Return information about whether or not an instruction may read or write memory (with...
MDNode * NoAlias
The tag specifying the noalias scope.
void setPreservesAll()
Set by analyses that do not transform their input at all.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
AAMDNodes AATags
The metadata nodes which describes the aliasing of the location (each member is null if that kind of ...
ImmutableCallSite - establish a view to a call site for examination.
ModRefResult
Simple mod/ref information...
virtual void getAnalysisUsage(AnalysisUsage &AU) const
getAnalysisUsage - All alias analysis implementations should invoke this directly (using AliasAnalysi...