LLVM  10.0.0svn
ScopedNoAliasAA.h
Go to the documentation of this file.
1 //===- ScopedNoAliasAA.h - Scoped No-Alias Alias Analysis -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
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/InstrTypes.h"
19 #include "llvm/IR/PassManager.h"
20 #include "llvm/Pass.h"
21 #include <memory>
22 
23 namespace llvm {
24 
25 class Function;
26 class MDNode;
27 class MemoryLocation;
28 
29 /// A simple AA result which uses scoped-noalias metadata to answer queries.
30 class ScopedNoAliasAAResult : public AAResultBase<ScopedNoAliasAAResult> {
32 
33 public:
34  /// Handle invalidation events from the new pass manager.
35  ///
36  /// By definition, this result is stateless and so remains valid.
39  return false;
40  }
41 
42  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
43  AAQueryInfo &AAQI);
44  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
45  AAQueryInfo &AAQI);
46  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
47  AAQueryInfo &AAQI);
48 
49 private:
50  bool mayAliasInScopes(const MDNode *Scopes, const MDNode *NoAlias) const;
51 };
52 
53 /// Analysis pass providing a never-invalidated alias analysis result.
54 class ScopedNoAliasAA : public AnalysisInfoMixin<ScopedNoAliasAA> {
56 
57  static AnalysisKey Key;
58 
59 public:
61 
63 };
64 
65 /// Legacy wrapper pass to provide the ScopedNoAliasAAResult object.
67  std::unique_ptr<ScopedNoAliasAAResult> Result;
68 
69 public:
70  static char ID;
71 
73 
74  ScopedNoAliasAAResult &getResult() { return *Result; }
75  const ScopedNoAliasAAResult &getResult() const { return *Result; }
76 
77  bool doInitialization(Module &M) override;
78  bool doFinalization(Module &M) override;
79  void getAnalysisUsage(AnalysisUsage &AU) const override;
80 };
81 
82 //===--------------------------------------------------------------------===//
83 //
84 // createScopedNoAliasAAWrapperPass - This pass implements metadata-based
85 // scoped noalias analysis.
86 //
88 
89 } // end namespace llvm
90 
91 #endif // LLVM_ANALYSIS_SCOPEDNOALIASAA_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
const ScopedNoAliasAAResult & getResult() const
This class stores info we want to provide to or retain within an alias query.
The two locations do not alias at all.
Definition: AliasAnalysis.h:84
Metadata node.
Definition: Metadata.h:863
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1100
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 alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI)
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:153
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:389
Represent the analysis usage information of a pass.
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:255
Analysis pass providing a never-invalidated alias analysis result.
ScopedNoAliasAAResult & getResult()
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:648
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc, AAQueryInfo &AAQI)
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:70