@@ -1351,25 +1351,22 @@ bool MDAttachments::erase(unsigned ID) {
1351
1351
return OldSize != Attachments.size ();
1352
1352
}
1353
1353
1354
- MDNode *Value::getMetadata (unsigned KindID ) const {
1354
+ MDNode *Value::getMetadata (StringRef Kind ) const {
1355
1355
if (!hasMetadata ())
1356
1356
return nullptr ;
1357
- const auto &Info = getContext ().pImpl ->ValueMetadata [this ];
1358
- assert (!Info.empty () && " bit out of sync with hash table" );
1359
- return Info.lookup (KindID);
1357
+ unsigned KindID = getContext ().getMDKindID (Kind);
1358
+ return getMetadataImpl (KindID);
1360
1359
}
1361
1360
1362
- MDNode *Value::getMetadata (StringRef Kind) const {
1363
- if (!hasMetadata ())
1364
- return nullptr ;
1365
- const auto &Info = getContext ().pImpl ->ValueMetadata [this ];
1366
- assert (!Info.empty () && " bit out of sync with hash table" );
1367
- return Info.lookup (getContext ().getMDKindID (Kind));
1361
+ MDNode *Value::getMetadataImpl (unsigned KindID) const {
1362
+ const LLVMContext &Ctx = getContext ();
1363
+ const MDAttachments &Attachements = Ctx.pImpl ->ValueMetadata .at (this );
1364
+ return Attachements.lookup (KindID);
1368
1365
}
1369
1366
1370
1367
void Value::getMetadata (unsigned KindID, SmallVectorImpl<MDNode *> &MDs) const {
1371
1368
if (hasMetadata ())
1372
- getContext ().pImpl ->ValueMetadata [ this ] .get (KindID, MDs);
1369
+ getContext ().pImpl ->ValueMetadata . at ( this ) .get (KindID, MDs);
1373
1370
}
1374
1371
1375
1372
void Value::getMetadata (StringRef Kind, SmallVectorImpl<MDNode *> &MDs) const {
@@ -1382,8 +1379,7 @@ void Value::getAllMetadata(
1382
1379
if (hasMetadata ()) {
1383
1380
assert (getContext ().pImpl ->ValueMetadata .count (this ) &&
1384
1381
" bit out of sync with hash table" );
1385
- const auto &Info = getContext ().pImpl ->ValueMetadata .find (this )->second ;
1386
- assert (!Info.empty () && " Shouldn't have called this" );
1382
+ const MDAttachments &Info = getContext ().pImpl ->ValueMetadata .at (this );
1387
1383
Info.getAll (MDs);
1388
1384
}
1389
1385
}
@@ -1393,7 +1389,7 @@ void Value::setMetadata(unsigned KindID, MDNode *Node) {
1393
1389
1394
1390
// Handle the case when we're adding/updating metadata on a value.
1395
1391
if (Node) {
1396
- auto &Info = getContext ().pImpl ->ValueMetadata [this ];
1392
+ MDAttachments &Info = getContext ().pImpl ->ValueMetadata [this ];
1397
1393
assert (!Info.empty () == HasMetadata && " bit out of sync with hash table" );
1398
1394
if (Info.empty ())
1399
1395
HasMetadata = true ;
@@ -1406,7 +1402,7 @@ void Value::setMetadata(unsigned KindID, MDNode *Node) {
1406
1402
" bit out of sync with hash table" );
1407
1403
if (!HasMetadata)
1408
1404
return ; // Nothing to remove!
1409
- auto &Info = getContext ().pImpl ->ValueMetadata [ this ] ;
1405
+ MDAttachments &Info = getContext ().pImpl ->ValueMetadata . find ( this )-> second ;
1410
1406
1411
1407
// Handle removal of an existing value.
1412
1408
Info.erase (KindID);
@@ -1438,7 +1434,7 @@ bool Value::eraseMetadata(unsigned KindID) {
1438
1434
if (!HasMetadata)
1439
1435
return false ;
1440
1436
1441
- auto &Store = getContext ().pImpl ->ValueMetadata [ this ] ;
1437
+ MDAttachments &Store = getContext ().pImpl ->ValueMetadata . find ( this )-> second ;
1442
1438
bool Changed = Store.erase (KindID);
1443
1439
if (Store.empty ())
1444
1440
clearMetadata ();
@@ -1461,7 +1457,11 @@ void Instruction::setMetadata(StringRef Kind, MDNode *Node) {
1461
1457
}
1462
1458
1463
1459
MDNode *Instruction::getMetadataImpl (StringRef Kind) const {
1464
- return getMetadataImpl (getContext ().getMDKindID (Kind));
1460
+ const LLVMContext &Ctx = getContext ();
1461
+ unsigned KindID = Ctx.getMDKindID (Kind);
1462
+ if (KindID == LLVMContext::MD_dbg)
1463
+ return DbgLoc.getAsMDNode ();
1464
+ return Value::getMetadata (KindID);
1465
1465
}
1466
1466
1467
1467
void Instruction::dropUnknownNonDebugMetadata (ArrayRef<unsigned > KnownIDs) {
@@ -1475,7 +1475,7 @@ void Instruction::dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs) {
1475
1475
KnownSet.insert (LLVMContext::MD_DIAssignID);
1476
1476
1477
1477
auto &MetadataStore = getContext ().pImpl ->ValueMetadata ;
1478
- auto &Info = MetadataStore[ this ] ;
1478
+ MDAttachments &Info = MetadataStore. find ( this )-> second ;
1479
1479
assert (!Info.empty () && " bit out of sync with hash table" );
1480
1480
Info.remove_if ([&KnownSet](const MDAttachments::Attachment &I) {
1481
1481
return !KnownSet.count (I.MDKind );
@@ -1598,7 +1598,7 @@ AAMDNodes Instruction::getAAMetadata() const {
1598
1598
// Not using Instruction::hasMetadata() because we're not interested in
1599
1599
// DebugInfoMetadata.
1600
1600
if (Value::hasMetadata ()) {
1601
- const auto &Info = getContext ().pImpl ->ValueMetadata [ this ] ;
1601
+ const MDAttachments &Info = getContext ().pImpl ->ValueMetadata . at ( this ) ;
1602
1602
Result.TBAA = Info.lookup (LLVMContext::MD_tbaa);
1603
1603
Result.TBAAStruct = Info.lookup (LLVMContext::MD_tbaa_struct);
1604
1604
Result.Scope = Info.lookup (LLVMContext::MD_alias_scope);
@@ -1619,13 +1619,6 @@ void Instruction::setNoSanitizeMetadata() {
1619
1619
llvm::MDNode::get (getContext (), std::nullopt));
1620
1620
}
1621
1621
1622
- MDNode *Instruction::getMetadataImpl (unsigned KindID) const {
1623
- // Handle 'dbg' as a special case since it is not stored in the hash table.
1624
- if (KindID == LLVMContext::MD_dbg)
1625
- return DbgLoc.getAsMDNode ();
1626
- return Value::getMetadata (KindID);
1627
- }
1628
-
1629
1622
void Instruction::getAllMetadataImpl (
1630
1623
SmallVectorImpl<std::pair<unsigned , MDNode *>> &Result) const {
1631
1624
Result.clear ();
0 commit comments