summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/VMCore')
-rw-r--r--llvm/lib/VMCore/Metadata.cpp7
-rw-r--r--llvm/lib/VMCore/Module.cpp8
-rw-r--r--llvm/lib/VMCore/Value.cpp4
3 files changed, 17 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/Metadata.cpp b/llvm/lib/VMCore/Metadata.cpp
index 73f89caa388..2f6c153a9d7 100644
--- a/llvm/lib/VMCore/Metadata.cpp
+++ b/llvm/lib/VMCore/Metadata.cpp
@@ -13,6 +13,7 @@
#include "llvm/Metadata.h"
#include "llvm/Module.h"
+#include "SymbolTableListTraitsImpl.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
@@ -36,9 +37,11 @@ NamedMDNode::NamedMDNode(const char *N, unsigned NameLength,
MetadataBase*const* MDs, unsigned NumMDs,
Module *M)
: MetadataBase(Type::MetadataTy, Value::NamedMDNodeVal),
- Parent(M), Name(N, NameLength) {
+ Name(N, NameLength) {
+ setName(N);
for (unsigned i = 0; i != NumMDs; ++i)
Node.push_back(WeakMetadataVH(MDs[i]));
- // FIXME : Add into the parent module.
+ if (M)
+ M->getNamedMDList().push_back(this);
}
diff --git a/llvm/lib/VMCore/Module.cpp b/llvm/lib/VMCore/Module.cpp
index 35db8d25b5b..c9d599eb953 100644
--- a/llvm/lib/VMCore/Module.cpp
+++ b/llvm/lib/VMCore/Module.cpp
@@ -67,6 +67,7 @@ Module::~Module() {
FunctionList.clear();
AliasList.clear();
LibraryList.clear();
+ NamedMDList.clear();
delete ValSymTab;
delete TypeSymTab;
}
@@ -288,6 +289,13 @@ GlobalAlias *Module::getNamedAlias(const StringRef &Name) const {
return dyn_cast_or_null<GlobalAlias>(getNamedValue(Name));
}
+/// getNamedMetadata - Return the first named MDNode in the module with the
+/// specified name. This method returns null if a MDNode with the specified
+/// name is not found.
+NamedMDNode *Module::getNamedMetadata(const StringRef &Name) const {
+ return dyn_cast_or_null<NamedMDNode>(getNamedValue(Name));
+}
+
//===----------------------------------------------------------------------===//
// Methods for easy access to the types in the module.
//
diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp
index af13973e830..2cdd55217cc 100644
--- a/llvm/lib/VMCore/Value.cpp
+++ b/llvm/lib/VMCore/Value.cpp
@@ -142,6 +142,10 @@ static bool getSymTab(Value *V, ValueSymbolTable *&ST) {
} else if (Argument *A = dyn_cast<Argument>(V)) {
if (Function *P = A->getParent())
ST = &P->getValueSymbolTable();
+ } else if (NamedMDNode *N = dyn_cast<NamedMDNode>(V)) {
+ if (Module *P = N->getParent()) {
+ ST = &P->getValueSymbolTable();
+ }
} else if (isa<MDString>(V))
return true;
else {
OpenPOWER on IntegriCloud