llvm.org GIT mirror llvm / 5969830
where possible, encode symtab names with 7 bits per char instead of 8. This shaves 110K off kc++ to 3514K. Before: Block ID #14 (VALUE_SYMTAB): Num Instances: 2345 Total Size: 1.50425e+07b/1.88031e+06B/470077W Average Size: 6414.69b/801.837B/200.459W % of file: 51.8057 Tot/Avg SubBlocks: 0/0 Tot/Avg Abbrevs: 2345/1 Tot/Avg Records: 120924/51.5667 % Abbrev Recs: 85.1791 after: Block ID #14 (VALUE_SYMTAB): Num Instances: 2345 Total Size: 1.41229e+07b/1.76536e+06B/441341W Average Size: 6022.56b/752.82B/188.205W % of file: 50.2295 Tot/Avg SubBlocks: 0/0 Tot/Avg Abbrevs: 4690/2 Tot/Avg Records: 120924/51.5667 % Abbrev Recs: 85.1791 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36758 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
1 changed file(s) with 45 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
2424 #include "llvm/Support/MathExtras.h"
2525 using namespace llvm;
2626
27 static const unsigned CurVersion = 0;
27 /// These are manifest constants used by the bitcode writer. They do not need to
28 /// be kept in sync with the reader, but need to be consistent within this file.
29 enum {
30 CurVersion = 0,
31
32 // VALUE_SYMTAB_BLOCK abbrev id's.
33 VST_ENTRY_8_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
34 VST_ENTRY_7_ABBREV
35
36 };
37
2838
2939 static unsigned GetEncodedCastOpcode(unsigned Opcode) {
3040 switch (Opcode) {
702712 if (VST.empty()) return;
703713 Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3);
704714
705 // 8-bit fixed width VST_ENTRY strings.
706 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
707 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
708 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
709 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
710 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
711 unsigned AbbrevID = Stream.EmitAbbrev(Abbv);
715 { // 8-bit fixed width VST_ENTRY strings.
716 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
717 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
718 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
719 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
720 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
721 if (Stream.EmitAbbrev(Abbv) != VST_ENTRY_8_ABBREV)
722 assert(0 && "Unexpected abbrev ordering!");
723 }
724
725 { // 7-bit fixed width VST_ENTRY strings.
726 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
727 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
728 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
729 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
730 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
731 if (Stream.EmitAbbrev(Abbv) != VST_ENTRY_7_ABBREV)
732 assert(0 && "Unexpected abbrev ordering!");
733 }
712734
713735
714736 // FIXME: Set up the abbrev, we know how many values there are!
717739
718740 for (ValueSymbolTable::const_iterator SI = VST.begin(), SE = VST.end();
719741 SI != SE; ++SI) {
742
743 const ValueName &Name = *SI;
744
745 // Figure out the encoding to use for the name.
746 bool is7Bit = true;
747 for (unsigned i = 0, e = Name.getKeyLength(); i != e; ++i)
748 if ((unsigned char)Name.getKeyData()[i] & 128) {
749 is7Bit = false;
750 break;
751 }
752
753
720754 unsigned AbbrevToUse = 0;
721755
722756 // VST_ENTRY: [valueid, namelen, namechar x N]
726760 Code = bitc::VST_CODE_BBENTRY;
727761 } else {
728762 Code = bitc::VST_CODE_ENTRY;
729 AbbrevToUse = AbbrevID;
763 AbbrevToUse = is7Bit ? VST_ENTRY_7_ABBREV : VST_ENTRY_8_ABBREV;
730764 }
731765
732766 NameVals.push_back(VE.getValueID(SI->getValue()));
733 for (const char *P = SI->getKeyData(),
734 *E = SI->getKeyData()+SI->getKeyLength(); P != E; ++P)
767 for (const char *P = Name.getKeyData(),
768 *E = Name.getKeyData()+Name.getKeyLength(); P != E; ++P)
735769 NameVals.push_back((unsigned char)*P);
736770
737771 // Emit the finished record.