mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
Bitcode: Add ValueEnumerator::getMetadataOrNullID(), NFC
llvm-svn: 226533
This commit is contained in:
parent
399f517a79
commit
fc8503a473
@ -768,12 +768,9 @@ static void WriteMDNode(const MDNode *N,
|
||||
SmallVectorImpl<uint64_t> &Record) {
|
||||
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
|
||||
Metadata *MD = N->getOperand(i);
|
||||
if (!MD) {
|
||||
Record.push_back(0);
|
||||
continue;
|
||||
}
|
||||
assert(!isa<LocalAsMetadata>(MD) && "Unexpected function-local metadata");
|
||||
Record.push_back(VE.getMetadataID(MD) + 1);
|
||||
assert(!(MD && isa<LocalAsMetadata>(MD)) &&
|
||||
"Unexpected function-local metadata");
|
||||
Record.push_back(VE.getMetadataOrNullID(MD));
|
||||
}
|
||||
Stream.EmitRecord(N->isDistinct() ? bitc::METADATA_DISTINCT_NODE
|
||||
: bitc::METADATA_NODE,
|
||||
@ -789,12 +786,7 @@ static void WriteMDLocation(const MDLocation *N, const ValueEnumerator &VE,
|
||||
Record.push_back(N->getLine());
|
||||
Record.push_back(N->getColumn());
|
||||
Record.push_back(VE.getMetadataID(N->getScope()));
|
||||
|
||||
// Always emit the inlined-at location, even though it's optional.
|
||||
if (Metadata *InlinedAt = N->getInlinedAt())
|
||||
Record.push_back(VE.getMetadataID(InlinedAt) + 1);
|
||||
else
|
||||
Record.push_back(0);
|
||||
Record.push_back(VE.getMetadataOrNullID(N->getInlinedAt()));
|
||||
|
||||
Stream.EmitRecord(bitc::METADATA_LOCATION, Record, Abbrev);
|
||||
Record.clear();
|
||||
@ -1754,8 +1746,8 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE,
|
||||
|
||||
Vals.push_back(DL.getLine());
|
||||
Vals.push_back(DL.getCol());
|
||||
Vals.push_back(Scope ? VE.getMetadataID(Scope) + 1 : 0);
|
||||
Vals.push_back(IA ? VE.getMetadataID(IA) + 1 : 0);
|
||||
Vals.push_back(VE.getMetadataOrNullID(Scope));
|
||||
Vals.push_back(VE.getMetadataOrNullID(IA));
|
||||
Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC, Vals);
|
||||
Vals.clear();
|
||||
|
||||
|
@ -410,12 +410,6 @@ unsigned ValueEnumerator::getValueID(const Value *V) const {
|
||||
return I->second-1;
|
||||
}
|
||||
|
||||
unsigned ValueEnumerator::getMetadataID(const Metadata *MD) const {
|
||||
auto I = MDValueMap.find(MD);
|
||||
assert(I != MDValueMap.end() && "Metadata not in slotcalculator!");
|
||||
return I->second - 1;
|
||||
}
|
||||
|
||||
void ValueEnumerator::dump() const {
|
||||
print(dbgs(), ValueMap, "Default");
|
||||
dbgs() << '\n';
|
||||
|
@ -109,7 +109,14 @@ public:
|
||||
const char *Name) const;
|
||||
|
||||
unsigned getValueID(const Value *V) const;
|
||||
unsigned getMetadataID(const Metadata *V) const;
|
||||
unsigned getMetadataID(const Metadata *MD) const {
|
||||
auto ID = getMetadataOrNullID(MD);
|
||||
assert(ID != 0 && "Metadata not in slotcalculator!");
|
||||
return ID - 1;
|
||||
}
|
||||
unsigned getMetadataOrNullID(const Metadata *MD) const {
|
||||
return MDValueMap.lookup(MD);
|
||||
}
|
||||
|
||||
bool hasMDString() const { return HasMDString; }
|
||||
bool hasMDLocation() const { return HasMDLocation; }
|
||||
|
Loading…
Reference in New Issue
Block a user