summaryrefslogtreecommitdiffstats
path: root/lib/Bitcode/Writer
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-05 00:47:19 +0000
committerChris Lattner <sabre@nondot.org>2007-05-05 00:47:19 +0000
commit7a263ea8598c03c8522d66ea8db5113d6b4d640e (patch)
tree8ea33a9ae52d302d213018e1c7bb8e14ed44da17 /lib/Bitcode/Writer
parent1772b12d1332c7fb23155c20e7eeeed92200d053 (diff)
downloadexternal_llvm-7a263ea8598c03c8522d66ea8db5113d6b4d640e.zip
external_llvm-7a263ea8598c03c8522d66ea8db5113d6b4d640e.tar.gz
external_llvm-7a263ea8598c03c8522d66ea8db5113d6b4d640e.tar.bz2
add an abbreviation for the type symtab, this shrinks the TST from 175197 bits
to 103165 bits: Old: Block ID #13 (TYPE_SYMTAB): Num Instances: 1 Total Size: 175197b/21899.6B/5474.91W Average Size: 175197b/21899.6B/5474.91W % of file: 0.657023 Tot/Avg SubBlocks: 0/0 Tot/Avg Abbrevs: 0/0 Tot/Avg Records: 255/255 % Abbrev Recs: 0 New: Block ID #13 (TYPE_SYMTAB): Num Instances: 1 Total Size: 103165b/12895.6B/3223.91W Average Size: 103165b/12895.6B/3223.91W % of file: 0.387937 Tot/Avg SubBlocks: 0/0 Tot/Avg Abbrevs: 1/1 Tot/Avg Records: 255/255 % Abbrev Recs: 100 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36769 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Writer')
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index 35e75da..a3c3c6b 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -798,24 +798,32 @@ static void WriteTypeSymbolTable(const TypeSymbolTable &TST,
Stream.EnterSubblock(bitc::TYPE_SYMTAB_BLOCK_ID, 3);
- // FIXME: Set up the abbrev, we know how many types there are!
- // FIXME: We know if the type names can use 7-bit ascii.
+ // 7-bit fixed width VST_CODE_ENTRY strings.
+ BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+ Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
+ Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
+ Log2_32_Ceil(VE.getTypes().size()+1)));
+ Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+ Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
+ unsigned V7Abbrev = Stream.EmitAbbrev(Abbv);
SmallVector<unsigned, 64> NameVals;
for (TypeSymbolTable::const_iterator TI = TST.begin(), TE = TST.end();
TI != TE; ++TI) {
- unsigned AbbrevToUse = 0;
-
- // TST_ENTRY: [typeid, namelen, namechar x N]
+ // TST_ENTRY: [typeid, namechar x N]
NameVals.push_back(VE.getTypeID(TI->second));
const std::string &Str = TI->first;
- for (unsigned i = 0, e = Str.size(); i != e; ++i)
- NameVals.push_back(Str[i]);
+ bool is7Bit = true;
+ for (unsigned i = 0, e = Str.size(); i != e; ++i) {
+ NameVals.push_back((unsigned char)Str[i]);
+ if (Str[i] & 128)
+ is7Bit = false;
+ }
// Emit the finished record.
- Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, AbbrevToUse);
+ Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, is7Bit ? V7Abbrev : 0);
NameVals.clear();
}