LLVM  14.0.0git
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/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<ScopedNoAliasAAResult> {
31 
32 public:
33  /// Handle invalidation events from the new pass manager.
34  ///
35  /// By definition, this result is stateless and so remains valid.
38  return false;
39  }
40 
41  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
42  AAQueryInfo &AAQI);
43  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
44  AAQueryInfo &AAQI);
45  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
46  AAQueryInfo &AAQI);
47 
48 private:
49  bool mayAliasInScopes(const MDNode *Scopes, const MDNode *NoAlias) const;
50 };
51 
52 /// Analysis pass providing a never-invalidated alias analysis result.
53 class ScopedNoAliasAA : public AnalysisInfoMixin<ScopedNoAliasAA> {
55 
56  static AnalysisKey Key;
57 
58 public:
60 
62 };
63 
64 /// Legacy wrapper pass to provide the ScopedNoAliasAAResult object.
66  std::unique_ptr<ScopedNoAliasAAResult> Result;
67 
68 public:
69  static char ID;
70 
72 
73  ScopedNoAliasAAResult &getResult() { return *Result; }
74  const ScopedNoAliasAAResult &getResult() const { return *Result; }
75 
76  bool doInitialization(Module &M) override;
77  bool doFinalization(Module &M) override;
78  void getAnalysisUsage(AnalysisUsage &AU) const override;
79 };
80 
81 //===--------------------------------------------------------------------===//
82 //
83 // createScopedNoAliasAAWrapperPass - This pass implements metadata-based
84 // scoped noalias analysis.
85 //
86 ImmutablePass *createScopedNoAliasAAWrapperPass();
87 
88 } // end namespace llvm
89 
90 #endif // LLVM_ANALYSIS_SCOPEDNOALIASAA_H
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm::ScopedNoAliasAA
Analysis pass providing a never-invalidated alias analysis result.
Definition: ScopedNoAliasAA.h:53
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::ScopedNoAliasAAWrapperPass::doInitialization
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
Definition: ScopedNoAliasAA.cpp:169
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:269
llvm::Function
Definition: Function.h:62
Pass.h
llvm::AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:82
llvm::ScopedNoAliasAAWrapperPass::getResult
const ScopedNoAliasAAResult & getResult() const
Definition: ScopedNoAliasAA.h:74
F
#define F(x, y, z)
Definition: MD5.cpp:56
AliasAnalysis.h
llvm::AAQueryInfo
This class stores info we want to provide to or retain within an alias query.
Definition: AliasAnalysis.h:459
llvm::ScopedNoAliasAAResult::getModRefInfo
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc, AAQueryInfo &AAQI)
Definition: ScopedNoAliasAA.cpp:76
llvm::ScopedNoAliasAAWrapperPass::doFinalization
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
Definition: ScopedNoAliasAA.cpp:174
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::ScopedNoAliasAAWrapperPass::ScopedNoAliasAAWrapperPass
ScopedNoAliasAAWrapperPass()
Definition: ScopedNoAliasAA.cpp:165
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:670
llvm::ScopedNoAliasAAResult::alias
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI)
Definition: ScopedNoAliasAA.cpp:55
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:72
llvm::ModRefInfo
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition: AliasAnalysis.h:149
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:906
llvm::AnalysisInfoMixin
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:397
llvm::ReplayInlineScope::Function
@ Function
llvm::ScopedNoAliasAAWrapperPass::getResult
ScopedNoAliasAAResult & getResult()
Definition: ScopedNoAliasAA.h:73
llvm::ScopedNoAliasAAResult
A simple AA result which uses scoped-noalias metadata to answer queries.
Definition: ScopedNoAliasAA.h:29
llvm::createScopedNoAliasAAWrapperPass
ImmutablePass * createScopedNoAliasAAWrapperPass()
PassManager.h
llvm::ScopedNoAliasAA::run
ScopedNoAliasAAResult run(Function &F, FunctionAnalysisManager &AM)
Definition: ScopedNoAliasAA.cpp:151
llvm::ScopedNoAliasAAWrapperPass
Legacy wrapper pass to provide the ScopedNoAliasAAResult object.
Definition: ScopedNoAliasAA.h:65
llvm::ScopedNoAliasAAResult::invalidate
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
Handle invalidation events from the new pass manager.
Definition: ScopedNoAliasAA.h:36
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1161
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::AAResultBase
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept.
Definition: AliasAnalysis.h:1131
llvm::ScopedNoAliasAAWrapperPass::ID
static char ID
Definition: ScopedNoAliasAA.h:69
llvm::MemoryLocation
Representation for a specific memory location.
Definition: MemoryLocation.h:209
llvm::ScopedNoAliasAAWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: ScopedNoAliasAA.cpp:179