@@ -3853,6 +3853,12 @@ void ModuleBitcodeWriter::writeBlockInfo() {
3853
3853
// Other blocks can define their abbrevs inline.
3854
3854
Stream.EnterBlockInfoBlock ();
3855
3855
3856
+ // Encode type indices using fixed size based on number of types.
3857
+ BitCodeAbbrevOp TypeAbbrevOp (BitCodeAbbrevOp::Fixed,
3858
+ VE.computeBitsRequiredForTypeIndices ());
3859
+ // Encode value indices as 6-bit VBR.
3860
+ BitCodeAbbrevOp ValAbbrevOp (BitCodeAbbrevOp::VBR, 6 );
3861
+
3856
3862
{ // 8-bit fixed-width VST_CODE_ENTRY/VST_CODE_BBENTRY strings.
3857
3863
auto Abbv = std::make_shared<BitCodeAbbrev>();
3858
3864
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 3 ));
@@ -3898,8 +3904,7 @@ void ModuleBitcodeWriter::writeBlockInfo() {
3898
3904
{ // SETTYPE abbrev for CONSTANTS_BLOCK.
3899
3905
auto Abbv = std::make_shared<BitCodeAbbrev>();
3900
3906
Abbv->Add (BitCodeAbbrevOp (bitc::CST_CODE_SETTYPE));
3901
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed,
3902
- VE.computeBitsRequiredForTypeIndices ()));
3907
+ Abbv->Add (TypeAbbrevOp);
3903
3908
if (Stream.EmitBlockInfoAbbrev (bitc::CONSTANTS_BLOCK_ID, Abbv) !=
3904
3909
CONSTANTS_SETTYPE_ABBREV)
3905
3910
llvm_unreachable (" Unexpected abbrev ordering!" );
@@ -3939,9 +3944,8 @@ void ModuleBitcodeWriter::writeBlockInfo() {
3939
3944
{ // INST_LOAD abbrev for FUNCTION_BLOCK.
3940
3945
auto Abbv = std::make_shared<BitCodeAbbrev>();
3941
3946
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_LOAD));
3942
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 )); // Ptr
3943
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, // dest ty
3944
- VE.computeBitsRequiredForTypeIndices ()));
3947
+ Abbv->Add (ValAbbrevOp); // Ptr
3948
+ Abbv->Add (TypeAbbrevOp); // dest ty
3945
3949
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 4 )); // Align
3946
3950
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 1 )); // volatile
3947
3951
if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
@@ -3951,7 +3955,7 @@ void ModuleBitcodeWriter::writeBlockInfo() {
3951
3955
{ // INST_UNOP abbrev for FUNCTION_BLOCK.
3952
3956
auto Abbv = std::make_shared<BitCodeAbbrev>();
3953
3957
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_UNOP));
3954
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 ) ); // LHS
3958
+ Abbv->Add (ValAbbrevOp ); // LHS
3955
3959
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 4 )); // opc
3956
3960
if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
3957
3961
FUNCTION_INST_UNOP_ABBREV)
@@ -3960,7 +3964,7 @@ void ModuleBitcodeWriter::writeBlockInfo() {
3960
3964
{ // INST_UNOP_FLAGS abbrev for FUNCTION_BLOCK.
3961
3965
auto Abbv = std::make_shared<BitCodeAbbrev>();
3962
3966
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_UNOP));
3963
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 ) ); // LHS
3967
+ Abbv->Add (ValAbbrevOp ); // LHS
3964
3968
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 4 )); // opc
3965
3969
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 8 )); // flags
3966
3970
if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
@@ -3970,8 +3974,8 @@ void ModuleBitcodeWriter::writeBlockInfo() {
3970
3974
{ // INST_BINOP abbrev for FUNCTION_BLOCK.
3971
3975
auto Abbv = std::make_shared<BitCodeAbbrev>();
3972
3976
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_BINOP));
3973
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 ) ); // LHS
3974
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 ) ); // RHS
3977
+ Abbv->Add (ValAbbrevOp ); // LHS
3978
+ Abbv->Add (ValAbbrevOp ); // RHS
3975
3979
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 4 )); // opc
3976
3980
if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
3977
3981
FUNCTION_INST_BINOP_ABBREV)
@@ -3980,8 +3984,8 @@ void ModuleBitcodeWriter::writeBlockInfo() {
3980
3984
{ // INST_BINOP_FLAGS abbrev for FUNCTION_BLOCK.
3981
3985
auto Abbv = std::make_shared<BitCodeAbbrev>();
3982
3986
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_BINOP));
3983
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 ) ); // LHS
3984
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 ) ); // RHS
3987
+ Abbv->Add (ValAbbrevOp ); // LHS
3988
+ Abbv->Add (ValAbbrevOp ); // RHS
3985
3989
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 4 )); // opc
3986
3990
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 8 )); // flags
3987
3991
if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
@@ -3991,20 +3995,18 @@ void ModuleBitcodeWriter::writeBlockInfo() {
3991
3995
{ // INST_CAST abbrev for FUNCTION_BLOCK.
3992
3996
auto Abbv = std::make_shared<BitCodeAbbrev>();
3993
3997
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_CAST));
3994
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 )); // OpVal
3995
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, // dest ty
3996
- VE.computeBitsRequiredForTypeIndices ()));
3997
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 4 )); // opc
3998
+ Abbv->Add (ValAbbrevOp); // OpVal
3999
+ Abbv->Add (TypeAbbrevOp); // dest ty
4000
+ Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 4 )); // opc
3998
4001
if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
3999
4002
FUNCTION_INST_CAST_ABBREV)
4000
4003
llvm_unreachable (" Unexpected abbrev ordering!" );
4001
4004
}
4002
4005
{ // INST_CAST_FLAGS abbrev for FUNCTION_BLOCK.
4003
4006
auto Abbv = std::make_shared<BitCodeAbbrev>();
4004
4007
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_CAST));
4005
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 )); // OpVal
4006
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, // dest ty
4007
- VE.computeBitsRequiredForTypeIndices ()));
4008
+ Abbv->Add (ValAbbrevOp); // OpVal
4009
+ Abbv->Add (TypeAbbrevOp); // dest ty
4008
4010
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 4 )); // opc
4009
4011
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 8 )); // flags
4010
4012
if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
@@ -4022,7 +4024,7 @@ void ModuleBitcodeWriter::writeBlockInfo() {
4022
4024
{ // INST_RET abbrev for FUNCTION_BLOCK.
4023
4025
auto Abbv = std::make_shared<BitCodeAbbrev>();
4024
4026
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_RET));
4025
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 )); // ValID
4027
+ Abbv->Add (ValAbbrevOp);
4026
4028
if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
4027
4029
FUNCTION_INST_RET_VAL_ABBREV)
4028
4030
llvm_unreachable (" Unexpected abbrev ordering!" );
@@ -4037,11 +4039,10 @@ void ModuleBitcodeWriter::writeBlockInfo() {
4037
4039
{
4038
4040
auto Abbv = std::make_shared<BitCodeAbbrev>();
4039
4041
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_GEP));
4040
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 3 ));
4041
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, // dest ty
4042
- Log2_32_Ceil (VE.getTypes ().size () + 1 )));
4042
+ Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 3 )); // flags
4043
+ Abbv->Add (TypeAbbrevOp); // dest ty
4043
4044
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Array));
4044
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 ) );
4045
+ Abbv->Add (ValAbbrevOp );
4045
4046
if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
4046
4047
FUNCTION_INST_GEP_ABBREV)
4047
4048
llvm_unreachable (" Unexpected abbrev ordering!" );
@@ -4052,7 +4053,7 @@ void ModuleBitcodeWriter::writeBlockInfo() {
4052
4053
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 7 )); // dbgloc
4053
4054
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 7 )); // var
4054
4055
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 7 )); // expr
4055
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 ) ); // val
4056
+ Abbv->Add (ValAbbrevOp ); // val
4056
4057
if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
4057
4058
FUNCTION_DEBUG_RECORD_VALUE_ABBREV)
4058
4059
llvm_unreachable (" Unexpected abbrev ordering! 1" );
0 commit comments