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

[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

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from

Conversation

paperchalice
Copy link
Contributor

Convert this result into a flat-map like class, so AsmPrinter can iterate over this bidirectionally.


/// 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];
Copy link
Contributor

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?

Comment on lines 155 to +156
StringMap<std::unique_ptr<GCStrategy>> StrategyMap;
SmallVector<GCStrategy *, 1> StrategyList; // For bidirectional iterator.
Copy link
Contributor

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?

Copy link
Contributor Author

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:

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);

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.
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.