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`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225712 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-01-12 22:30:34 +00:00
parent 0c51e0a826
commit 8d86cef92f
3 changed files with 33 additions and 37 deletions
+3 -1
View File
@@ -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);