[all-commits] [llvm/llvm-project] f0ef70: [demangler][NFC] Utility header cleanups

Nathan Sidwell via All-commits all-commits at lists.llvm.org
Tue Feb 8 07:25:31 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f0ef708dc12eb7d3ec5d8af9abbae40bd27c07cd
      https://github.com/llvm/llvm-project/commit/f0ef708dc12eb7d3ec5d8af9abbae40bd27c07cd
  Author: Nathan Sidwell <nathan at acm.org>
  Date:   2022-02-08 (Tue, 08 Feb 2022)

  Changed paths:
    M libcxxabi/src/demangle/Utility.h
    M llvm/include/llvm/Demangle/Utility.h

  Log Message:
  -----------
  [demangler][NFC] Utility header cleanups

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.

Reviewed By: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D119176




More information about the All-commits mailing list