[PATCH] D126061: [clang] Reject non-declaration C++11 attributes on declarations

Martin Böhme via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 17 13:24:09 PDT 2022


mboehme added a comment.

In D126061#3585681 <https://reviews.llvm.org/D126061#3585681>, @nikic wrote:

> FYI this change had a measurable effect on compile-time (http://llvm-compile-time-tracker.com/compare.php?from=7acc88be0312c721bc082ed9934e381d297f4707&to=8c7b64b5ae2a09027c38db969a04fc9ddd0cd6bb&stat=instructions), about 0.5% regression for `O0` builds. Not sure if that's expected.

I've found the reason for this slowdown, and a fix.

In a number of places, this patch adds additional local variables of type `ParsedAttributes`, typically because we need to keep track of declaration and decl-specifier-seq attributes in two separate `ParsedAttribute` lists where previously we were putting them in the same list. Note that in the vast majority of cases, these `ParsedAttributes` lists are empty.

I would have assumed that creating an empty `ParsedAttributes`, potentially iterating over it, then destroying it, is cheap. However, this is not true for `ParsedAttributes` because it uses a `TinyPtrVector` as the underlying container. The same is true for the `AttributePool` that `ParsedAttributes` contains.

`TinyPtrVector` is amazingly memory-frugal in that it consumes only a single pointer worth of memory if the vector contains zero or one elements. However, this comes at a cost: `begin()` and `end()` on this container are relatively expensive. As a result, iterating over an empty `TinyPtrVector`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126061/new/

https://reviews.llvm.org/D126061



More information about the cfe-commits mailing list