LLVM  4.0.0
ScopedNoAliasAA.h
Go to the documentation of this file.
1 //===- ScopedNoAliasAA.h - Scoped No-Alias Alias Analysis -------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 /// This is the interface for a metadata-based scoped no-alias analysis.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_ANALYSIS_SCOPEDNOALIASAA_H
15 #define LLVM_ANALYSIS_SCOPEDNOALIASAA_H
16 
18 #include "llvm/IR/Function.h"
19 #include "llvm/IR/Metadata.h"
20 #include "llvm/IR/Module.h"
21 #include "llvm/Pass.h"
22 
23 namespace llvm {
24 
25 /// A simple AA result which uses scoped-noalias metadata to answer queries.
26 class ScopedNoAliasAAResult : public AAResultBase<ScopedNoAliasAAResult> {
28 
29 public:
30  /// Handle invalidation events from the new pass manager.
31  ///
32  /// By definition, this result is stateless and so remains valid.
35  return false;
36  }
37 
38  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
41 
42 private:
43  bool mayAliasInScopes(const MDNode *Scopes, const MDNode *NoAlias) const;
44 };
45 
46 /// Analysis pass providing a never-invalidated alias analysis result.
47 class ScopedNoAliasAA : public AnalysisInfoMixin<ScopedNoAliasAA> {
49  static AnalysisKey Key;
50 
51 public:
53 
55 };
56 
57 /// Legacy wrapper pass to provide the ScopedNoAliasAAResult object.
59  std::unique_ptr<ScopedNoAliasAAResult> Result;
60 
61 public:
62  static char ID;
63 
65 
66  ScopedNoAliasAAResult &getResult() { return *Result; }
67  const ScopedNoAliasAAResult &getResult() const { return *Result; }
68 
69  bool doInitialization(Module &M) override;
70  bool doFinalization(Module &M) override;
71  void getAnalysisUsage(AnalysisUsage &AU) const override;
72 };
73 
74 //===--------------------------------------------------------------------===//
75 //
76 // createScopedNoAliasAAWrapperPass - This pass implements metadata-based
77 // scoped noalias analysis.
78 //
79 ImmutablePass *createScopedNoAliasAAWrapperPass();
80 }
81 
82 #endif
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
This file contains the declarations for metadata subclasses.
Metadata node.
Definition: Metadata.h:830
The two locations do not alias at all.
Definition: AliasAnalysis.h:79
ImmutablePass * createScopedNoAliasAAWrapperPass()
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition: AliasAnalysis.h:94
A simple AA result which uses scoped-noalias metadata to answer queries.
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
Handle invalidation events from the new pass manager.
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept...
#define F(x, y, z)
Definition: MD5.cpp:51
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
Legacy wrapper pass to provide the ScopedNoAliasAAResult object.
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:107
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:328
AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:73
Represent the analysis usage information of a pass.
ScopedNoAliasAAResult Result
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Representation for a specific memory location.
ImmutablePass class - This class is used to provide information that does not need to be run...
Definition: Pass.h:266
Module.h This file contains the declarations for the Module class.
Analysis pass providing a never-invalidated alias analysis result.
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:665
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
ScopedNoAliasAAResult & getResult()
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:525
A container for analyses that lazily runs them and caches their results.
const ScopedNoAliasAAResult & getResult() const
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:64
ScopedNoAliasAAResult run(Function &F, FunctionAnalysisManager &AM)