forked from OSchip/llvm-project
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:
parent
6565a0d4b2
commit
2766e4d488
|
@ -1431,15 +1431,13 @@ static void WriteFunctionLocalMetadata(const Function &F,
|
||||||
BitstreamWriter &Stream) {
|
BitstreamWriter &Stream) {
|
||||||
bool StartedMetadataBlock = false;
|
bool StartedMetadataBlock = false;
|
||||||
SmallVector<uint64_t, 64> Record;
|
SmallVector<uint64_t, 64> Record;
|
||||||
const SmallVectorImpl<const LocalAsMetadata *> &MDs =
|
for (const Metadata *MD : VE.getFunctionMDs()) {
|
||||||
VE.getFunctionLocalMDs();
|
auto *Local = cast<LocalAsMetadata>(MD);
|
||||||
for (unsigned i = 0, e = MDs.size(); i != e; ++i) {
|
|
||||||
assert(MDs[i] && "Expected valid function-local metadata");
|
|
||||||
if (!StartedMetadataBlock) {
|
if (!StartedMetadataBlock) {
|
||||||
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
|
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
|
||||||
StartedMetadataBlock = true;
|
StartedMetadataBlock = true;
|
||||||
}
|
}
|
||||||
WriteValueAsMetadata(MDs[i], VE, Stream, Record);
|
WriteValueAsMetadata(Local, VE, Stream, Record);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StartedMetadataBlock)
|
if (StartedMetadataBlock)
|
||||||
|
|
|
@ -554,9 +554,6 @@ void ValueEnumerator::EnumerateFunctionLocalMetadata(
|
||||||
MetadataID = MDs.size();
|
MetadataID = MDs.size();
|
||||||
|
|
||||||
EnumerateValue(Local->getValue());
|
EnumerateValue(Local->getValue());
|
||||||
|
|
||||||
// Also, collect all function-local metadata for easy access.
|
|
||||||
FunctionLocalMDs.push_back(Local);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValueEnumerator::organizeMetadata() {
|
void ValueEnumerator::organizeMetadata() {
|
||||||
|
@ -778,7 +775,6 @@ void ValueEnumerator::purgeFunction() {
|
||||||
Values.resize(NumModuleValues);
|
Values.resize(NumModuleValues);
|
||||||
MDs.resize(NumModuleMDs);
|
MDs.resize(NumModuleMDs);
|
||||||
BasicBlocks.clear();
|
BasicBlocks.clear();
|
||||||
FunctionLocalMDs.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IncorporateFunctionInfoGlobalBBIDs(const Function *F,
|
static void IncorporateFunctionInfoGlobalBBIDs(const Function *F,
|
||||||
|
|
|
@ -63,7 +63,6 @@ private:
|
||||||
ComdatSetType Comdats;
|
ComdatSetType Comdats;
|
||||||
|
|
||||||
std::vector<const Metadata *> MDs;
|
std::vector<const Metadata *> MDs;
|
||||||
SmallVector<const LocalAsMetadata *, 8> FunctionLocalMDs;
|
|
||||||
typedef DenseMap<const Metadata *, unsigned> MetadataMapType;
|
typedef DenseMap<const Metadata *, unsigned> MetadataMapType;
|
||||||
MetadataMapType MetadataMap;
|
MetadataMapType MetadataMap;
|
||||||
unsigned NumMDStrings = 0;
|
unsigned NumMDStrings = 0;
|
||||||
|
@ -161,8 +160,8 @@ public:
|
||||||
ArrayRef<const Metadata *> getNonMDStrings() const {
|
ArrayRef<const Metadata *> getNonMDStrings() const {
|
||||||
return makeArrayRef(MDs).slice(NumMDStrings);
|
return makeArrayRef(MDs).slice(NumMDStrings);
|
||||||
}
|
}
|
||||||
const SmallVectorImpl<const LocalAsMetadata *> &getFunctionLocalMDs() const {
|
ArrayRef<const Metadata *> getFunctionMDs() const {
|
||||||
return FunctionLocalMDs;
|
return makeArrayRef(MDs).slice(NumModuleMDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TypeList &getTypes() const { return Types; }
|
const TypeList &getTypes() const { return Types; }
|
||||||
|
|
Loading…
Reference in New Issue