[PATCH] D18918: [DebugInfo] Try to make class memory layout more efficient

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 8 19:08:31 PDT 2016


davide created this revision.
davide added reviewers: dexonsmith, aprantl, echristo, dblaikie.
davide added a subscriber: llvm-commits.

I started this effort after noticing that DI shows up as a considerable portion of memory usage during an LTO build (of clang, and others).
This is roughly the data I got (peak usage):
DISubprogram: 228MB
DILocalVariable: 164MB
The proposed patch packs field slightly more efficiently reducing the size of DISubprogram from 48bytes to 40bytes and of DILocalVariable from 40 bytes to 32 bytes.
The saving overall in memory is ~70MB.
This is still to be considered WIP as this breaks 4 tests in the LLVM suite (which I'm currently investigating), but I wanted to have some eyes on it as DebugInfo seems to be of interest of many these days.

http://reviews.llvm.org/D18918

Files:
  include/llvm/IR/DebugInfoMetadata.h

Index: include/llvm/IR/DebugInfoMetadata.h
===================================================================
--- include/llvm/IR/DebugInfoMetadata.h
+++ include/llvm/IR/DebugInfoMetadata.h
@@ -1229,21 +1229,21 @@
 
   unsigned Line;
   unsigned ScopeLine;
-  unsigned Virtuality;
   unsigned VirtualIndex;
-  unsigned Flags;
-  bool IsLocalToUnit;
-  bool IsDefinition;
-  bool IsOptimized;
+  unsigned Virtuality:2;
+  unsigned Flags:27;
+  bool IsLocalToUnit:1;
+  bool IsDefinition:1;
+  bool IsOptimized:1;
 
   DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
-               unsigned ScopeLine, unsigned Virtuality, unsigned VirtualIndex,
+               unsigned ScopeLine, unsigned VirtualIndex, unsigned Virtuality,
                unsigned Flags, bool IsLocalToUnit, bool IsDefinition,
                bool IsOptimized, ArrayRef<Metadata *> Ops)
       : DILocalScope(C, DISubprogramKind, Storage, dwarf::DW_TAG_subprogram,
                      Ops),
-        Line(Line), ScopeLine(ScopeLine), Virtuality(Virtuality),
-        VirtualIndex(VirtualIndex), Flags(Flags), IsLocalToUnit(IsLocalToUnit),
+        Line(Line), ScopeLine(ScopeLine), VirtualIndex(VirtualIndex),
+        Virtuality(Virtuality), Flags(Flags), IsLocalToUnit(IsLocalToUnit),
         IsDefinition(IsDefinition), IsOptimized(IsOptimized) {}
   ~DISubprogram() = default;
 
@@ -1858,8 +1858,8 @@
   friend class LLVMContextImpl;
   friend class MDNode;
 
-  unsigned Arg;
-  unsigned Flags;
+  unsigned Arg:16;
+  unsigned Flags:16;
 
   DILocalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
                   unsigned Arg, unsigned Flags, ArrayRef<Metadata *> Ops)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18918.53109.patch
Type: text/x-patch
Size: 1680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160409/0807d680/attachment.bin>


More information about the llvm-commits mailing list