BitcodeWriter: Simplify tracking of function-local metadata, NFC

We don't really need a separate vector here; instead, point at a range
inside the main MDs array.  This matches how r264551 references the
ranges of strings and non-strings.

llvm-svn: 264552
This commit is contained in:
Duncan P. N. Exon Smith 2016-03-27 23:22:31 +00:00
parent 6565a0d4b2
commit 2766e4d488
3 changed files with 5 additions and 12 deletions

View File

@ -1431,15 +1431,13 @@ static void WriteFunctionLocalMetadata(const Function &F,
BitstreamWriter &Stream) {
bool StartedMetadataBlock = false;
SmallVector<uint64_t, 64> Record;
const SmallVectorImpl<const LocalAsMetadata *> &MDs =
VE.getFunctionLocalMDs();
for (unsigned i = 0, e = MDs.size(); i != e; ++i) {
assert(MDs[i] && "Expected valid function-local metadata");
for (const Metadata *MD : VE.getFunctionMDs()) {
auto *Local = cast<LocalAsMetadata>(MD);
if (!StartedMetadataBlock) {
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
StartedMetadataBlock = true;
}
WriteValueAsMetadata(MDs[i], VE, Stream, Record);
WriteValueAsMetadata(Local, VE, Stream, Record);
}
if (StartedMetadataBlock)

View File

@ -554,9 +554,6 @@ void ValueEnumerator::EnumerateFunctionLocalMetadata(
MetadataID = MDs.size();
EnumerateValue(Local->getValue());
// Also, collect all function-local metadata for easy access.
FunctionLocalMDs.push_back(Local);
}
void ValueEnumerator::organizeMetadata() {
@ -778,7 +775,6 @@ void ValueEnumerator::purgeFunction() {
Values.resize(NumModuleValues);
MDs.resize(NumModuleMDs);
BasicBlocks.clear();
FunctionLocalMDs.clear();
}
static void IncorporateFunctionInfoGlobalBBIDs(const Function *F,

View File

@ -63,7 +63,6 @@ private:
ComdatSetType Comdats;
std::vector<const Metadata *> MDs;
SmallVector<const LocalAsMetadata *, 8> FunctionLocalMDs;
typedef DenseMap<const Metadata *, unsigned> MetadataMapType;
MetadataMapType MetadataMap;
unsigned NumMDStrings = 0;
@ -161,8 +160,8 @@ public:
ArrayRef<const Metadata *> getNonMDStrings() const {
return makeArrayRef(MDs).slice(NumMDStrings);
}
const SmallVectorImpl<const LocalAsMetadata *> &getFunctionLocalMDs() const {
return FunctionLocalMDs;
ArrayRef<const Metadata *> getFunctionMDs() const {
return makeArrayRef(MDs).slice(NumModuleMDs);
}
const TypeList &getTypes() const { return Types; }