aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bitcode/Writer/ValueEnumerator.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-07-21 23:38:33 +0000
committerDan Gohman <gohman@apple.com>2010-07-21 23:38:33 +0000
commit17aa92c92a925b4a674440c7ef088c223990e854 (patch)
treebc129644ee9db39dc25a41c22ce01b14ede5728f /lib/Bitcode/Writer/ValueEnumerator.cpp
parentfcbd1a749f9db4bf144a3343c4d707e1de087a7e (diff)
downloadexternal_llvm-17aa92c92a925b4a674440c7ef088c223990e854.zip
external_llvm-17aa92c92a925b4a674440c7ef088c223990e854.tar.gz
external_llvm-17aa92c92a925b4a674440c7ef088c223990e854.tar.bz2
Make NamedMDNode not be a subclass of Value, and simplify the interface
for creating and populating NamedMDNodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109061 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Writer/ValueEnumerator.cpp')
-rw-r--r--lib/Bitcode/Writer/ValueEnumerator.cpp29
1 files changed, 7 insertions, 22 deletions
diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp
index 7be6dda..930c521 100644
--- a/lib/Bitcode/Writer/ValueEnumerator.cpp
+++ b/lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -75,7 +75,7 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
// Insert constants and metadata that are named at module level into the slot
// pool so that the module symbol table can refer to them...
EnumerateValueSymbolTable(M->getValueSymbolTable());
- EnumerateMDSymbolTable(M->getMDSymbolTable());
+ EnumerateNamedMetadata(M);
SmallVector<std::pair<unsigned, MDNode*>, 8> MDs;
@@ -207,31 +207,18 @@ void ValueEnumerator::EnumerateValueSymbolTable(const ValueSymbolTable &VST) {
EnumerateValue(VI->getValue());
}
-/// EnumerateMDSymbolTable - Insert all of the values in the specified metadata
-/// table.
-void ValueEnumerator::EnumerateMDSymbolTable(const MDSymbolTable &MST) {
- for (MDSymbolTable::const_iterator MI = MST.begin(), ME = MST.end();
- MI != ME; ++MI)
- EnumerateValue(MI->getValue());
+/// EnumerateNamedMetadata - Insert all of the values referenced by
+/// named metadata in the specified module.
+void ValueEnumerator::EnumerateNamedMetadata(const Module *M) {
+ for (Module::const_named_metadata_iterator I = M->named_metadata_begin(),
+ E = M->named_metadata_end(); I != E; ++I)
+ EnumerateNamedMDNode(I);
}
void ValueEnumerator::EnumerateNamedMDNode(const NamedMDNode *MD) {
- // Check to see if it's already in!
- unsigned &MDValueID = MDValueMap[MD];
- if (MDValueID) {
- // Increment use count.
- MDValues[MDValueID-1].second++;
- return;
- }
-
- // Enumerate the type of this value.
- EnumerateType(MD->getType());
-
for (unsigned i = 0, e = MD->getNumOperands(); i != e; ++i)
if (MDNode *E = MD->getOperand(i))
EnumerateValue(E);
- MDValues.push_back(std::make_pair(MD, 1U));
- MDValueMap[MD] = Values.size();
}
void ValueEnumerator::EnumerateMetadata(const Value *MD) {
@@ -272,8 +259,6 @@ void ValueEnumerator::EnumerateValue(const Value *V) {
assert(!V->getType()->isVoidTy() && "Can't insert void values!");
if (isa<MDNode>(V) || isa<MDString>(V))
return EnumerateMetadata(V);
- else if (const NamedMDNode *NMD = dyn_cast<NamedMDNode>(V))
- return EnumerateNamedMDNode(NMD);
// Check to see if it's already in!
unsigned &ValueID = ValueMap[V];