llvm-project/clang/lib/Basic
Bruno Ricci 366ba73018 [AST] Various optimizations + refactoring in DeclarationName(Table)
Introduce the following optimizations in DeclarationName(Table):

 1. Store common kinds inline in DeclarationName instead of
    DeclarationNameExtra. Currently the kind of C++ constructor, destructor,
    conversion function and overloaded operator names is stored in
    DeclarationNameExtra. Instead store it inline in DeclarationName.
    To do this align IdentifierInfo, CXXSpecialName, DeclarationNameExtra
    and CXXOperatorIdName to 8 bytes so that we can use the lower 3 bits of
    DeclarationName::Ptr. This is already the case on 64 bits archs anyway.
    This also allow us to remove DeclarationNameExtra from CXXSpecialName
    and CXXOperatorIdName, which shave off a pointer from CXXSpecialName. 

 2. Synchronize the enumerations DeclarationName::NameKind,
    DeclarationName::StoredNameKind and Selector::IdentifierInfoFlag.
    This makes DeclarationName::getNameKind much more efficient since we can
    replace the switch table by a single comparison and an addition.

 3. Put the overloaded operator names inline in DeclarationNameTable to remove
    an indirection. This increase the size of DeclarationNameTable a little
    bit but this is not important since it is only used in ASTContext, and
    never copied nor moved from. This also get rid of the last dynamic
    allocation in DeclarationNameTable.

Altogether these optimizations cut the run time of parsing all of Boost by
about 0.8%. While we are at it, do the following NFC modifications:

 1. Put the internal classes CXXSpecialName, CXXDeductionGuideNameExtra,
    CXXOperatorIdName, CXXLiteralOperatorIdName and DeclarationNameExtra
    in a namespace detail since these classes are only meant to be used by
    DeclarationName and DeclarationNameTable. Make this more explicit by making
    the members of these classes private and friending DeclarationName(Table).

 2. Make DeclarationName::getFETokenInfo a non-template since every users are
    using it to get a void *. It was supposed to be used with a type to avoid
    a subsequent static_cast.

 3. Change the internal functions DeclarationName::getAs* to castAs* since when
    we use them we already know the correct kind. This has no external impact
    since all of these are private.

Reviewed By: erichkeane, rjmccall

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

llvm-svn: 342729
2018-09-21 12:53:22 +00:00
..
Targets Basic: correct `__WINT_TYPE__` on Windows 2018-09-19 16:18:55 +00:00
Attributes.cpp Add #pragma clang attribute 2017-04-18 14:33:39 +00:00
Builtins.cpp [Builtins][Attributes][X86] Tag all X86 builtins with their required vector width. Add a min_vector_width function attribute and tag all x86 instrinsics with it 2018-07-09 19:00:16 +00:00
CMakeLists.txt [Fixed Point Arithmetic] Fixed Point Constant 2018-08-06 16:42:37 +00:00
CharInfo.cpp
Cuda.cpp [CUDA] Enable CUDA compilation with CUDA-9.2 2018-04-24 18:23:19 +00:00
Diagnostic.cpp Add a newline to SourceLocation dump output 2018-08-15 20:32:06 +00:00
DiagnosticIDs.cpp Remove trailing space 2018-07-30 19:24:48 +00:00
DiagnosticOptions.cpp [Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2018-02-16 23:40:07 +00:00
FileManager.cpp Fix build bot after r340598. 2018-08-24 09:53:44 +00:00
FileSystemStatCache.cpp Remove trailing space 2018-07-30 19:24:48 +00:00
FixedPoint.cpp Fix for broken build on clang-hexagon-elf for ambiguous call to 2018-08-06 19:31:00 +00:00
IdentifierTable.cpp [AST] Various optimizations + refactoring in DeclarationName(Table) 2018-09-21 12:53:22 +00:00
LangOptions.cpp [OpenCL] Factor out language version printing 2018-05-08 13:47:43 +00:00
MemoryBufferCache.cpp Reapply "Modules: Cache PCMs in memory and avoid a use-after-free" 2017-03-20 17:58:26 +00:00
Module.cpp [Modules] Add platform and environment features to requires clause 2018-09-18 17:11:13 +00:00
ObjCRuntime.cpp Remove trailing space 2018-07-30 19:24:48 +00:00
OpenMPKinds.cpp Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
OperatorPrecedence.cpp Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
SanitizerBlacklist.cpp Allow specifying sanitizers in blacklists 2017-09-25 22:11:12 +00:00
SanitizerSpecialCaseList.cpp Update SanitizerSpecialCaseList to use renamed functions in base class. 2017-11-07 21:16:37 +00:00
Sanitizers.cpp [Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2018-03-28 22:09:09 +00:00
SourceLocation.cpp Add dump() method for SourceRange 2018-08-30 23:10:52 +00:00
SourceManager.cpp Remove trailing space 2018-07-30 19:24:48 +00:00
TargetInfo.cpp [Android] Increase default new alignment for Android 2018-08-01 17:55:34 +00:00
Targets.cpp [Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals 2018-06-20 17:19:40 +00:00
Targets.h NFC: Add the emacs c++ mode hint "-*- C++ -*-" to the headers that don't have it 2018-07-24 00:07:49 +00:00
TokenKinds.cpp
Version.cpp
VirtualFileSystem.cpp [VFS] vfs::directory_iterator yields path and file type instead of full Status 2018-09-14 12:47:38 +00:00
Warnings.cpp Remove trailing space 2018-07-30 19:24:48 +00:00
XRayInstr.cpp [XRay] Add clang builtin for xray typed events. 2018-04-17 21:32:43 +00:00
XRayLists.cpp [XRay][llvm+clang] Consolidate attribute list files 2018-04-09 04:02:09 +00:00