[PATCH] D119176: [demangler][NFC] Utility header cleanups

Nathan Sidwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 7 12:14:00 PST 2022


urnathan created this revision.
urnathan added reviewers: ChuanqiXu, iains, bruno, aaron.ballman.
Herald added a subscriber: pengfei.
urnathan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

A few items I came across ...

a) Using a do...while loop in the number formatter means we do not have to special case zero.

b) Let's use 'if (auto size = ...) {}' for appending to the output buffer.

c) We should also be using memcpy there, not memmove -- the string being appended is never part of the current buffer.

d) Let's put all the operator<< functions together.

e) I find 'if (cond) frob(..., true) ; elseOD frob(..., false)' somewhat confusing.  Let's just use std::abs in the signed integer printer and let CSE decide about the duplicate < 0 testing.

f) Let's have as many as possible return *this.  That's both more consistent, and allows tailcalls in some cases (the actual number formatter has a local array though).

These changes removed around 100 bytes from the demangler's instructions on x86_64.


https://reviews.llvm.org/D119176

Files:
  libcxxabi/src/demangle/Utility.h
  llvm/include/llvm/Demangle/Utility.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119176.406558.patch
Type: text/x-patch
Size: 4532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220207/ec610811/attachment.bin>


More information about the llvm-commits mailing list