1 //===- ScopedNoAliasAA.h - Scoped No-Alias Alias Analysis -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// This is the interface for a metadata-based scoped no-alias analysis.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ANALYSIS_SCOPEDNOALIASAA_H
15 #define LLVM_ANALYSIS_SCOPEDNOALIASAA_H
17 #include "llvm/Analysis/AliasAnalysis.h"
18 #include "llvm/IR/Function.h"
19 #include "llvm/IR/Metadata.h"
20 #include "llvm/IR/Module.h"
21 #include "llvm/Pass.h"
25 /// ScopedNoAliasAA - This is a simple alias analysis
26 /// implementation that uses scoped-noalias metadata to answer queries.
27 class ScopedNoAliasAA : public ImmutablePass, public AliasAnalysis {
29 static char ID; // Class identification, replacement for typeinfo
30 ScopedNoAliasAA() : ImmutablePass(ID) {
31 initializeScopedNoAliasAAPass(*PassRegistry::getPassRegistry());
34 bool doInitialization(Module &M) override;
36 /// getAdjustedAnalysisPointer - This method is used when a pass implements
37 /// an analysis interface through multiple inheritance. If needed, it
38 /// should override this to adjust the this pointer as needed for the
39 /// specified pass info.
40 void *getAdjustedAnalysisPointer(const void *PI) override {
41 if (PI == &AliasAnalysis::ID)
42 return (AliasAnalysis *)this;
47 bool mayAliasInScopes(const MDNode *Scopes, const MDNode *NoAlias) const;
48 void collectMDInDomain(const MDNode *List, const MDNode *Domain,
49 SmallPtrSetImpl<const MDNode *> &Nodes) const;
52 void getAnalysisUsage(AnalysisUsage &AU) const override;
53 AliasResult alias(const MemoryLocation &LocA,
54 const MemoryLocation &LocB) override;
55 bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) override;
56 FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS) override;
57 FunctionModRefBehavior getModRefBehavior(const Function *F) override;
58 ModRefInfo getModRefInfo(ImmutableCallSite CS,
59 const MemoryLocation &Loc) override;
60 ModRefInfo getModRefInfo(ImmutableCallSite CS1,
61 ImmutableCallSite CS2) override;
64 //===--------------------------------------------------------------------===//
66 // createScopedNoAliasAAPass - This pass implements metadata-based
67 // scoped noalias analysis.
69 ImmutablePass *createScopedNoAliasAAPass();