[llvm] r264552 - BitcodeWriter: Simplify tracking of function-local metadata, NFC
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 27 16:22:31 PDT 2016
Author: dexonsmith
Date: Sun Mar 27 18:22:31 2016
New Revision: 264552
URL: http://llvm.org/viewvc/llvm-project?rev=264552&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=264552&r1=264551&r2=264552&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Sun Mar 27 18:22:31 2016
@@ -1431,15 +1431,13 @@ static void WriteFunctionLocalMetadata(c
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)
Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=264552&r1=264551&r2=264552&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Sun Mar 27 18:22:31 2016
@@ -554,9 +554,6 @@ void ValueEnumerator::EnumerateFunctionL
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,
Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h?rev=264552&r1=264551&r2=264552&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h Sun Mar 27 18:22:31 2016
@@ -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; }
More information about the llvm-commits
mailing list