[PATCH] D44668: [demangler] WIP: Add a "partial" demangling API for LLDB

Erik Pilkington via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 20 12:11:31 PDT 2018


erik.pilkington added a subscriber: rafael.
erik.pilkington added a comment.

> It would be awesome if you could benchmark on some pathological testcases (e.g. the one Greg was pointing out)

As of r327690, the pathological symbol Greg posted is much smaller, due to a bug in how the demangler parsed generic lambda parameters. Now, partially demangling that symbol and getting the basename "Subscribe" is about 20x faster than fully demangling the name. Just for fun I removed the fix and benchmarked it again and it was more in the ballpark of hundreds of thousands of times faster. For more realistic symbols (test case being all the symbols in LLVM), partially demangling and extracting the basename runs in about 40% less time than fully demangling. Partially demangling and splitting up the entire name runs in about as long as the full demangle, but it should be faster if LLDB avoids parsing the demangled name. Depending on how LLDB is consuming these names, it might be profitable to do a first pass to find the base names of all the symbols in the program, then lazily demangle the other components as needed.

> Seems like it might be nice to replace all "char *Buf, size_t *N" arguments, where "char *" is returned with a llvm::raw_ostream and let the user use what ever backing / memory allocation scheme they want instead of forcing re-allocations? Probably best to include a person that has contributed to this file in the LLVM community so they can comment on the changes here.

@rafael: Any thoughts? I think it would be nice to use LLVM data structures to express this API and have the no-dependencies demangler live in libcxxabi.

Thanks!



================
Comment at: llvm/include/llvm/Demangle/Demangle.h:64
+  /// know this if the function has a cv or reference qualifier.
+  bool isProvablyMemberFunction() const;
+
----------------
clayborg wrote:
> s/provably/probably/ in comment and function name. Maybe "couldBeMemberFunction" might be a better name?
That wasn't a typo, this function checks if the name is for sure a non-static member function, so it conservatively returns false for `a::b()`. I suppose `isDefinitelyMemberFunction()` might be more clear.


Repository:
  rL LLVM

https://reviews.llvm.org/D44668





More information about the llvm-commits mailing list