llvm.org GIT mirror llvm / 817f08a
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 Chris Lattner 12 years ago
1 changed file(s) with 16 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
410410 Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 4);
411411
412412 unsigned AggregateAbbrev = 0;
413 unsigned GEPAbbrev = 0;
413 unsigned String7Abbrev = 0;
414414 // If this is a constant pool for the module, emit module-specific abbrevs.
415415 if (isGlobal) {
416416 // Abbrev for CST_CODE_AGGREGATE.
419419 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
420420 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, Log2_32_Ceil(LastVal+1)));
421421 AggregateAbbrev = Stream.EmitAbbrev(Abbv);
422
423 // Abbrev for CST_CODE_STRING.
424 Abbv = new BitCodeAbbrev();
425 Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_STRING));
426 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
427 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
428 String7Abbrev = Stream.EmitAbbrev(Abbv);
422429 }
423430
424431 // FIXME: Install and use abbrevs to reduce size. Install them globally so
486493 } else if (isa(C) && cast(C)->isString()) {
487494 // Emit constant strings specially.
488495 Code = bitc::CST_CODE_STRING;
489 for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i)
490 Record.push_back(cast(C->getOperand(i))->getZExtValue());
491
496 bool isStr7 = true;
497 for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) {
498 unsigned char V = cast(C->getOperand(i))->getZExtValue();
499 Record.push_back(V);
500 isStr7 &= (V & 128) == 0;
501 }
502 if (isStr7)
503 AbbrevToUse = String7Abbrev;
492504 } else if (isa(C) || isa(V) ||
493505 isa(V)) {
494506 Code = bitc::CST_CODE_AGGREGATE;
518530 Record.push_back(VE.getTypeID(C->getOperand(i)->getType()));
519531 Record.push_back(VE.getValueID(C->getOperand(i)));
520532 }
521 AbbrevToUse = GEPAbbrev;
522533 break;
523534 case Instruction::Select:
524535 Code = bitc::CST_CODE_CE_SELECT;