@@ -141,6 +141,7 @@ enum {
141
141
142
142
// FUNCTION_BLOCK abbrev id's.
143
143
FUNCTION_INST_LOAD_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
144
+ FUNCTION_INST_STORE_ABBREV,
144
145
FUNCTION_INST_UNOP_ABBREV,
145
146
FUNCTION_INST_UNOP_FLAGS_ABBREV,
146
147
FUNCTION_INST_BINOP_ABBREV,
@@ -149,8 +150,12 @@ enum {
149
150
FUNCTION_INST_CAST_FLAGS_ABBREV,
150
151
FUNCTION_INST_RET_VOID_ABBREV,
151
152
FUNCTION_INST_RET_VAL_ABBREV,
153
+ FUNCTION_INST_BR_UNCOND_ABBREV,
154
+ FUNCTION_INST_BR_COND_ABBREV,
152
155
FUNCTION_INST_UNREACHABLE_ABBREV,
153
156
FUNCTION_INST_GEP_ABBREV,
157
+ FUNCTION_INST_CMP_ABBREV,
158
+ FUNCTION_INST_CMP_FLAGS_ABBREV,
154
159
FUNCTION_DEBUG_RECORD_VALUE_ABBREV,
155
160
};
156
161
@@ -3197,12 +3202,17 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I,
3197
3202
case Instruction::FCmp: {
3198
3203
// compare returning Int1Ty or vector of Int1Ty
3199
3204
Code = bitc::FUNC_CODE_INST_CMP2;
3200
- pushValueAndType (I.getOperand (0 ), InstID, Vals);
3205
+ AbbrevToUse = FUNCTION_INST_CMP_ABBREV;
3206
+ if (pushValueAndType (I.getOperand (0 ), InstID, Vals))
3207
+ AbbrevToUse = 0 ;
3201
3208
pushValue (I.getOperand (1 ), InstID, Vals);
3202
3209
Vals.push_back (cast<CmpInst>(I).getPredicate ());
3203
3210
uint64_t Flags = getOptimizationFlags (&I);
3204
- if (Flags != 0 )
3211
+ if (Flags != 0 ) {
3205
3212
Vals.push_back (Flags);
3213
+ if (AbbrevToUse)
3214
+ AbbrevToUse = FUNCTION_INST_CMP_FLAGS_ABBREV;
3215
+ }
3206
3216
break ;
3207
3217
}
3208
3218
@@ -3224,11 +3234,13 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I,
3224
3234
case Instruction::Br:
3225
3235
{
3226
3236
Code = bitc::FUNC_CODE_INST_BR;
3237
+ AbbrevToUse = FUNCTION_INST_BR_UNCOND_ABBREV;
3227
3238
const BranchInst &II = cast<BranchInst>(I);
3228
3239
Vals.push_back (VE.getValueID (II.getSuccessor (0 )));
3229
3240
if (II.isConditional ()) {
3230
3241
Vals.push_back (VE.getValueID (II.getSuccessor (1 )));
3231
3242
pushValue (II.getCondition (), InstID, Vals);
3243
+ AbbrevToUse = FUNCTION_INST_BR_COND_ABBREV;
3232
3244
}
3233
3245
}
3234
3246
break ;
@@ -3449,12 +3461,16 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I,
3449
3461
}
3450
3462
break ;
3451
3463
case Instruction::Store:
3452
- if (cast<StoreInst>(I).isAtomic ())
3464
+ if (cast<StoreInst>(I).isAtomic ()) {
3453
3465
Code = bitc::FUNC_CODE_INST_STOREATOMIC;
3454
- else
3466
+ } else {
3455
3467
Code = bitc::FUNC_CODE_INST_STORE;
3456
- pushValueAndType (I.getOperand (1 ), InstID, Vals); // ptrty + ptr
3457
- pushValueAndType (I.getOperand (0 ), InstID, Vals); // valty + val
3468
+ AbbrevToUse = FUNCTION_INST_STORE_ABBREV;
3469
+ }
3470
+ if (pushValueAndType (I.getOperand (1 ), InstID, Vals)) // ptrty + ptr
3471
+ AbbrevToUse = 0 ;
3472
+ if (pushValueAndType (I.getOperand (0 ), InstID, Vals)) // valty + val
3473
+ AbbrevToUse = 0 ;
3458
3474
Vals.push_back (getEncodedAlign (cast<StoreInst>(I).getAlign ()));
3459
3475
Vals.push_back (cast<StoreInst>(I).isVolatile ());
3460
3476
if (cast<StoreInst>(I).isAtomic ()) {
@@ -3677,7 +3693,7 @@ void ModuleBitcodeWriter::writeFunction(
3677
3693
// in the VST.
3678
3694
FunctionToBitcodeIndex[&F] = Stream.GetCurrentBitNo ();
3679
3695
3680
- Stream.EnterSubblock (bitc::FUNCTION_BLOCK_ID, 4 );
3696
+ Stream.EnterSubblock (bitc::FUNCTION_BLOCK_ID, 5 );
3681
3697
VE.incorporateFunction (F);
3682
3698
3683
3699
SmallVector<unsigned , 64 > Vals;
@@ -3952,6 +3968,17 @@ void ModuleBitcodeWriter::writeBlockInfo() {
3952
3968
FUNCTION_INST_LOAD_ABBREV)
3953
3969
llvm_unreachable (" Unexpected abbrev ordering!" );
3954
3970
}
3971
+ {
3972
+ auto Abbv = std::make_shared<BitCodeAbbrev>();
3973
+ Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_STORE));
3974
+ Abbv->Add (ValAbbrevOp); // op1
3975
+ Abbv->Add (ValAbbrevOp); // op0
3976
+ Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 4 )); // align
3977
+ Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 1 )); // volatile
3978
+ if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
3979
+ FUNCTION_INST_STORE_ABBREV)
3980
+ llvm_unreachable (" Unexpected abbrev ordering!" );
3981
+ }
3955
3982
{ // INST_UNOP abbrev for FUNCTION_BLOCK.
3956
3983
auto Abbv = std::make_shared<BitCodeAbbrev>();
3957
3984
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_UNOP));
@@ -4029,6 +4056,26 @@ void ModuleBitcodeWriter::writeBlockInfo() {
4029
4056
FUNCTION_INST_RET_VAL_ABBREV)
4030
4057
llvm_unreachable (" Unexpected abbrev ordering!" );
4031
4058
}
4059
+ {
4060
+ auto Abbv = std::make_shared<BitCodeAbbrev>();
4061
+ Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_BR));
4062
+ // TODO: Use different abbrev for absolute value reference (succ0)?
4063
+ Abbv->Add (ValAbbrevOp); // succ0
4064
+ if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
4065
+ FUNCTION_INST_BR_UNCOND_ABBREV)
4066
+ llvm_unreachable (" Unexpected abbrev ordering!" );
4067
+ }
4068
+ {
4069
+ auto Abbv = std::make_shared<BitCodeAbbrev>();
4070
+ Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_BR));
4071
+ // TODO: Use different abbrev for absolute value references (succ0, succ1)?
4072
+ Abbv->Add (ValAbbrevOp); // succ0
4073
+ Abbv->Add (ValAbbrevOp); // succ1
4074
+ Abbv->Add (ValAbbrevOp); // cond
4075
+ if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
4076
+ FUNCTION_INST_BR_COND_ABBREV)
4077
+ llvm_unreachable (" Unexpected abbrev ordering!" );
4078
+ }
4032
4079
{ // INST_UNREACHABLE abbrev for FUNCTION_BLOCK.
4033
4080
auto Abbv = std::make_shared<BitCodeAbbrev>();
4034
4081
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_UNREACHABLE));
@@ -4047,6 +4094,27 @@ void ModuleBitcodeWriter::writeBlockInfo() {
4047
4094
FUNCTION_INST_GEP_ABBREV)
4048
4095
llvm_unreachable (" Unexpected abbrev ordering!" );
4049
4096
}
4097
+ {
4098
+ auto Abbv = std::make_shared<BitCodeAbbrev>();
4099
+ Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_CMP2));
4100
+ Abbv->Add (ValAbbrevOp); // op0
4101
+ Abbv->Add (ValAbbrevOp); // op1
4102
+ Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 6 )); // pred
4103
+ if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
4104
+ FUNCTION_INST_CMP_ABBREV)
4105
+ llvm_unreachable (" Unexpected abbrev ordering!" );
4106
+ }
4107
+ {
4108
+ auto Abbv = std::make_shared<BitCodeAbbrev>();
4109
+ Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_INST_CMP2));
4110
+ Abbv->Add (ValAbbrevOp); // op0
4111
+ Abbv->Add (ValAbbrevOp); // op1
4112
+ Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 6 )); // pred
4113
+ Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 8 )); // flags
4114
+ if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
4115
+ FUNCTION_INST_CMP_FLAGS_ABBREV)
4116
+ llvm_unreachable (" Unexpected abbrev ordering!" );
4117
+ }
4050
4118
{
4051
4119
auto Abbv = std::make_shared<BitCodeAbbrev>();
4052
4120
Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_DEBUG_RECORD_VALUE_SIMPLE));
0 commit comments