Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e3b7620

Browse filesBrowse files
committed
[GC] Use MapVector for GCStrategyMap
Use `MapVector`, so `GCStrategyMap` can support forward and reverse iterator, which is required in `AsmPrinter`.
1 parent cf0efb3 commit e3b7620
Copy full SHA for e3b7620

File tree

2 files changed

+9
-10
lines changed
Filter options

2 files changed

+9
-10
lines changed

‎llvm/include/llvm/CodeGen/GCMetadata.h

Copy file name to clipboardExpand all lines: llvm/include/llvm/CodeGen/GCMetadata.h
+4-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define LLVM_CODEGEN_GCMETADATA_H
3434

3535
#include "llvm/ADT/DenseMap.h"
36+
#include "llvm/ADT/MapVector.h"
3637
#include "llvm/ADT/SmallVector.h"
3738
#include "llvm/ADT/StringMap.h"
3839
#include "llvm/ADT/StringRef.h"
@@ -151,9 +152,9 @@ class GCFunctionInfo {
151152
size_t live_size(const iterator &p) const { return roots_size(); }
152153
};
153154

154-
struct GCStrategyMap {
155-
StringMap<std::unique_ptr<GCStrategy>> StrategyMap;
156-
155+
class GCStrategyMap : public MapVector<std::string, std::unique_ptr<GCStrategy>,
156+
StringMap<unsigned>> {
157+
public:
157158
GCStrategyMap() = default;
158159
GCStrategyMap(GCStrategyMap &&) = default;
159160

‎llvm/lib/CodeGen/GCMetadata.cpp

Copy file name to clipboardExpand all lines: llvm/lib/CodeGen/GCMetadata.cpp
+5-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bool GCStrategyMap::invalidate(Module &M, const PreservedAnalyses &PA,
2626
for (const auto &F : M) {
2727
if (F.isDeclaration() || !F.hasGC())
2828
continue;
29-
if (!StrategyMap.contains(F.getGC()))
29+
if (!contains(F.getGC()))
3030
return true;
3131
}
3232
return false;
@@ -36,17 +36,16 @@ AnalysisKey CollectorMetadataAnalysis::Key;
3636

3737
CollectorMetadataAnalysis::Result
3838
CollectorMetadataAnalysis::run(Module &M, ModuleAnalysisManager &MAM) {
39-
Result R;
40-
auto &Map = R.StrategyMap;
39+
Result StrategyMap;
4140
for (auto &F : M) {
4241
if (F.isDeclaration() || !F.hasGC())
4342
continue;
4443
auto GCName = F.getGC();
45-
auto [It, Inserted] = Map.try_emplace(GCName);
44+
auto [It, Inserted] = StrategyMap.try_emplace(GCName);
4645
if (Inserted)
4746
It->second = getGCStrategy(GCName);
4847
}
49-
return R;
48+
return StrategyMap;
5049
}
5150

5251
AnalysisKey GCFunctionAnalysis::Key;
@@ -61,8 +60,7 @@ GCFunctionAnalysis::run(Function &F, FunctionAnalysisManager &FAM) {
6160
MAMProxy.cachedResultExists<CollectorMetadataAnalysis>(*F.getParent()) &&
6261
"This pass need module analysis `collector-metadata`!");
6362
auto &Map =
64-
MAMProxy.getCachedResult<CollectorMetadataAnalysis>(*F.getParent())
65-
->StrategyMap;
63+
*MAMProxy.getCachedResult<CollectorMetadataAnalysis>(*F.getParent());
6664
GCFunctionInfo Info(F, *Map[F.getGC()]);
6765
return Info;
6866
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.