54
54
55
55
using namespace llvm ;
56
56
57
- // Avoid large gaps in the NumberedVals vector.
58
- static const size_t MaxNumberedValSkip = 1000 ;
59
-
60
57
static std::string getTypeString (Type *T) {
61
58
std::string Result;
62
59
raw_string_ostream Tmp (Result);
@@ -2937,10 +2934,6 @@ bool LLParser::checkValueID(LocTy Loc, StringRef Kind, StringRef Prefix,
2937
2934
return error (Loc, Kind + " expected to be numbered '" + Prefix +
2938
2935
Twine (NextID) + " ' or greater" );
2939
2936
2940
- if (ID > NextID + MaxNumberedValSkip)
2941
- return error (Loc, " value numbers can skip at most " +
2942
- Twine (MaxNumberedValSkip) + " values" );
2943
-
2944
2937
return false ;
2945
2938
}
2946
2939
@@ -3304,8 +3297,7 @@ LLParser::PerFunctionState::PerFunctionState(LLParser &p, Function &f,
3304
3297
for (Argument &A : F.args ()) {
3305
3298
if (!A.hasName ()) {
3306
3299
unsigned ArgNum = *It++;
3307
- NumberedVals.resize (ArgNum);
3308
- NumberedVals.push_back (&A);
3300
+ NumberedVals.add (ArgNum, &A);
3309
3301
}
3310
3302
}
3311
3303
}
@@ -3388,7 +3380,7 @@ Value *LLParser::PerFunctionState::getVal(const std::string &Name, Type *Ty,
3388
3380
3389
3381
Value *LLParser::PerFunctionState::getVal (unsigned ID, Type *Ty, LocTy Loc) {
3390
3382
// Look this name up in the normal function symbol table.
3391
- Value *Val = ID < NumberedVals.size () ? NumberedVals[ID] : nullptr ;
3383
+ Value *Val = NumberedVals.get (ID) ;
3392
3384
3393
3385
// If this is a forward reference for the value, see if we already created a
3394
3386
// forward ref record.
@@ -3436,9 +3428,9 @@ bool LLParser::PerFunctionState::setInstName(int NameID,
3436
3428
if (NameStr.empty ()) {
3437
3429
// If neither a name nor an ID was specified, just use the next ID.
3438
3430
if (NameID == -1 )
3439
- NameID = NumberedVals.size ();
3431
+ NameID = NumberedVals.getNext ();
3440
3432
3441
- if (P.checkValueID (NameLoc, " instruction" , " %" , NumberedVals.size (),
3433
+ if (P.checkValueID (NameLoc, " instruction" , " %" , NumberedVals.getNext (),
3442
3434
NameID))
3443
3435
return true ;
3444
3436
@@ -3455,10 +3447,7 @@ bool LLParser::PerFunctionState::setInstName(int NameID,
3455
3447
ForwardRefValIDs.erase (FI);
3456
3448
}
3457
3449
3458
- // Fill in skipped IDs using nullptr.
3459
- NumberedVals.resize (unsigned (NameID));
3460
-
3461
- NumberedVals.push_back (Inst);
3450
+ NumberedVals.add (NameID, Inst);
3462
3451
return false ;
3463
3452
}
3464
3453
@@ -3506,15 +3495,14 @@ BasicBlock *LLParser::PerFunctionState::defineBB(const std::string &Name,
3506
3495
BasicBlock *BB;
3507
3496
if (Name.empty ()) {
3508
3497
if (NameID != -1 ) {
3509
- if (P.checkValueID (Loc, " label" , " " , NumberedVals.size (), NameID))
3498
+ if (P.checkValueID (Loc, " label" , " " , NumberedVals.getNext (), NameID))
3510
3499
return nullptr ;
3511
3500
} else {
3512
- NameID = NumberedVals.size ();
3501
+ NameID = NumberedVals.getNext ();
3513
3502
}
3514
3503
BB = getBB (NameID, Loc);
3515
3504
if (!BB) {
3516
- P.error (Loc, " unable to create block numbered '" +
3517
- Twine (NumberedVals.size ()) + " '" );
3505
+ P.error (Loc, " unable to create block numbered '" + Twine (NameID) + " '" );
3518
3506
return nullptr ;
3519
3507
}
3520
3508
} else {
@@ -3532,8 +3520,7 @@ BasicBlock *LLParser::PerFunctionState::defineBB(const std::string &Name,
3532
3520
// Remove the block from forward ref sets.
3533
3521
if (Name.empty ()) {
3534
3522
ForwardRefValIDs.erase (NameID);
3535
- NumberedVals.resize (NameID);
3536
- NumberedVals.push_back (BB);
3523
+ NumberedVals.add (NameID, BB);
3537
3524
} else {
3538
3525
// BB forward references are already in the function symbol table.
3539
3526
ForwardRefVals.erase (Name);
0 commit comments