-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[GC] Support bidirectional iterator in GCStrategyMap #99316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
||
/// Insert a new strategy if it is not existed, otherwise do nothing. | ||
void insert(StringRef Name, std::unique_ptr<GCStrategy> Strategy) { | ||
auto &S = StrategyMap[Name]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use insert and check if insert succeeded?
StringMap<std::unique_ptr<GCStrategy>> StrategyMap; | ||
SmallVector<GCStrategy *, 1> StrategyList; // For bidirectional iterator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a set vector?
Not really sure why these need indexing by name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a flat map here:
llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Lines 521 to 525 in 3b78dfa
GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>(); | |
assert(MI && "AsmPrinter didn't require GCModuleInfo?"); | |
for (const auto &I : *MI) | |
if (GCMetadataPrinter *MP = getOrCreateGCPrinter(*I)) | |
MP->beginAssembly(M, *MI, *this); |
llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Lines 2469 to 2471 in 3b78dfa
for (GCModuleInfo::iterator I = MI->end(), E = MI->begin(); I != E; ) | |
if (GCMetadataPrinter *MP = getOrCreateGCPrinter(**--I)) | |
MP->finishAssembly(M, *MI, *this); |
Indexed by name here because GC printers need it (see
OCamlGCPrinter.cpp
).
StringMap<std::unique_ptr<GCStrategy>> StrategyMap; | ||
SmallVector<GCStrategy *, 1> StrategyList; // For bidirectional iterator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How many entries will this have? 1? 2? Can it just get rid of the map?
Convert this result into a flat-map like class, so
AsmPrinter
can iterate over this bidirectionally.