Skip to content

Commit d233243

Browse files
committed
[NFC][Bitcode] Remove FUNCTION_INST_UNOP abbrevs
Discussed in llvm#146497. Seems to have a positive impact on bitcode file size in CTMark LTO builds, and makes space for more abbrevs without bumping the CodeLen for function blocks. Alternatively, we could just bump the CodeLen to 5 bits.
1 parent 7354123 commit d233243

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ enum {
141141

142142
// FUNCTION_BLOCK abbrev id's.
143143
FUNCTION_INST_LOAD_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
144-
FUNCTION_INST_UNOP_ABBREV,
145-
FUNCTION_INST_UNOP_FLAGS_ABBREV,
146144
FUNCTION_INST_BINOP_ABBREV,
147145
FUNCTION_INST_BINOP_FLAGS_ABBREV,
148146
FUNCTION_INST_CAST_ABBREV,
@@ -3127,13 +3125,10 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I,
31273125
break;
31283126
case Instruction::FNeg: {
31293127
Code = bitc::FUNC_CODE_INST_UNOP;
3130-
if (!pushValueAndType(I.getOperand(0), InstID, Vals))
3131-
AbbrevToUse = FUNCTION_INST_UNOP_ABBREV;
3128+
pushValueAndType(I.getOperand(0), InstID, Vals);
31323129
Vals.push_back(getEncodedUnaryOpcode(I.getOpcode()));
31333130
uint64_t Flags = getOptimizationFlags(&I);
31343131
if (Flags != 0) {
3135-
if (AbbrevToUse == FUNCTION_INST_UNOP_ABBREV)
3136-
AbbrevToUse = FUNCTION_INST_UNOP_FLAGS_ABBREV;
31373132
Vals.push_back(Flags);
31383133
}
31393134
break;
@@ -3947,23 +3942,23 @@ void ModuleBitcodeWriter::writeBlockInfo() {
39473942
llvm_unreachable("Unexpected abbrev ordering!");
39483943
}
39493944
{ // INST_UNOP abbrev for FUNCTION_BLOCK.
3950-
auto Abbv = std::make_shared<BitCodeAbbrev>();
3951-
Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_UNOP));
3952-
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS
3953-
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
3954-
if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
3955-
FUNCTION_INST_UNOP_ABBREV)
3956-
llvm_unreachable("Unexpected abbrev ordering!");
3945+
// auto Abbv = std::make_shared<BitCodeAbbrev>();
3946+
// Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_UNOP));
3947+
// Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS
3948+
// Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
3949+
// if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
3950+
// FUNCTION_INST_UNOP_ABBREV)
3951+
// llvm_unreachable("Unexpected abbrev ordering!");
39573952
}
39583953
{ // INST_UNOP_FLAGS abbrev for FUNCTION_BLOCK.
3959-
auto Abbv = std::make_shared<BitCodeAbbrev>();
3960-
Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_UNOP));
3961-
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS
3962-
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
3963-
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); // flags
3964-
if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
3965-
FUNCTION_INST_UNOP_FLAGS_ABBREV)
3966-
llvm_unreachable("Unexpected abbrev ordering!");
3954+
// auto Abbv = std::make_shared<BitCodeAbbrev>();
3955+
// Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_UNOP));
3956+
// Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS
3957+
// Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
3958+
// Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); // flags
3959+
// if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
3960+
// FUNCTION_INST_UNOP_FLAGS_ABBREV)
3961+
// llvm_unreachable("Unexpected abbrev ordering!");
39673962
}
39683963
{ // INST_BINOP abbrev for FUNCTION_BLOCK.
39693964
auto Abbv = std::make_shared<BitCodeAbbrev>();

0 commit comments

Comments
 (0)