Bitcode: Simplify emission of METADATA_BLOCK
Refactor logic so that we know up-front whether to open a block and whether we need an MDString abbreviation. This is almost NFC, but will start emitting `MDString` abbreviations when the first record is not an `MDString`. llvm-svn: 225712
This commit is contained in:
@@ -282,7 +282,7 @@ static bool isIntOrIntVectorValue(const std::pair<const Value*, unsigned> &V) {
|
||||
return V.first->getType()->isIntOrIntVectorTy();
|
||||
}
|
||||
|
||||
ValueEnumerator::ValueEnumerator(const Module &M) {
|
||||
ValueEnumerator::ValueEnumerator(const Module &M) : HasMDString(false) {
|
||||
if (shouldPreserveBitcodeUseListOrder())
|
||||
UseListOrders = predictUseListOrder(M);
|
||||
|
||||
@@ -546,6 +546,8 @@ void ValueEnumerator::EnumerateMetadata(const Metadata *MD) {
|
||||
else if (auto *C = dyn_cast<ConstantAsMetadata>(MD))
|
||||
EnumerateValue(C->getValue());
|
||||
|
||||
HasMDString |= isa<MDString>(MD);
|
||||
|
||||
// Replace the dummy ID inserted above with the correct one. MDValueMap may
|
||||
// have changed by inserting operands, so we need a fresh lookup here.
|
||||
MDs.push_back(MD);
|
||||
|
||||
Reference in New Issue
Block a user