LLVM: lib/CodeGen/GCMetadata.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
18#include
19#include
20#include
21
22using namespace llvm;
23
25 ModuleAnalysisManager::Invalidator &) {
26 for (const auto &F : M) {
27 if (F.isDeclaration() || .hasGC())
28 continue;
30 return true;
31 }
32 return false;
33}
34
35AnalysisKey CollectorMetadataAnalysis::Key;
36
40 for (auto &F : M) {
41 if (F.isDeclaration() || .hasGC())
42 continue;
44 auto [It, Inserted] = StrategyMap.try_emplace(GCName);
45 if (Inserted) {
47 It->second->Name = GCName;
48 }
49 }
50 return StrategyMap;
51}
52
54
57 assert(.isDeclaration() && "Can only get GCFunctionInfo for a definition!");
58 assert(F.hasGC() && "Function doesn't have GC!");
59
63 "This pass need module analysis `collector-metadata`!");
64 auto &Map =
66 GCStrategy &S = *Map.try_emplace(F.getGC()).first->second;
68 return Info;
69}
70
72 "Create Garbage Collector Module Metadata", false, true)
73
74
75
77 : F(F), S(S), FrameSize(~0LL) {}
78
80
82 FunctionAnalysisManager::Invalidator &) {
85}
86
87
88
90
94
96 assert(.isDeclaration() && "Can only get GCFunctionInfo for a definition!");
98
100 if (I != FInfoMap.end())
101 return *I->second;
102
104 Functions.push_back(std::make_unique(F, *S));
106 FInfoMap[&F] = GFI;
107 return *GFI;
108}
109
111 Functions.clear();
112 FInfoMap.clear();
113 GCStrategyList.clear();
114}
115
116
117
119
120 auto NMI = GCStrategyMap.find(Name);
121 if (NMI != GCStrategyMap.end())
122 return NMI->getValue();
123
125 S->Name = std::string(Name);
126 GCStrategyMap[Name] = S.get();
127 GCStrategyList.push_back(std::move(S));
128 return GCStrategyList.back().get();
129}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Analysis containing CSE Info
Module.h This file contains the declarations for the Module class.
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This templated class represents "all analyses that operate over " (e....
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
An analysis pass which caches information about the Function.
LLVM_ABI Result run(Function &F, FunctionAnalysisManager &FAM)
Definition GCMetadata.cpp:56
Garbage collection metadata for a single function.
LLVM_ABI ~GCFunctionInfo()
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation explicitly.
Definition GCMetadata.cpp:81
An analysis pass which caches information about the entire Module.
LLVM_ABI GCFunctionInfo & getFunctionInfo(const Function &F)
get - Look up function metadata.
Definition GCMetadata.cpp:95
LLVM_ABI void clear()
clear - Resets the pass.
Definition GCMetadata.cpp:110
LLVM_ABI GCStrategy * getGCStrategy(const StringRef Name)
Lookup the GCStrategy object associated with the given gc name.
Definition GCMetadata.cpp:118
LLVM_ABI GCModuleInfo()
Definition GCMetadata.cpp:91
std::pair< iterator, bool > try_emplace(StringRef GCName)
LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &Inv)
Handle invalidation explicitly.
Definition GCMetadata.cpp:24
bool contains(StringRef GCName) const
GCStrategy describes a garbage collector algorithm's code generation requirements,...
A Module instance is used to store all the information related to an LLVM module.
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
StringRef - Represent a constant reference to a string, i.e.
This is an optimization pass for GlobalISel generic memory operations.
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
LLVM_ABI void initializeGCModuleInfoPass(PassRegistry &)
LLVM_ABI std::unique_ptr< GCStrategy > getGCStrategy(const StringRef Name)
Lookup the GCStrategy object associated with the given gc name.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
A special type used by analysis passes to provide an address that identifies that particular analysis...