[PATCH] D97553: [clang][NFC] pack StaticDiagInfoRec

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 26 06:29:34 PST 2021


njames93 created this revision.
njames93 added reviewers: rsmith, aaron.ballman.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Exchanging types, reordering fields and borrowing a bit from OptionGroupIndex shrinks this from 12 bytes to 8.
This knocks ~20k from the binary size.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97553

Files:
  clang/lib/Basic/DiagnosticIDs.cpp


Index: clang/lib/Basic/DiagnosticIDs.cpp
===================================================================
--- clang/lib/Basic/DiagnosticIDs.cpp
+++ clang/lib/Basic/DiagnosticIDs.cpp
@@ -109,15 +109,15 @@
 
 struct StaticDiagInfoRec {
   uint16_t DiagID;
-  unsigned DefaultSeverity : 3;
-  unsigned Class : 3;
-  unsigned SFINAE : 2;
-  unsigned WarnNoWerror : 1;
-  unsigned WarnShowInSystemHeader : 1;
-  unsigned Deferrable : 1;
-  unsigned Category : 6;
+  uint8_t DefaultSeverity : 3;
+  uint8_t Class : 3;
+  uint8_t SFINAE : 2;
+  uint8_t Category : 6;
+  uint8_t WarnNoWerror : 1;
+  uint8_t WarnShowInSystemHeader : 1;
 
-  uint16_t OptionGroupIndex;
+  uint16_t OptionGroupIndex : 15;
+  uint16_t Deferrable : 1;
 
   uint16_t DescriptionLen;
 
@@ -168,20 +168,20 @@
 #undef STRINGIFY_NAME
 
 const StaticDiagInfoRec StaticDiagInfo[] = {
+// clang-format off
 #define DIAG(ENUM, CLASS, DEFAULT_SEVERITY, DESC, GROUP, SFINAE, NOWERROR,     \
-             SHOWINSYSHEADER, DEFERRABLE, CATEGORY)                         \
+             SHOWINSYSHEADER, DEFERRABLE, CATEGORY)                            \
   {                                                                            \
       diag::ENUM,                                                              \
       DEFAULT_SEVERITY,                                                        \
       CLASS,                                                                   \
       DiagnosticIDs::SFINAE,                                                   \
+      CATEGORY,                                                                \
       NOWERROR,                                                                \
       SHOWINSYSHEADER,                                                         \
-	  DEFERRABLE,                                                          \
-      CATEGORY,                                                                \
       GROUP,                                                                   \
+	    DEFERRABLE,                                                              \
       STR_SIZE(DESC, uint16_t)},
-// clang-format off
 #include "clang/Basic/DiagnosticCommonKinds.inc"
 #include "clang/Basic/DiagnosticDriverKinds.inc"
 #include "clang/Basic/DiagnosticFrontendKinds.inc"
@@ -194,7 +194,7 @@
 #include "clang/Basic/DiagnosticSemaKinds.inc"
 #include "clang/Basic/DiagnosticAnalysisKinds.inc"
 #include "clang/Basic/DiagnosticRefactoringKinds.inc"
-  // clang-format on
+// clang-format on
 #undef DIAG
 };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97553.326679.patch
Type: text/x-patch
Size: 2534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210226/b8497f65/attachment-0001.bin>


More information about the cfe-commits mailing list