@@ -4629,48 +4629,31 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
4629
4629
InstructionList.push_back (I);
4630
4630
break ;
4631
4631
case bitc::FUNC_CODE_INST_PHI: { // PHI: [ty, val0,bb0, ...]
4632
- if (Record.size () < 1 )
4632
+ if (Record.size () < 1 || ((Record. size ()- 1 )& 1 ) )
4633
4633
return error (" Invalid record" );
4634
- // The first record specifies the type.
4635
4634
FullTy = getFullyStructuredTypeByID (Record[0 ]);
4636
4635
Type *Ty = flattenPointerTypes (FullTy);
4637
4636
if (!Ty)
4638
4637
return error (" Invalid record" );
4639
4638
4640
- // Phi arguments are pairs of records of [value, basic block].
4641
- // There is an optional final record for fast-math-flags if this phi has a
4642
- // floating-point type.
4643
- size_t NumArgs = (Record.size () - 1 ) / 2 ;
4644
- if ((Record.size () - 1 ) % 2 == 1 && !Ty->isFloatingPointTy ())
4645
- return error (" Invalid record" );
4646
-
4647
- PHINode *PN = PHINode::Create (Ty, NumArgs);
4639
+ PHINode *PN = PHINode::Create (Ty, (Record.size ()-1 )/2 );
4648
4640
InstructionList.push_back (PN);
4649
4641
4650
- for (unsigned i = 0 ; i != NumArgs ; i++ ) {
4642
+ for (unsigned i = 0 , e = Record. size ()- 1 ; i != e ; i += 2 ) {
4651
4643
Value *V;
4652
4644
// With the new function encoding, it is possible that operands have
4653
4645
// negative IDs (for forward references). Use a signed VBR
4654
4646
// representation to keep the encoding small.
4655
4647
if (UseRelativeIDs)
4656
- V = getValueSigned (Record, i * 2 + 1 , NextValueNo, Ty);
4648
+ V = getValueSigned (Record, 1 +i , NextValueNo, Ty);
4657
4649
else
4658
- V = getValue (Record, i * 2 + 1 , NextValueNo, Ty);
4659
- BasicBlock *BB = getBasicBlock (Record[i * 2 + 2 ]);
4650
+ V = getValue (Record, 1 +i , NextValueNo, Ty);
4651
+ BasicBlock *BB = getBasicBlock (Record[2 +i ]);
4660
4652
if (!V || !BB)
4661
4653
return error (" Invalid record" );
4662
4654
PN->addIncoming (V, BB);
4663
4655
}
4664
4656
I = PN;
4665
-
4666
- // If there are an even number of records, the final record must be FMF.
4667
- if (Record.size () % 2 == 0 ) {
4668
- assert (isa<FPMathOperator>(I) && " Unexpected phi type" );
4669
- FastMathFlags FMF = getDecodedFastMathFlags (Record[Record.size () - 1 ]);
4670
- if (FMF.any ())
4671
- I->setFastMathFlags (FMF);
4672
- }
4673
-
4674
4657
break ;
4675
4658
}
4676
4659
0 commit comments