Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 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 | |||
17 | #include "llvm/Analysis/AliasAnalysis.h" |
||
18 | #include "llvm/IR/PassManager.h" |
||
19 | #include "llvm/Pass.h" |
||
20 | #include <memory> |
||
21 | |||
22 | namespace llvm { |
||
23 | |||
24 | class Function; |
||
25 | class MDNode; |
||
26 | class MemoryLocation; |
||
27 | |||
28 | /// A simple AA result which uses scoped-noalias metadata to answer queries. |
||
29 | class ScopedNoAliasAAResult : public AAResultBase { |
||
30 | public: |
||
31 | /// Handle invalidation events from the new pass manager. |
||
32 | /// |
||
33 | /// By definition, this result is stateless and so remains valid. |
||
34 | bool invalidate(Function &, const PreservedAnalyses &, |
||
35 | FunctionAnalysisManager::Invalidator &) { |
||
36 | return false; |
||
37 | } |
||
38 | |||
39 | AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, |
||
40 | AAQueryInfo &AAQI, const Instruction *CtxI); |
||
41 | ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc, |
||
42 | AAQueryInfo &AAQI); |
||
43 | ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2, |
||
44 | AAQueryInfo &AAQI); |
||
45 | |||
46 | private: |
||
47 | bool mayAliasInScopes(const MDNode *Scopes, const MDNode *NoAlias) const; |
||
48 | }; |
||
49 | |||
50 | /// Analysis pass providing a never-invalidated alias analysis result. |
||
51 | class ScopedNoAliasAA : public AnalysisInfoMixin<ScopedNoAliasAA> { |
||
52 | friend AnalysisInfoMixin<ScopedNoAliasAA>; |
||
53 | |||
54 | static AnalysisKey Key; |
||
55 | |||
56 | public: |
||
57 | using Result = ScopedNoAliasAAResult; |
||
58 | |||
59 | ScopedNoAliasAAResult run(Function &F, FunctionAnalysisManager &AM); |
||
60 | }; |
||
61 | |||
62 | /// Legacy wrapper pass to provide the ScopedNoAliasAAResult object. |
||
63 | class ScopedNoAliasAAWrapperPass : public ImmutablePass { |
||
64 | std::unique_ptr<ScopedNoAliasAAResult> Result; |
||
65 | |||
66 | public: |
||
67 | static char ID; |
||
68 | |||
69 | ScopedNoAliasAAWrapperPass(); |
||
70 | |||
71 | ScopedNoAliasAAResult &getResult() { return *Result; } |
||
72 | const ScopedNoAliasAAResult &getResult() const { return *Result; } |
||
73 | |||
74 | bool doInitialization(Module &M) override; |
||
75 | bool doFinalization(Module &M) override; |
||
76 | void getAnalysisUsage(AnalysisUsage &AU) const override; |
||
77 | }; |
||
78 | |||
79 | //===--------------------------------------------------------------------===// |
||
80 | // |
||
81 | // createScopedNoAliasAAWrapperPass - This pass implements metadata-based |
||
82 | // scoped noalias analysis. |
||
83 | // |
||
84 | ImmutablePass *createScopedNoAliasAAWrapperPass(); |
||
85 | |||
86 | } // end namespace llvm |
||
87 | |||
88 | #endif // LLVM_ANALYSIS_SCOPEDNOALIASAA_H |