[PATCH] D62780: msabi: Fix exponential mangling time for even more contrived inputs
Nico Weber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 3 15:27:24 PDT 2019
thakis marked an inline comment as done.
thakis added inline comments.
================
Comment at: clang/lib/AST/MicrosoftMangle.cpp:819-823
ArgBackRefMap::iterator Found = TemplateArgBackReferences.find(ND);
if (Found == TemplateArgBackReferences.end()) {
- // Mangle full template name into temporary buffer.
- llvm::SmallString<64> TemplateMangling;
- llvm::raw_svector_ostream Stream(TemplateMangling);
- MicrosoftCXXNameMangler Extra(Context, Stream);
- Extra.mangleTemplateInstantiationName(TD, *TemplateArgs);
-
- // Use the string backref vector to possibly get a back reference.
- mangleSourceName(TemplateMangling);
-
- // Memoize back reference for this type.
- BackRefVec::iterator StringFound =
- llvm::find(NameBackReferences, TemplateMangling);
- if (StringFound != NameBackReferences.end()) {
- TemplateArgBackReferences[ND] =
- StringFound - NameBackReferences.begin();
+
+ TemplateArgStringMap::iterator Found = TemplateArgStrings.find(ND);
+ if (Found == TemplateArgStrings.end()) {
----------------
rnk wrote:
> Here's a thought: could we get by with one map? I think we can be certain that nothing mangles to integer literals between 0 and 9, since otherwise the demangler couldn't distinguish those from back references. So, can we keep the string map, and insert the string "0", "1", etc for back referenced things?
I had wondered too. In the end, I figured the int map needs less memory and is almost always enough, so I went with this approach.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62780/new/
https://reviews.llvm.org/D62780
More information about the cfe-commits
mailing list