[llvm] r220337 - IR: Remove dead code in metadata bitcode writing, NFC
Duncan P. N. Exon Smith
dexonsmith at apple.com
Tue Oct 21 15:13:34 PDT 2014
Author: dexonsmith
Date: Tue Oct 21 17:13:34 2014
New Revision: 220337
URL: http://llvm.org/viewvc/llvm-project?rev=220337&view=rev
Log:
IR: Remove dead code in metadata bitcode writing, NFC
No one cares how many uses each metadata value has, so don't bother
counting.
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=220337&r1=220336&r2=220337&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Oct 21 17:13:34 2014
@@ -756,13 +756,13 @@ static void WriteMDNode(const MDNode *N,
static void WriteModuleMetadata(const Module *M,
const ValueEnumerator &VE,
BitstreamWriter &Stream) {
- const ValueEnumerator::ValueList &Vals = VE.getMDValues();
+ const auto &Vals = VE.getMDValues();
bool StartedMetadataBlock = false;
unsigned MDSAbbrev = 0;
SmallVector<uint64_t, 64> Record;
for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
- if (const MDNode *N = dyn_cast<MDNode>(Vals[i].first)) {
+ if (const MDNode *N = dyn_cast<MDNode>(Vals[i])) {
if (!N->isFunctionLocal() || !N->getFunction()) {
if (!StartedMetadataBlock) {
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
@@ -770,7 +770,7 @@ static void WriteModuleMetadata(const Mo
}
WriteMDNode(N, VE, Stream, Record);
}
- } else if (const MDString *MDS = dyn_cast<MDString>(Vals[i].first)) {
+ } else if (const MDString *MDS = dyn_cast<MDString>(Vals[i])) {
if (!StartedMetadataBlock) {
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=220337&r1=220336&r2=220337&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Tue Oct 21 17:13:34 2014
@@ -509,12 +509,10 @@ void ValueEnumerator::EnumerateMetadata(
// Check to see if it's already in!
unsigned &MDValueID = MDValueMap[MD];
- if (MDValueID) {
- // Increment use count.
- MDValues[MDValueID-1].second++;
+ if (MDValueID)
return;
- }
- MDValues.push_back(std::make_pair(MD, 1U));
+
+ MDValues.push_back(MD);
MDValueID = MDValues.size();
// Enumerate all non-function-local operands.
@@ -533,12 +531,10 @@ void ValueEnumerator::EnumerateFunctionL
// Check to see if it's already in!
unsigned &MDValueID = MDValueMap[N];
- if (MDValueID) {
- // Increment use count.
- MDValues[MDValueID-1].second++;
+ if (MDValueID)
return;
- }
- MDValues.push_back(std::make_pair(N, 1U));
+
+ MDValues.push_back(N);
MDValueID = MDValues.size();
// To incoroporate function-local information visit all function-local
@@ -766,7 +762,7 @@ void ValueEnumerator::purgeFunction() {
for (unsigned i = NumModuleValues, e = Values.size(); i != e; ++i)
ValueMap.erase(Values[i].first);
for (unsigned i = NumModuleMDValues, e = MDValues.size(); i != e; ++i)
- MDValueMap.erase(MDValues[i].first);
+ MDValueMap.erase(MDValues[i]);
for (unsigned i = 0, e = BasicBlocks.size(); i != e; ++i)
ValueMap.erase(BasicBlocks[i]);
Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h?rev=220337&r1=220336&r2=220337&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h Tue Oct 21 17:13:34 2014
@@ -58,7 +58,7 @@ private:
typedef UniqueVector<const Comdat *> ComdatSetType;
ComdatSetType Comdats;
- ValueList MDValues;
+ std::vector<const Value *> MDValues;
SmallVector<const MDNode *, 8> FunctionLocalMDs;
ValueMapType MDValueMap;
@@ -134,7 +134,7 @@ public:
}
const ValueList &getValues() const { return Values; }
- const ValueList &getMDValues() const { return MDValues; }
+ const std::vector<const Value *> &getMDValues() const { return MDValues; }
const SmallVectorImpl<const MDNode *> &getFunctionLocalMDValues() const {
return FunctionLocalMDs;
}
More information about the llvm-commits
mailing list