Use mangled template instantiation name as key for back references. Templates have their own context for back references, so their mangling is always the same regardless of context. This avoids mangling template instantiations twice.
Diff Detail
Event Timeline
Efficiency.
I have been profiling the compilation of a heavily templated C++ code, for which name mangling is the dominant part. The Microsoft mangling implementation is about 4 times slower than the Itanium one for this particular case, and it's mainly due to mangling template instantiations twice. As far as I understand, there is no reason to have a back reference key different than the actual mangled name, and thus no reason to mangle template instantiations twice. After this particular change, the Microsoft mangling implementation is just about 2 times slower than the Itanium one.
No functionality change is intended by this patch. The test case at /cfe/trunk/test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp should be sufficient.
The change looks good -- it simplifies the code and makes it faster.
David,
Do you have a good way to make sure we don't regress other than commit-and-see-if-it-explodes?
lib/AST/MicrosoftMangle.cpp | ||
---|---|---|
673 | This variable is no longer used as just a key. |
This variable is no longer used as just a key.
Please use something like TemplateMangling or TDMangling instead?