Final step in the metadata API restructuring: move the
[oota-llvm.git] / lib / AsmParser / LLParser.cpp
index 48b6e87e04d0c6734ddac794f524f7641080bef0..351245d8e871058300ef536b243e20d8b8f203e3 100644 (file)
@@ -18,8 +18,6 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/InlineAsm.h"
 #include "llvm/Instructions.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Metadata.h"
 #include "llvm/Module.h"
 #include "llvm/Operator.h"
 #include "llvm/ValueSymbolTable.h"
@@ -1122,12 +1120,8 @@ bool LLParser::ParseOptionalCustomMetadata() {
   MetadataBase *Node;
   if (ParseMDNode(Node)) return true;
 
-  MetadataContext &TheMetadata = M->getContext().getMetadata();
-  unsigned MDK = TheMetadata.getMDKind(Name.c_str());
-  if (!MDK)
-    MDK = TheMetadata.registerMDKind(Name.c_str());
+  unsigned MDK = M->getMDKindID(Name.c_str());
   MDsOnInst.push_back(std::make_pair(MDK, cast<MDNode>(Node)));
-
   return false;
 }
 
@@ -2829,10 +2823,9 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) {
       ParseOptionalCustomMetadata();
 
     // Set metadata attached with this instruction.
-    MetadataContext &TheMetadata = M->getContext().getMetadata();
     for (SmallVector<std::pair<unsigned, MDNode *>, 2>::iterator
            MDI = MDsOnInst.begin(), MDE = MDsOnInst.end(); MDI != MDE; ++MDI)
-      TheMetadata.addMD(MDI->first, MDI->second, Inst);
+      Inst->setMetadata(MDI->first, MDI->second);
     MDsOnInst.clear();
 
     BB->getInstList().push_back(Inst);