diff options
author | Chris Lattner <sabre@nondot.org> | 2007-05-06 00:42:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-05-06 00:42:18 +0000 |
commit | 817f08a0e5b4d5e697956b547a18968e62586479 (patch) | |
tree | ffa62b824272a77106cfbdd883ccd746485417a7 /lib/Bitcode/Writer | |
parent | 2d6b4bfc844ba6a57a08a27b21b0fbea75b3c9cd (diff) | |
download | external_llvm-817f08a0e5b4d5e697956b547a18968e62586479.zip external_llvm-817f08a0e5b4d5e697956b547a18968e62586479.tar.gz external_llvm-817f08a0e5b4d5e697956b547a18968e62586479.tar.bz2 |
add an abbreviation for the string constants opzn, shrinking the constnats
block from:
Block ID #11 (CONSTANTS_BLOCK):
Num Instances: 1722
Total Size: 3.85976e+06b/482470B/120617W
% of file: 16.7609
Average Size: 2241.44b/280.18B/70.045W
Tot/Avg SubBlocks: 0/0
Tot/Avg Abbrevs: 1/0.00058072
Tot/Avg Records: 26423/15.3444
% Abbrev Recs: 69.1746
to:
Block ID #11 (CONSTANTS_BLOCK):
Num Instances: 1724
Total Size: 2.62406e+06b/328008B/82001.9W
% of file: 12.041
Average Size: 1522.08b/190.26B/47.5649W
Tot/Avg SubBlocks: 0/0
Tot/Avg Abbrevs: 2/0.00116009
Tot/Avg Records: 26280/15.2436
% Abbrev Recs: 68.9992
This shrinks kc++ from 2815788 to 2724088 bytes, which means the bitcode
file is now smaller than the bytecode file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36820 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Writer')
-rw-r--r-- | lib/Bitcode/Writer/BitcodeWriter.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index a29f23d..6cfa25a 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -411,7 +411,7 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal, Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 4); unsigned AggregateAbbrev = 0; - unsigned GEPAbbrev = 0; + unsigned String7Abbrev = 0; // If this is a constant pool for the module, emit module-specific abbrevs. if (isGlobal) { // Abbrev for CST_CODE_AGGREGATE. @@ -420,6 +420,13 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal, Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, Log2_32_Ceil(LastVal+1))); AggregateAbbrev = Stream.EmitAbbrev(Abbv); + + // Abbrev for CST_CODE_STRING. + Abbv = new BitCodeAbbrev(); + Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_STRING)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7)); + String7Abbrev = Stream.EmitAbbrev(Abbv); } // FIXME: Install and use abbrevs to reduce size. Install them globally so @@ -487,9 +494,14 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal, } else if (isa<ConstantArray>(C) && cast<ConstantArray>(C)->isString()) { // Emit constant strings specially. Code = bitc::CST_CODE_STRING; - for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) - Record.push_back(cast<ConstantInt>(C->getOperand(i))->getZExtValue()); - + bool isStr7 = true; + for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) { + unsigned char V = cast<ConstantInt>(C->getOperand(i))->getZExtValue(); + Record.push_back(V); + isStr7 &= (V & 128) == 0; + } + if (isStr7) + AbbrevToUse = String7Abbrev; } else if (isa<ConstantArray>(C) || isa<ConstantStruct>(V) || isa<ConstantVector>(V)) { Code = bitc::CST_CODE_AGGREGATE; @@ -519,7 +531,6 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal, Record.push_back(VE.getTypeID(C->getOperand(i)->getType())); Record.push_back(VE.getValueID(C->getOperand(i))); } - AbbrevToUse = GEPAbbrev; break; case Instruction::Select: Code = bitc::CST_CODE_CE_SELECT; |