This is an archive of the discontinued LLVM Phabricator instance.

Avoid extra back reference key lookup in msmangler
ClosedPublic

Authored by K-ballo on Jun 12 2014, 5:12 PM.

Details

Summary

Avoid a second key lookup when the back reference key is going to be inserted in the StringMap. The string lookups in the msmangler are the main responsible for the huge overhead when compared to the itanium mangler. This patch makes a small but noticeable improvement.

Diff Detail

Event Timeline

K-ballo updated this revision to Diff 10375.Jun 12 2014, 5:12 PM
K-ballo retitled this revision from to Avoid extra back reference key lookup in msmangler.
K-ballo updated this object.
K-ballo edited the test plan for this revision. (Show Details)
K-ballo added reviewers: majnemer, timurrrr.
K-ballo added a subscriber: Unknown Object (MLST).
timurrrr edited edge metadata.Jun 15 2014, 6:05 AM

Looks good overall.

lib/AST/MicrosoftMangle.cpp
614

You probably want

std::tie(I, Inserted) = NameBackReferences.insert(...)

See MicrosoftCXXABI::getAddrOfVTable as an example.

673

Am I right that you need raw_svector_ostream just to use SmallString instead of string?

K-ballo added inline comments.Jun 15 2014, 11:53 AM
lib/AST/MicrosoftMangle.cpp
614

Indeed, the standard insert interface is what I would want. However, StringMap does not offer this interface, its insert member simply returns bool.

673

That is correct.

Is it hard to add that function to the interface?

K-ballo planned changes to this revision.Jun 15 2014, 12:58 PM
In D4130#6, @timurrrr wrote:

Is it hard to add that function to the interface?

It seems doable at first sight. I will try adding those insert overloads to StringMap.

I think that instead of introducing a new function I should just be using mangleSourceName. A template instantiation name is a source name too (considering anonymous type names are treated as source names), it's just that their terminating '@' is currently being added at the end of the template argument list. If the argument list no longer appends the '@', then they would be treated as any other source name.

K-ballo updated this revision to Diff 10800.Jun 24 2014, 11:54 AM
K-ballo updated this object.
K-ballo edited edge metadata.

Changes in this iteration:

  • Use the new StringMap::insert overload.
  • Template instantiation names are source names, mangle them as such.
rnk accepted this revision.Jun 25 2014, 2:12 PM
rnk added a reviewer: rnk.
rnk added a subscriber: rnk.

lgtm

Timur is on vacation. Do you need me to commit this for you?

This revision is now accepted and ready to land.Jun 25 2014, 2:12 PM
In D4130#13, @rnk wrote:

Do you need me to commit this for you?

Yes, please. Thank you.

rnk closed this revision.Jun 27 2014, 11:28 AM

Landed as rL211813. Not sure why phab didn't close this.