llvm.org GIT mirror llvm / 0149731
[DebugInfo] Optimize memory layout of DISubprogram. A DISubprogram on x86_64 was 48 bytes. During an LTO build we end up allocating *a lot* of these (see Duncan's numbers on llvm-dev and/or my numbers in the review link). This change reduces the size to 40 bytes, with a nice effect on peak memory usage when LTO'ing clang. There are more classes in the hierarchy which can be compacted so more patches will come. DISubprogram was the biggest offender in my profiling, anyway. Differential Revision: http://reviews.llvm.org/D18918 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266241 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 3 years ago
2 changed file(s) with 24 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
12281228
12291229 unsigned Line;
12301230 unsigned ScopeLine;
1231 unsigned Virtuality;
12321231 unsigned VirtualIndex;
1233 unsigned Flags;
1234 bool IsLocalToUnit;
1235 bool IsDefinition;
1236 bool IsOptimized;
1232
1233 // Virtuality can only assume three values, so we can pack
1234 // in 2 bits (none/pure/pure_virtual).
1235 unsigned Virtuality : 2;
1236
1237 unsigned Flags : 27;
1238
1239 // These are boolean flags so one bit is enough.
1240 // MSVC starts a new container field every time the base
1241 // type changes so we can't use 'bool' to ensure these bits
1242 // are packed.
1243 unsigned IsLocalToUnit : 1;
1244 unsigned IsDefinition : 1;
1245 unsigned IsOptimized : 1;
12371246
12381247 DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
12391248 unsigned ScopeLine, unsigned Virtuality, unsigned VirtualIndex,
12411250 bool IsOptimized, ArrayRef Ops)
12421251 : DILocalScope(C, DISubprogramKind, Storage, dwarf::DW_TAG_subprogram,
12431252 Ops),
1244 Line(Line), ScopeLine(ScopeLine), Virtuality(Virtuality),
1245 VirtualIndex(VirtualIndex), Flags(Flags), IsLocalToUnit(IsLocalToUnit),
1246 IsDefinition(IsDefinition), IsOptimized(IsOptimized) {}
1253 Line(Line), ScopeLine(ScopeLine), VirtualIndex(VirtualIndex),
1254 Virtuality(Virtuality), Flags(Flags), IsLocalToUnit(IsLocalToUnit),
1255 IsDefinition(IsDefinition), IsOptimized(IsOptimized) {
1256 static_assert(dwarf::DW_VIRTUALITY_max < 4, "Virtuality out of range");
1257 assert(Virtuality < 4 && "Virtuality out of range");
1258 assert((Flags < (1 << 27)) && "Flags out of range");
1259 }
12471260 ~DISubprogram() = default;
12481261
12491262 static DISubprogram *
14121412 bool IsDefinition = true;
14131413 unsigned ScopeLine = 3;
14141414 DITypeRef ContainingType = getCompositeType();
1415 unsigned Virtuality = 4;
1415 unsigned Virtuality = 2;
14161416 unsigned VirtualIndex = 5;
14171417 unsigned Flags = 6;
1418 unsigned NotFlags = (~Flags) & ((1 << 27) - 1);
14181419 bool IsOptimized = false;
14191420 MDTuple *TemplateParams = getTuple();
14201421 DISubprogram *Declaration = getSubprogram();
15121513 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
15131514 Type, IsLocalToUnit, IsDefinition, ScopeLine,
15141515 ContainingType, Virtuality, VirtualIndex,
1515 ~Flags, IsOptimized, TemplateParams,
1516 NotFlags, IsOptimized, TemplateParams,
15161517 Declaration, Variables));
15171518 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
15181519 Type, IsLocalToUnit, IsDefinition, ScopeLine,