LLVM  8.0.1
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 //
10 /// \file
11 /// This is the interface for a metadata-based scoped no-alias analysis.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_ANALYSIS_SCOPEDNOALIASAA_H
16 #define LLVM_ANALYSIS_SCOPEDNOALIASAA_H
17 
19 #include "llvm/IR/InstrTypes.h"
20 #include "llvm/IR/PassManager.h"
21 #include "llvm/Pass.h"
22 #include <memory>
23 
24 namespace llvm {
25 
26 class Function;
27 class MDNode;
28 class MemoryLocation;
29 
30 /// A simple AA result which uses scoped-noalias metadata to answer queries.
31 class ScopedNoAliasAAResult : public AAResultBase<ScopedNoAliasAAResult> {
33 
34 public:
35  /// Handle invalidation events from the new pass manager.
36  ///
37  /// By definition, this result is stateless and so remains valid.
40  return false;
41  }
42 
43  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
44  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc);
45  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2);
46 
47 private:
48  bool mayAliasInScopes(const MDNode *Scopes, const MDNode *NoAlias) const;
49 };
50 
51 /// Analysis pass providing a never-invalidated alias analysis result.
52 class ScopedNoAliasAA : public AnalysisInfoMixin<ScopedNoAliasAA> {
54 
55  static AnalysisKey Key;
56 
57 public:
59 
61 };
62 
63 /// Legacy wrapper pass to provide the ScopedNoAliasAAResult object.
65  std::unique_ptr<ScopedNoAliasAAResult> Result;
66 
67 public:
68  static char ID;
69 
71 
72  ScopedNoAliasAAResult &getResult() { return *Result; }
73  const ScopedNoAliasAAResult &getResult() const { return *Result; }
74 
75  bool doInitialization(Module &M) override;
76  bool doFinalization(Module &M) override;
77  void getAnalysisUsage(AnalysisUsage &AU) const override;
78 };
79 
80 //===--------------------------------------------------------------------===//
81 //
82 // createScopedNoAliasAAWrapperPass - This pass implements metadata-based
83 // scoped noalias analysis.
84 //
86 
87 } // end namespace llvm
88 
89 #endif // LLVM_ANALYSIS_SCOPEDNOALIASAA_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
const ScopedNoAliasAAResult & getResult() const
The two locations do not alias at all.
Definition: AliasAnalysis.h:84
Metadata node.
Definition: Metadata.h:864
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1014
F(f)
ImmutablePass * createScopedNoAliasAAWrapperPass()
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...
Key
PAL metadata keys.
AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:78
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:154
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:383
Represent the analysis usage information of a pass.
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:256
Analysis pass providing a never-invalidated alias analysis result.
ScopedNoAliasAAResult & getResult()
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:642
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc)
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:71