LLVM 24.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"
21#include <memory>
22
23namespace llvm {
24
25struct AnalysisOptions;
26class FenceInst;
27class Function;
28class LLVMContext;
29class MDNode;
30class MemoryLocation;
31
32/// A simple AA result which uses scoped-noalias metadata to answer queries.
34 const AnalysisOptions &Opts;
35
36public:
38
39 /// Handle invalidation events from the new pass manager.
40 ///
41 /// By definition, this result is stateless and so remains valid.
43 FunctionAnalysisManager::Invalidator &) {
44 return false;
45 }
46
48 const MemoryLocation &LocB);
50 const MemoryLocation &LocB, AAQueryInfo &,
51 const Instruction *);
53 const MemoryLocation &Loc,
54 AAQueryInfo &AAQI);
56 const CallBase *Call2, AAQueryInfo &AAQI);
58 const MemoryLocation &Loc,
59 AAQueryInfo &AAQI);
60
61 LLVM_ABI static void
62 collectScopedDomains(const MDNode *NoAlias,
64 bool DisjointOnly = false);
65
66 LLVM_ABI static bool mayAliasInScopes(const MDNode *Scopes,
67 const MDNode *NoAlias);
68
69 /// Return false if two accesses with scope lists \p Scopes1 and \p Scopes2
70 /// are kept apart because they use different scopes of a disjoint-scope
71 /// domain.
72 LLVM_ABI static bool mayAliasInDisjointDomains(const MDNode *Scopes1,
73 const MDNode *Scopes2);
74};
75
76/// Analysis pass providing a never-invalidated alias analysis result.
87
88/// Legacy wrapper pass to provide the ScopedNoAliasAAResult object.
90 std::unique_ptr<ScopedNoAliasAAResult> Result;
91
92public:
93 static char ID;
94
96
97 ScopedNoAliasAAResult &getResult() { return *Result; }
98 const ScopedNoAliasAAResult &getResult() const { return *Result; }
99
100 bool doInitialization(Module &M) override;
101 bool doFinalization(Module &M) override;
102 void getAnalysisUsage(AnalysisUsage &AU) const override;
103};
104
105//===--------------------------------------------------------------------===//
106//
107// createScopedNoAliasAAWrapperPass - This pass implements metadata-based
108// scoped noalias analysis.
109//
111
112} // end namespace llvm
113
114#endif // LLVM_ANALYSIS_SCOPEDNOALIASAA_H
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_ABI
Definition Compiler.h:211
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:54
This class stores info we want to provide to or retain within an alias query.
AAResultBase()=default
The possible results of an alias query.
Represent the analysis usage information of a pass.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
An instruction for ordering other memory operations.
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition Pass.h:283
ImmutablePass(char &pid)
Definition Pass.h:285
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:76
Metadata node.
Definition Metadata.h:1081
Representation for a specific memory location.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
A simple AA result which uses scoped-noalias metadata to answer queries.
static LLVM_ABI bool mayAliasInScopes(const MDNode *Scopes, const MDNode *NoAlias)
LLVM_ABI AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
Handle invalidation events from the new pass manager.
LLVM_ABI ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc, AAQueryInfo &AAQI)
LLVM_ABI ScopedNoAliasAAResult(const LLVMContext &C)
static LLVM_ABI void collectScopedDomains(const MDNode *NoAlias, SmallPtrSetImpl< const MDNode * > &Domains, bool DisjointOnly=false)
Collect the set of scoped domains relevant to the noalias scopes.
static LLVM_ABI bool mayAliasInDisjointDomains(const MDNode *Scopes1, const MDNode *Scopes2)
Return false if two accesses with scope lists Scopes1 and Scopes2 are kept apart because they use dif...
ScopedNoAliasAAResult & getResult()
const ScopedNoAliasAAResult & getResult() const
Analysis pass providing a never-invalidated alias analysis result.
LLVM_ABI ScopedNoAliasAAResult run(Function &F, FunctionAnalysisManager &AM)
ScopedNoAliasAAResult Result
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
CallInst * Call
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI ImmutablePass * createScopedNoAliasAAWrapperPass()
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition ModRef.h:28
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29