Skip to content

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

struct GCStrategyMap {
class GCStrategyMap {
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

2 participants