IR: Give 'DI' prefix to debug info metadata

Finish off PR23080 by renaming the debug info IR constructs from `MD*`
to `DI*`.  The last of the `DIDescriptor` classes were deleted in
r235356, and the last of the related typedefs removed in r235413, so
this has all baked for about a week.

Note: If you have out-of-tree code (like a frontend), I recommend that
you get everything compiling and tests passing with the *previous*
commit before updating to this one.  It'll be easier to keep track of
what code is using the `DIDescriptor` hierarchy and what you've already
updated, and I think you're extremely unlikely to insert bugs.  YMMV of
course.

Back to *this* commit: I did this using the rename-md-di-nodes.sh
upgrade script I've attached to PR23080 (both code and testcases) and
filtered through clang-format-diff.py.  I edited the tests for
test/Assembler/invalid-generic-debug-node-*.ll by hand since the columns
were off-by-three.  It should work on your out-of-tree testcases (and
code, if you've followed the advice in the previous paragraph).

Some of the tests are in badly named files now (e.g.,
test/Assembler/invalid-mdcompositetype-missing-tag.ll should be
'dicompositetype'); I'll come back and move the files in a follow-up
commit.

llvm-svn: 236120
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index a8fb9b7..d56a180 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -668,15 +668,15 @@
   raw_svector_ostream OS(Str);
   OS << "DEBUG_VALUE: ";
 
-  const MDLocalVariable *V = MI->getDebugVariable();
-  if (auto *SP = dyn_cast<MDSubprogram>(V->getScope())) {
+  const DILocalVariable *V = MI->getDebugVariable();
+  if (auto *SP = dyn_cast<DISubprogram>(V->getScope())) {
     StringRef Name = SP->getDisplayName();
     if (!Name.empty())
       OS << Name << ":";
   }
   OS << V->getName();
 
-  const MDExpression *Expr = MI->getDebugExpression();
+  const DIExpression *Expr = MI->getDebugExpression();
   if (Expr->isBitPiece())
     OS << " [bit_piece offset=" << Expr->getBitPieceOffset()
        << " size=" << Expr->getBitPieceSize() << "]";
diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp b/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
index 9cb0aab..3c46a99 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
@@ -204,7 +204,7 @@
       // Use the base variable (without any DW_OP_piece expressions)
       // as index into History. The full variables including the
       // piece expressions are attached to the MI.
-      const MDLocalVariable *RawVar = MI.getDebugVariable();
+      const DILocalVariable *RawVar = MI.getDebugVariable();
       assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) &&
              "Expected inlined-at fields to agree");
       InlinedVariable Var(RawVar, MI.getDebugLoc()->getInlinedAt());
diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h b/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h
index c25aaff..546d1b4 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h
@@ -17,8 +17,8 @@
 
 class MachineFunction;
 class MachineInstr;
-class MDLocalVariable;
-class MDLocation;
+class DILocalVariable;
+class DILocation;
 class TargetRegisterInfo;
 
 // For each user variable, keep a list of instruction ranges where this variable
@@ -32,7 +32,7 @@
 public:
   typedef std::pair<const MachineInstr *, const MachineInstr *> InstrRange;
   typedef SmallVector<InstrRange, 4> InstrRanges;
-  typedef std::pair<const MDLocalVariable *, const MDLocation *>
+  typedef std::pair<const DILocalVariable *, const DILocation *>
       InlinedVariable;
   typedef MapVector<InlinedVariable, InstrRanges> InstrRangesMap;
 
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
index ff3eb03..6a943c6 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
@@ -29,25 +29,25 @@
 public:
   /// \brief A single location or constant.
   struct Value {
-    Value(const MDExpression *Expr, int64_t i)
+    Value(const DIExpression *Expr, int64_t i)
         : Expression(Expr), EntryKind(E_Integer) {
       Constant.Int = i;
     }
-    Value(const MDExpression *Expr, const ConstantFP *CFP)
+    Value(const DIExpression *Expr, const ConstantFP *CFP)
         : Expression(Expr), EntryKind(E_ConstantFP) {
       Constant.CFP = CFP;
     }
-    Value(const MDExpression *Expr, const ConstantInt *CIP)
+    Value(const DIExpression *Expr, const ConstantInt *CIP)
         : Expression(Expr), EntryKind(E_ConstantInt) {
       Constant.CIP = CIP;
     }
-    Value(const MDExpression *Expr, MachineLocation Loc)
+    Value(const DIExpression *Expr, MachineLocation Loc)
         : Expression(Expr), EntryKind(E_Location), Loc(Loc) {
-      assert(cast<MDExpression>(Expr)->isValid());
+      assert(cast<DIExpression>(Expr)->isValid());
     }
 
     /// Any complex address location expression for this Value.
-    const MDExpression *Expression;
+    const DIExpression *Expression;
 
     /// Type of entry that this represents.
     enum EntryType { E_Location, E_Integer, E_ConstantFP, E_ConstantInt };
@@ -72,7 +72,7 @@
     const ConstantInt *getConstantInt() const { return Constant.CIP; }
     MachineLocation getLoc() const { return Loc; }
     bool isBitPiece() const { return getExpression()->isBitPiece(); }
-    const MDExpression *getExpression() const { return Expression; }
+    const DIExpression *getExpression() const { return Expression; }
     friend bool operator==(const Value &, const Value &);
     friend bool operator<(const Value &, const Value &);
   };
@@ -94,8 +94,8 @@
   /// Return true if the merge was successful.
   bool MergeValues(const DebugLocEntry &Next) {
     if (Begin == Next.Begin) {
-      auto *Expr = cast_or_null<MDExpression>(Values[0].Expression);
-      auto *NextExpr = cast_or_null<MDExpression>(Next.Values[0].Expression);
+      auto *Expr = cast_or_null<DIExpression>(Values[0].Expression);
+      auto *NextExpr = cast_or_null<DIExpression>(Next.Values[0].Expression);
       if (Expr->isBitPiece() && NextExpr->isBitPiece()) {
         addValues(Next.Values);
         End = Next.End;
@@ -143,7 +143,7 @@
 
   /// \brief Lower this entry into a DWARF expression.
   void finalize(const AsmPrinter &AP, DebugLocStream &Locs,
-                const MDBasicType *BT);
+                const DIBasicType *BT);
 };
 
 /// \brief Compare two Values for equality.
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 856920f..c10e703 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -16,7 +16,7 @@
 
 namespace llvm {
 
-DwarfCompileUnit::DwarfCompileUnit(unsigned UID, const MDCompileUnit *Node,
+DwarfCompileUnit::DwarfCompileUnit(unsigned UID, const DICompileUnit *Node,
                                    AsmPrinter *A, DwarfDebug *DW,
                                    DwarfFile *DWU)
     : DwarfUnit(UID, dwarf::DW_TAG_compile_unit, Node, A, DW, DWU),
@@ -98,7 +98,7 @@
 
 /// getOrCreateGlobalVariableDIE - get or create global variable DIE.
 DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
-    const MDGlobalVariable *GV) {
+    const DIGlobalVariable *GV) {
   // Check for pre-existence.
   if (DIE *Die = getDIE(GV))
     return Die;
@@ -114,7 +114,7 @@
 
   // Add to map.
   DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV);
-  MDScope *DeclContext;
+  DIScope *DeclContext;
   if (auto *SDMDecl = GV->getStaticDataMemberDeclaration()) {
     DeclContext = resolve(SDMDecl->getScope());
     assert(SDMDecl->isStaticMember() && "Expected static member decl");
@@ -277,7 +277,7 @@
 // Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
 // and DW_AT_high_pc attributes. If there are global variables in this
 // scope then create and insert DIEs for these variables.
-DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const MDSubprogram *SP) {
+DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) {
   DIE *SPDie = getOrCreateSubprogramDIE(SP, includeMinimalInlineScopes());
 
   attachLowHighPC(*SPDie, Asm->getFunctionBegin(), Asm->getFunctionEnd());
@@ -308,7 +308,7 @@
 
   auto *DS = Scope->getScopeNode();
 
-  assert((Scope->getInlinedAt() || !isa<MDSubprogram>(DS)) &&
+  assert((Scope->getInlinedAt() || !isa<DISubprogram>(DS)) &&
          "Only handle inlined subprograms here, use "
          "constructSubprogramScopeDIE for non-inlined "
          "subprograms");
@@ -319,7 +319,7 @@
   // avoid creating un-used children then removing them later when we find out
   // the scope DIE is null.
   std::unique_ptr<DIE> ScopeDIE;
-  if (Scope->getParent() && isa<MDSubprogram>(DS)) {
+  if (Scope->getParent() && isa<DISubprogram>(DS)) {
     ScopeDIE = constructInlinedScopeDIE(Scope);
     if (!ScopeDIE)
       return;
@@ -341,7 +341,7 @@
       // There is no need to emit empty lexical block DIE.
       for (const auto &E : DD->findImportedEntitiesForScope(DS))
         Children.push_back(
-            constructImportedEntityDIE(cast<MDImportedEntity>(E.second)));
+            constructImportedEntityDIE(cast<DIImportedEntity>(E.second)));
     }
 
     // If there are only other scopes as children, put them directly in the
@@ -432,7 +432,7 @@
   attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges());
 
   // Add the call site information to the DIE.
-  const MDLocation *IA = Scope->getInlinedAt();
+  const DILocation *IA = Scope->getInlinedAt();
   addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None,
           getOrCreateSourceID(IA->getFilename(), IA->getDirectory()));
   addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, IA->getLine());
@@ -563,14 +563,14 @@
   assert(Scope && Scope->getScopeNode());
   assert(!Scope->getInlinedAt());
   assert(!Scope->isAbstractScope());
-  auto *Sub = cast<MDSubprogram>(Scope->getScopeNode());
+  auto *Sub = cast<DISubprogram>(Scope->getScopeNode());
 
   DD->getProcessedSPNodes().insert(Sub);
 
   DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
 
   // If this is a variadic function, add an unspecified parameter.
-  MDTypeRefArray FnArgs = Sub->getType()->getTypeArray();
+  DITypeRefArray FnArgs = Sub->getType()->getTypeArray();
 
   // Collect lexical scope children first.
   // ObjectPointer might be a local (non-argument) local variable if it's a
@@ -605,7 +605,7 @@
   if (AbsDef)
     return;
 
-  auto *SP = cast<MDSubprogram>(Scope->getScopeNode());
+  auto *SP = cast<DISubprogram>(Scope->getScopeNode());
 
   DIE *ContextDIE;
 
@@ -633,18 +633,18 @@
 }
 
 std::unique_ptr<DIE>
-DwarfCompileUnit::constructImportedEntityDIE(const MDImportedEntity *Module) {
+DwarfCompileUnit::constructImportedEntityDIE(const DIImportedEntity *Module) {
   std::unique_ptr<DIE> IMDie = make_unique<DIE>((dwarf::Tag)Module->getTag());
   insertDIE(Module, IMDie.get());
   DIE *EntityDie;
   auto *Entity = resolve(Module->getEntity());
-  if (auto *NS = dyn_cast<MDNamespace>(Entity))
+  if (auto *NS = dyn_cast<DINamespace>(Entity))
     EntityDie = getOrCreateNameSpace(NS);
-  else if (auto *SP = dyn_cast<MDSubprogram>(Entity))
+  else if (auto *SP = dyn_cast<DISubprogram>(Entity))
     EntityDie = getOrCreateSubprogramDIE(SP);
-  else if (auto *T = dyn_cast<MDType>(Entity))
+  else if (auto *T = dyn_cast<DIType>(Entity))
     EntityDie = getOrCreateTypeDIE(T);
-  else if (auto *GV = dyn_cast<MDGlobalVariable>(Entity))
+  else if (auto *GV = dyn_cast<DIGlobalVariable>(Entity))
     EntityDie = getOrCreateGlobalVariableDIE(GV);
   else
     EntityDie = getDIE(Entity);
@@ -659,7 +659,7 @@
   return IMDie;
 }
 
-void DwarfCompileUnit::finishSubprogramDefinition(const MDSubprogram *SP) {
+void DwarfCompileUnit::finishSubprogramDefinition(const DISubprogram *SP) {
   DIE *D = getDIE(SP);
   if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) {
     if (D)
@@ -676,7 +676,7 @@
       applySubprogramAttributesToDefinition(SP, *D);
   }
 }
-void DwarfCompileUnit::collectDeadVariables(const MDSubprogram *SP) {
+void DwarfCompileUnit::collectDeadVariables(const DISubprogram *SP) {
   assert(SP && "CU's subprogram list contains a non-subprogram");
   assert(SP->isDefinition() &&
          "CU's subprogram list contains a subprogram declaration");
@@ -688,7 +688,7 @@
   if (!SPDIE)
     SPDIE = getDIE(SP);
   assert(SPDIE);
-  for (const MDLocalVariable *DV : Variables) {
+  for (const DILocalVariable *DV : Variables) {
     DbgVariable NewVar(DV, /* IA */ nullptr, /* Expr */ nullptr, DD);
     auto VariableDie = constructVariableDIE(NewVar);
     applyVariableAttributes(NewVar, *VariableDie);
@@ -708,7 +708,7 @@
 
 /// addGlobalName - Add a new global name to the compile unit.
 void DwarfCompileUnit::addGlobalName(StringRef Name, DIE &Die,
-                                     const MDScope *Context) {
+                                     const DIScope *Context) {
   if (includeMinimalInlineScopes())
     return;
   std::string FullName = getParentContextString(Context) + Name.str();
@@ -716,8 +716,8 @@
 }
 
 /// Add a new global type to the unit.
-void DwarfCompileUnit::addGlobalType(const MDType *Ty, const DIE &Die,
-                                     const MDScope *Context) {
+void DwarfCompileUnit::addGlobalType(const DIType *Ty, const DIE &Die,
+                                     const DIScope *Context) {
   if (includeMinimalInlineScopes())
     return;
   std::string FullName = getParentContextString(Context) + Ty->getName().str();
@@ -764,7 +764,7 @@
   DIELoc *Loc = new (DIEValueAllocator) DIELoc();
   DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
   assert(DV.getExpression().size() == 1);
-  const MDExpression *Expr = DV.getExpression().back();
+  const DIExpression *Expr = DV.getExpression().back();
   bool ValidReg;
   if (Location.getOffset()) {
     ValidReg = DwarfExpr.AddMachineRegIndirect(Location.getReg(),
@@ -807,7 +807,7 @@
 }
 
 void DwarfCompileUnit::applySubprogramAttributesToDefinition(
-    const MDSubprogram *SP, DIE &SPDie) {
+    const DISubprogram *SP, DIE &SPDie) {
   auto *SPDecl = SP->getDeclaration();
   auto *Context = resolve(SPDecl ? SPDecl->getScope() : SP->getScope());
   applySubprogramAttributes(SP, SPDie, includeMinimalInlineScopes());
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
index 76811d9..50e4a54 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
@@ -66,7 +66,7 @@
   bool includeMinimalInlineScopes() const;
 
 public:
-  DwarfCompileUnit(unsigned UID, const MDCompileUnit *Node, AsmPrinter *A,
+  DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A,
                    DwarfDebug *DW, DwarfFile *DWU);
 
   DwarfCompileUnit *getSkeleton() const {
@@ -79,7 +79,7 @@
   void applyStmtList(DIE &D);
 
   /// getOrCreateGlobalVariableDIE - get or create global variable DIE.
-  DIE *getOrCreateGlobalVariableDIE(const MDGlobalVariable *GV);
+  DIE *getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV);
 
   /// addLabelAddress - Add a dwarf label attribute data and value using
   /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
@@ -113,7 +113,7 @@
   /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
   /// variables in this scope then create and insert DIEs for these
   /// variables.
-  DIE &updateSubprogramScopeDIE(const MDSubprogram *SP);
+  DIE &updateSubprogramScopeDIE(const DISubprogram *SP);
 
   void constructScopeDIE(LexicalScope *Scope,
                          SmallVectorImpl<std::unique_ptr<DIE>> &FinalChildren);
@@ -156,11 +156,11 @@
 
   /// \brief Construct import_module DIE.
   std::unique_ptr<DIE>
-  constructImportedEntityDIE(const MDImportedEntity *Module);
+  constructImportedEntityDIE(const DIImportedEntity *Module);
 
-  void finishSubprogramDefinition(const MDSubprogram *SP);
+  void finishSubprogramDefinition(const DISubprogram *SP);
 
-  void collectDeadVariables(const MDSubprogram *SP);
+  void collectDeadVariables(const DISubprogram *SP);
 
   /// Set the skeleton unit associated with this unit.
   void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; }
@@ -183,11 +183,11 @@
   }
 
   /// Add a new global name to the compile unit.
-  void addGlobalName(StringRef Name, DIE &Die, const MDScope *Context) override;
+  void addGlobalName(StringRef Name, DIE &Die, const DIScope *Context) override;
 
   /// Add a new global type to the compile unit.
-  void addGlobalType(const MDType *Ty, const DIE &Die,
-                     const MDScope *Context) override;
+  void addGlobalType(const DIType *Ty, const DIE &Die,
+                     const DIScope *Context) override;
 
   const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
   const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; }
@@ -215,7 +215,7 @@
   /// Add a Dwarf expression attribute data and value.
   void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr);
 
-  void applySubprogramAttributesToDefinition(const MDSubprogram *SP,
+  void applySubprogramAttributesToDefinition(const DISubprogram *SP,
                                              DIE &SPDie);
 
   /// getRangeLists - Get the vector of range lists.
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 345eea6..4f2b47f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -130,7 +130,7 @@
 
 /// resolve - Look in the DwarfDebug map for the MDNode that
 /// corresponds to the reference.
-template <typename T> T *DbgVariable::resolve(TypedDebugNodeRef<T> Ref) const {
+template <typename T> T *DbgVariable::resolve(TypedDINodeRef<T> Ref) const {
   return DD->resolve(Ref);
 }
 
@@ -141,8 +141,8 @@
       ->isBlockByrefStruct();
 }
 
-const MDType *DbgVariable::getType() const {
-  MDType *Ty = Var->getType().resolve(DD->getTypeIdentifierMap());
+const DIType *DbgVariable::getType() const {
+  DIType *Ty = Var->getType().resolve(DD->getTypeIdentifierMap());
   // FIXME: isBlockByrefVariable should be reformulated in terms of complex
   // addresses instead.
   if (Ty->isBlockByrefStruct()) {
@@ -170,15 +170,15 @@
        have a DW_AT_location that tells the debugger how to unwind through
        the pointers and __Block_byref_x_VarName struct to find the actual
        value of the variable.  The function addBlockByrefType does this.  */
-    MDType *subType = Ty;
+    DIType *subType = Ty;
     uint16_t tag = Ty->getTag();
 
     if (tag == dwarf::DW_TAG_pointer_type)
-      subType = resolve(cast<MDDerivedType>(Ty)->getBaseType());
+      subType = resolve(cast<DIDerivedType>(Ty)->getBaseType());
 
-    auto Elements = cast<MDCompositeTypeBase>(subType)->getElements();
+    auto Elements = cast<DICompositeTypeBase>(subType)->getElements();
     for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
-      auto *DT = cast<MDDerivedTypeBase>(Elements[i]);
+      auto *DT = cast<DIDerivedTypeBase>(Elements[i]);
       if (getName() == DT->getName())
         return resolve(DT->getBaseType());
     }
@@ -277,7 +277,7 @@
 // TODO: Determine whether or not we should add names for programs
 // that do not have a DW_AT_name or DW_AT_linkage_name field - this
 // is only slightly different than the lookup of non-standard ObjC names.
-void DwarfDebug::addSubprogramNames(const MDSubprogram *SP, DIE &Die) {
+void DwarfDebug::addSubprogramNames(const DISubprogram *SP, DIE &Die) {
   if (!SP->isDefinition())
     return;
   addAccelName(SP->getName(), Die);
@@ -305,9 +305,9 @@
 bool DwarfDebug::isSubprogramContext(const MDNode *Context) {
   if (!Context)
     return false;
-  if (isa<MDSubprogram>(Context))
+  if (isa<DISubprogram>(Context))
     return true;
-  if (auto *T = dyn_cast<MDType>(Context))
+  if (auto *T = dyn_cast<DIType>(Context))
     return isSubprogramContext(resolve(T->getScope()));
   return false;
 }
@@ -364,7 +364,7 @@
 // Create new DwarfCompileUnit for the given metadata node with tag
 // DW_TAG_compile_unit.
 DwarfCompileUnit &
-DwarfDebug::constructDwarfCompileUnit(const MDCompileUnit *DIUnit) {
+DwarfDebug::constructDwarfCompileUnit(const DICompileUnit *DIUnit) {
   StringRef FN = DIUnit->getFilename();
   CompilationDir = DIUnit->getDirectory();
 
@@ -422,7 +422,7 @@
 }
 
 void DwarfDebug::constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
-                                                  const MDImportedEntity *N) {
+                                                  const DIImportedEntity *N) {
   if (DIE *D = TheCU.getOrCreateContextDIE(N->getScope()))
     D->addChild(TheCU.constructImportedEntityDIE(N));
 }
@@ -446,7 +446,7 @@
   SingleCU = CU_Nodes->getNumOperands() == 1;
 
   for (MDNode *N : CU_Nodes->operands()) {
-    auto *CUNode = cast<MDCompileUnit>(N);
+    auto *CUNode = cast<DICompileUnit>(N);
     DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
     for (auto *IE : CUNode->getImportedEntities())
       ScopesWithImportedEntities.push_back(std::make_pair(IE->getScope(), IE));
@@ -462,12 +462,12 @@
     for (auto *Ty : CUNode->getEnumTypes()) {
       // The enum types array by design contains pointers to
       // MDNodes rather than DIRefs. Unique them here.
-      CU.getOrCreateTypeDIE(cast<MDType>(resolve(Ty->getRef())));
+      CU.getOrCreateTypeDIE(cast<DIType>(resolve(Ty->getRef())));
     }
     for (auto *Ty : CUNode->getRetainedTypes()) {
       // The retained types array by design contains pointers to
       // MDNodes rather than DIRefs. Unique them here.
-      CU.getOrCreateTypeDIE(cast<MDType>(resolve(Ty->getRef())));
+      CU.getOrCreateTypeDIE(cast<DIType>(resolve(Ty->getRef())));
     }
     // Emit imported_modules last so that the relevant context is already
     // available.
@@ -501,7 +501,7 @@
 void DwarfDebug::finishSubprogramDefinitions() {
   for (const auto &P : SPMap)
     forBothCUs(*P.second, [&](DwarfCompileUnit &CU) {
-      CU.finishSubprogramDefinition(cast<MDSubprogram>(P.first));
+      CU.finishSubprogramDefinition(cast<DISubprogram>(P.first));
     });
 }
 
@@ -512,7 +512,7 @@
 
   if (NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu")) {
     for (MDNode *N : CU_Nodes->operands()) {
-      auto *TheCU = cast<MDCompileUnit>(N);
+      auto *TheCU = cast<DICompileUnit>(N);
       // Construct subprogram DIE and add variables DIEs.
       DwarfCompileUnit *SPCU =
           static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
@@ -662,7 +662,7 @@
 // Find abstract variable, if any, associated with Var.
 DbgVariable *
 DwarfDebug::getExistingAbstractVariable(InlinedVariable IV,
-                                        const MDLocalVariable *&Cleansed) {
+                                        const DILocalVariable *&Cleansed) {
   // More then one inlined variable corresponds to one abstract variable.
   Cleansed = IV.first;
   auto I = AbstractVariables.find(Cleansed);
@@ -672,11 +672,11 @@
 }
 
 DbgVariable *DwarfDebug::getExistingAbstractVariable(InlinedVariable IV) {
-  const MDLocalVariable *Cleansed;
+  const DILocalVariable *Cleansed;
   return getExistingAbstractVariable(IV, Cleansed);
 }
 
-void DwarfDebug::createAbstractVariable(const MDLocalVariable *Var,
+void DwarfDebug::createAbstractVariable(const DILocalVariable *Var,
                                         LexicalScope *Scope) {
   auto AbsDbgVariable =
       make_unique<DbgVariable>(Var, /* IA */ nullptr, /* Expr */ nullptr, this);
@@ -686,22 +686,22 @@
 
 void DwarfDebug::ensureAbstractVariableIsCreated(InlinedVariable IV,
                                                  const MDNode *ScopeNode) {
-  const MDLocalVariable *Cleansed = nullptr;
+  const DILocalVariable *Cleansed = nullptr;
   if (getExistingAbstractVariable(IV, Cleansed))
     return;
 
   createAbstractVariable(Cleansed, LScopes.getOrCreateAbstractScope(
-                                       cast<MDLocalScope>(ScopeNode)));
+                                       cast<DILocalScope>(ScopeNode)));
 }
 
 void DwarfDebug::ensureAbstractVariableIsCreatedIfScoped(
     InlinedVariable IV, const MDNode *ScopeNode) {
-  const MDLocalVariable *Cleansed = nullptr;
+  const DILocalVariable *Cleansed = nullptr;
   if (getExistingAbstractVariable(IV, Cleansed))
     return;
 
   if (LexicalScope *Scope =
-          LScopes.findAbstractScope(cast_or_null<MDLocalScope>(ScopeNode)))
+          LScopes.findAbstractScope(cast_or_null<DILocalScope>(ScopeNode)))
     createAbstractVariable(Cleansed, Scope);
 }
 
@@ -722,7 +722,7 @@
     if (!Scope)
       continue;
 
-    const MDExpression *Expr = cast_or_null<MDExpression>(VI.Expr);
+    const DIExpression *Expr = cast_or_null<DIExpression>(VI.Expr);
     ensureAbstractVariableIsCreatedIfScoped(Var, Scope->getScopeNode());
     auto RegVar =
         make_unique<DbgVariable>(Var.first, Var.second, Expr, this, VI.Slot);
@@ -733,7 +733,7 @@
 
 // Get .debug_loc entry for the instruction range starting at MI.
 static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
-  const MDExpression *Expr = MI->getDebugExpression();
+  const DIExpression *Expr = MI->getDebugExpression();
 
   assert(MI->getNumOperands() == 4);
   if (MI->getOperand(0).isReg()) {
@@ -757,7 +757,7 @@
 }
 
 /// Determine whether two variable pieces overlap.
-static bool piecesOverlap(const MDExpression *P1, const MDExpression *P2) {
+static bool piecesOverlap(const DIExpression *P1, const DIExpression *P2) {
   if (!P1->isBitPiece() || !P2->isBitPiece())
     return true;
   unsigned l1 = P1->getBitPieceOffset();
@@ -809,7 +809,7 @@
     }
 
     // If this piece overlaps with any open ranges, truncate them.
-    const MDExpression *DIExpr = Begin->getDebugExpression();
+    const DIExpression *DIExpr = Begin->getDebugExpression();
     auto Last = std::remove_if(OpenRanges.begin(), OpenRanges.end(),
                                [&](DebugLocEntry::Value R) {
       return piecesOverlap(DIExpr, R.getExpression());
@@ -874,7 +874,7 @@
 
 // Find variables for each lexical scope.
 void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
-                                     const MDSubprogram *SP,
+                                     const DISubprogram *SP,
                                      DenseSet<InlinedVariable> &Processed) {
   // Grab the variable info that was squirreled away in the MMI side-table.
   collectVariableInfoFromMMITable(Processed);
@@ -890,7 +890,7 @@
       continue;
 
     LexicalScope *Scope = nullptr;
-    if (const MDLocation *IA = IV.second)
+    if (const DILocation *IA = IV.second)
       Scope = LScopes.findInlinedScope(IV.first->getScope(), IA);
     else
       Scope = LScopes.findLexicalScope(IV.first->getScope());
@@ -918,10 +918,10 @@
     SmallVector<DebugLocEntry, 8> Entries;
     buildLocationList(Entries, Ranges);
 
-    // If the variable has an MDBasicType, extract it.  Basic types cannot have
+    // If the variable has an DIBasicType, extract it.  Basic types cannot have
     // unique identifiers, so don't bother resolving the type with the
     // identifier map.
-    const MDBasicType *BT = dyn_cast<MDBasicType>(
+    const DIBasicType *BT = dyn_cast<DIBasicType>(
         static_cast<const Metadata *>(IV.first->getType()));
 
     // Finalize the entry by lowering it into a DWARF bytestream.
@@ -930,7 +930,7 @@
   }
 
   // Collect info for variables that were optimized out.
-  for (const MDLocalVariable *DV : SP->getVariables()) {
+  for (const DILocalVariable *DV : SP->getVariables()) {
     if (!Processed.insert(InlinedVariable(DV, nullptr)).second)
       continue;
     if (LexicalScope *Scope = LScopes.findLexicalScope(DV->getScope())) {
@@ -1128,14 +1128,14 @@
 
     // The first mention of a function argument gets the CurrentFnBegin
     // label, so arguments are visible when breaking at function entry.
-    const MDLocalVariable *DIVar = Ranges.front().first->getDebugVariable();
+    const DILocalVariable *DIVar = Ranges.front().first->getDebugVariable();
     if (DIVar->getTag() == dwarf::DW_TAG_arg_variable &&
         getDISubprogram(DIVar->getScope())->describes(MF->getFunction())) {
       LabelsBeforeInsn[Ranges.front().first] = Asm->getFunctionBegin();
       if (Ranges.front().first->getDebugExpression()->isBitPiece()) {
         // Mark all non-overlapping initial pieces.
         for (auto I = Ranges.begin(); I != Ranges.end(); ++I) {
-          const MDExpression *Piece = I->first->getDebugExpression();
+          const DIExpression *Piece = I->first->getDebugExpression();
           if (std::all_of(Ranges.begin(), I,
                           [&](DbgValueHistoryMap::InstrRange Pred) {
                 return !piecesOverlap(Piece, Pred.first->getDebugExpression());
@@ -1159,7 +1159,7 @@
 
   // Record beginning of function.
   PrologEndLoc = findPrologueEndLoc(MF);
-  if (MDLocation *L = PrologEndLoc) {
+  if (DILocation *L = PrologEndLoc) {
     // We'd like to list the prologue as "not statements" but GDB behaves
     // poorly if we do that. Revisit this with caution/GDB (7.5+) testing.
     auto *SP = L->getInlinedAtScope()->getSubprogram();
@@ -1186,7 +1186,7 @@
   Asm->OutStreamer->getContext().setDwarfCompileUnitID(0);
 
   LexicalScope *FnScope = LScopes.getCurrentFunctionScope();
-  auto *SP = cast<MDSubprogram>(FnScope->getScopeNode());
+  auto *SP = cast<DISubprogram>(FnScope->getScopeNode());
   DwarfCompileUnit &TheCU = *SPMap.lookup(SP);
 
   DenseSet<InlinedVariable> ProcessedVars;
@@ -1216,9 +1216,9 @@
 #endif
   // Construct abstract scopes.
   for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
-    auto *SP = cast<MDSubprogram>(AScope->getScopeNode());
+    auto *SP = cast<DISubprogram>(AScope->getScopeNode());
     // Collect info for variables that were optimized out.
-    for (const MDLocalVariable *DV : SP->getVariables()) {
+    for (const DILocalVariable *DV : SP->getVariables()) {
       if (!ProcessedVars.insert(InlinedVariable(DV, nullptr)).second)
         continue;
       ensureAbstractVariableIsCreated(InlinedVariable(DV, nullptr),
@@ -1254,10 +1254,10 @@
   StringRef Dir;
   unsigned Src = 1;
   unsigned Discriminator = 0;
-  if (auto *Scope = cast_or_null<MDScope>(S)) {
+  if (auto *Scope = cast_or_null<DIScope>(S)) {
     Fn = Scope->getFilename();
     Dir = Scope->getDirectory();
-    if (auto *LBF = dyn_cast<MDLexicalBlockFile>(Scope))
+    if (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope))
       Discriminator = LBF->getDiscriminator();
 
     unsigned CUID = Asm->OutStreamer->getContext().getDwarfCompileUnitID();
@@ -1471,7 +1471,7 @@
     Streamer.EmitInt8(Byte, Comment != End ? *(Comment++) : "");
 }
 
-static void emitDebugLocValue(const AsmPrinter &AP, const MDBasicType *BT,
+static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
                               ByteStreamer &Streamer,
                               const DebugLocEntry::Value &Value,
                               unsigned PieceOffsetInBits) {
@@ -1487,7 +1487,7 @@
       DwarfExpr.AddUnsignedConstant(Value.getInt());
   } else if (Value.isLocation()) {
     MachineLocation Loc = Value.getLoc();
-    const MDExpression *Expr = Value.getExpression();
+    const DIExpression *Expr = Value.getExpression();
     if (!Expr || !Expr->getNumElements())
       // Regular entry.
       AP.EmitDwarfRegOp(Streamer, Loc);
@@ -1508,7 +1508,7 @@
 }
 
 void DebugLocEntry::finalize(const AsmPrinter &AP, DebugLocStream &Locs,
-                             const MDBasicType *BT) {
+                             const DIBasicType *BT) {
   Locs.startEntry(Begin, End);
   BufferByteStreamer Streamer = Locs.getStreamer();
   const DebugLocEntry::Value &Value = Values[0];
@@ -1522,7 +1522,7 @@
    
     unsigned Offset = 0;
     for (auto Piece : Values) {
-      const MDExpression *Expr = Piece.getExpression();
+      const DIExpression *Expr = Piece.getExpression();
       unsigned PieceOffset = Expr->getBitPieceOffset();
       unsigned PieceSize = Expr->getBitPieceSize();
       assert(Offset <= PieceOffset && "overlapping or duplicate pieces");
@@ -1903,7 +1903,7 @@
 
 void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
                                       StringRef Identifier, DIE &RefDie,
-                                      const MDCompositeType *CTy) {
+                                      const DICompositeType *CTy) {
   // Fast path if we're building some type units and one has already used the
   // address pool we know we're going to throw away all this work anyway, so
   // don't bother building dependent types.
@@ -1962,7 +1962,7 @@
       // This is inefficient because all the dependent types will be rebuilt
       // from scratch, including building them in type units, discovering that
       // they depend on addresses, throwing them out and rebuilding them.
-      CU.constructTypeDIE(RefDie, cast<MDCompositeType>(CTy));
+      CU.constructTypeDIE(RefDie, cast<DICompositeType>(CTy));
       return;
     }
 
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 708fb8f..59024a7 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -75,9 +75,9 @@
 /// - Variables that are described by multiple MMI table entries have multiple
 ///   expressions and frame indices.
 class DbgVariable {
-  const MDLocalVariable *Var; /// Variable Descriptor.
-  const MDLocation *IA;       /// Inlined at location.
-  SmallVector<const MDExpression *, 1>
+  const DILocalVariable *Var; /// Variable Descriptor.
+  const DILocation *IA;       /// Inlined at location.
+  SmallVector<const DIExpression *, 1>
       Expr;                          /// Complex address location expression.
   DIE *TheDIE;                /// Variable DIE.
   unsigned DebugLocListIndex;        /// Offset in DebugLocs.
@@ -87,8 +87,8 @@
 
 public:
   /// Construct a DbgVariable from a variable.
-  DbgVariable(const MDLocalVariable *V, const MDLocation *IA,
-              const MDExpression *E, DwarfDebug *DD, int FI = ~0)
+  DbgVariable(const DILocalVariable *V, const DILocation *IA,
+              const DIExpression *E, DwarfDebug *DD, int FI = ~0)
       : Var(V), IA(IA), Expr(1, E), TheDIE(nullptr), DebugLocListIndex(~0U),
         MInsn(nullptr), DD(DD) {
     FrameIndex.push_back(FI);
@@ -106,9 +106,9 @@
   }
 
   // Accessors.
-  const MDLocalVariable *getVariable() const { return Var; }
-  const MDLocation *getInlinedAt() const { return IA; }
-  const ArrayRef<const MDExpression *> getExpression() const { return Expr; }
+  const DILocalVariable *getVariable() const { return Var; }
+  const DILocation *getInlinedAt() const { return IA; }
+  const ArrayRef<const DIExpression *> getExpression() const { return Expr; }
   void setDIE(DIE &D) { TheDIE = &D; }
   DIE *getDIE() const { return TheDIE; }
   void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
@@ -130,7 +130,7 @@
       FrameIndex.append(FI.begin(), FI.end());
     }
     assert(Expr.size() > 1 ? std::all_of(Expr.begin(), Expr.end(),
-                                         [](const MDExpression *E) {
+                                         [](const DIExpression *E) {
                                            return E->isBitPiece();
                                          })
                            : (true && "conflicting locations for variable"));
@@ -167,12 +167,12 @@
     return Expr.back()->getNumElements() > 0;
   }
   bool isBlockByrefVariable() const;
-  const MDType *getType() const;
+  const DIType *getType() const;
 
 private:
   /// resolve - Look in the DwarfDebug map for the MDNode that
   /// corresponds to the reference.
-  template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const;
+  template <typename T> T *resolve(TypedDINodeRef<T> Ref) const;
 };
 
 
@@ -271,7 +271,7 @@
   DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
 
   SmallVector<
-      std::pair<std::unique_ptr<DwarfTypeUnit>, const MDCompositeType *>, 1>
+      std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
       TypeUnitsUnderConstruction;
 
   // Whether to emit the pubnames/pubtypes sections.
@@ -324,7 +324,7 @@
   DwarfAccelTable AccelNamespace;
   DwarfAccelTable AccelTypes;
 
-  DenseMap<const Function *, MDSubprogram *> FunctionDIs;
+  DenseMap<const Function *, DISubprogram *> FunctionDIs;
 
   MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
 
@@ -336,9 +336,9 @@
 
   /// \brief Find abstract variable associated with Var.
   DbgVariable *getExistingAbstractVariable(InlinedVariable IV,
-                                           const MDLocalVariable *&Cleansed);
+                                           const DILocalVariable *&Cleansed);
   DbgVariable *getExistingAbstractVariable(InlinedVariable IV);
-  void createAbstractVariable(const MDLocalVariable *DV, LexicalScope *Scope);
+  void createAbstractVariable(const DILocalVariable *DV, LexicalScope *Scope);
   void ensureAbstractVariableIsCreated(InlinedVariable Var,
                                        const MDNode *Scope);
   void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var,
@@ -453,11 +453,11 @@
 
   /// \brief Create new DwarfCompileUnit for the given metadata node with tag
   /// DW_TAG_compile_unit.
-  DwarfCompileUnit &constructDwarfCompileUnit(const MDCompileUnit *DIUnit);
+  DwarfCompileUnit &constructDwarfCompileUnit(const DICompileUnit *DIUnit);
 
   /// \brief Construct imported_module or imported_declaration DIE.
   void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
-                                        const MDImportedEntity *N);
+                                        const DIImportedEntity *N);
 
   /// \brief Register a source line with debug info. Returns the unique
   /// label that was emitted and which provides correspondence to the
@@ -470,7 +470,7 @@
   void identifyScopeMarkers();
 
   /// \brief Populate LexicalScope entries with variables' info.
-  void collectVariableInfo(DwarfCompileUnit &TheCU, const MDSubprogram *SP,
+  void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
                            DenseSet<InlinedVariable> &ProcessedVars);
 
   /// \brief Build the location list for all DBG_VALUEs in the
@@ -522,7 +522,7 @@
   /// \brief Add a DIE to the set of types that we're going to pull into
   /// type units.
   void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
-                            DIE &Die, const MDCompositeType *CTy);
+                            DIE &Die, const DICompositeType *CTy);
 
   /// \brief Add a label so that arange data can be generated for it.
   void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
@@ -566,7 +566,7 @@
   void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
 
   /// Find the MDNode for the given reference.
-  template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
+  template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
     return Ref.resolve(TypeIdentifierMap);
   }
 
@@ -583,7 +583,7 @@
   /// or another context nested inside a subprogram.
   bool isSubprogramContext(const MDNode *Context);
 
-  void addSubprogramNames(const MDSubprogram *SP, DIE &Die);
+  void addSubprogramNames(const DISubprogram *SP, DIE &Die);
 
   AddressPool &getAddressPool() { return AddrPool; }
 
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
index fbe209a..a2799b8 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
@@ -192,7 +192,7 @@
   return OffsetInBits;
 }
 
-bool DwarfExpression::AddMachineRegExpression(const MDExpression *Expr,
+bool DwarfExpression::AddMachineRegExpression(const DIExpression *Expr,
                                               unsigned MachineReg,
                                               unsigned PieceOffsetInBits) {
   auto I = Expr->expr_op_begin();
@@ -240,8 +240,8 @@
   return true;
 }
 
-void DwarfExpression::AddExpression(MDExpression::expr_op_iterator I,
-                                    MDExpression::expr_op_iterator E,
+void DwarfExpression::AddExpression(DIExpression::expr_op_iterator I,
+                                    DIExpression::expr_op_iterator E,
                                     unsigned PieceOffsetInBits) {
   for (; I != E; ++I) {
     switch (I->getOp()) {
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
index 3b77a44..78ec937 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
@@ -93,13 +93,13 @@
   /// \param PieceOffsetInBits If this is one piece out of a fragmented
   /// location, this is the offset of the piece inside the entire variable.
   /// \return false if no DWARF register exists for MachineReg.
-  bool AddMachineRegExpression(const MDExpression *Expr, unsigned MachineReg,
+  bool AddMachineRegExpression(const DIExpression *Expr, unsigned MachineReg,
                                unsigned PieceOffsetInBits = 0);
   /// Emit a the operations remaining the DIExpressionIterator I.
   /// \param PieceOffsetInBits If this is one piece out of a fragmented
   /// location, this is the offset of the piece inside the entire variable.
-  void AddExpression(MDExpression::expr_op_iterator I,
-                     MDExpression::expr_op_iterator E,
+  void AddExpression(DIExpression::expr_op_iterator I,
+                     DIExpression::expr_op_iterator E,
                      unsigned PieceOffsetInBits = 0);
 };
 
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
index 50dbb41..1d6298c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
@@ -137,7 +137,7 @@
 
 bool DwarfFile::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
   SmallVectorImpl<DbgVariable *> &Vars = ScopeVariables[LS];
-  const MDLocalVariable *DV = Var->getVariable();
+  const DILocalVariable *DV = Var->getVariable();
   // Variables with positive arg numbers are parameters.
   if (unsigned ArgNum = DV->getArg()) {
     // Keep all parameters in order at the start of the variable list to ensure
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
index 19bb347..a3a5e99 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
@@ -56,7 +56,7 @@
   /// Maps MDNodes for type system with the corresponding DIEs. These DIEs can
   /// be shared across CUs, that is why we keep the map here instead
   /// of in DwarfCompileUnit.
-  DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
+  DenseMap<const MDNode *, DIE *> DITypeNodeToDieMap;
 
 public:
   DwarfFile(AsmPrinter *AP, StringRef Pref, BumpPtrAllocator &DA);
@@ -103,10 +103,10 @@
   }
 
   void insertDIE(const MDNode *TypeMD, DIE *Die) {
-    MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
+    DITypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
   }
   DIE *getDIE(const MDNode *TypeMD) {
-    return MDTypeNodeToDieMap.lookup(TypeMD);
+    return DITypeNodeToDieMap.lookup(TypeMD);
   }
 };
 }
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index b721077..ee233f7 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -64,7 +64,7 @@
 }
 
 DwarfUnit::DwarfUnit(unsigned UID, dwarf::Tag UnitTag,
-                     const MDCompileUnit *Node, AsmPrinter *A, DwarfDebug *DW,
+                     const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW,
                      DwarfFile *DWU)
     : UniqueID(UID), CUNode(Node), UnitDie(UnitTag), DebugInfoOffset(0), Asm(A),
       DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr) {
@@ -161,7 +161,7 @@
 }
 
 /// Check whether the DIE for this MDNode can be shared across CUs.
-static bool isShareableAcrossCUs(const DebugNode *D) {
+static bool isShareableAcrossCUs(const DINode *D) {
   // When the MDNode can be part of the type system, the DIE can be shared
   // across CUs.
   // Combining type units and cross-CU DIE sharing is lower value (since
@@ -169,18 +169,18 @@
   // level already) but may be implementable for some value in projects
   // building multiple independent libraries with LTO and then linking those
   // together.
-  return (isa<MDType>(D) ||
-          (isa<MDSubprogram>(D) && !cast<MDSubprogram>(D)->isDefinition())) &&
+  return (isa<DIType>(D) ||
+          (isa<DISubprogram>(D) && !cast<DISubprogram>(D)->isDefinition())) &&
          !GenerateDwarfTypeUnits;
 }
 
-DIE *DwarfUnit::getDIE(const DebugNode *D) const {
+DIE *DwarfUnit::getDIE(const DINode *D) const {
   if (isShareableAcrossCUs(D))
     return DU->getDIE(D);
   return MDNodeToDieMap.lookup(D);
 }
 
-void DwarfUnit::insertDIE(const DebugNode *Desc, DIE *D) {
+void DwarfUnit::insertDIE(const DINode *Desc, DIE *D) {
   if (isShareableAcrossCUs(Desc)) {
     DU->insertDIE(Desc, D);
     return;
@@ -320,7 +320,7 @@
                Entry);
 }
 
-DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DebugNode *N) {
+DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {
   assert(Tag != dwarf::DW_TAG_auto_variable &&
          Tag != dwarf::DW_TAG_arg_variable);
   Parent.addChild(make_unique<DIE>((dwarf::Tag)Tag));
@@ -354,38 +354,38 @@
   addUInt(Die, dwarf::DW_AT_decl_line, None, Line);
 }
 
-void DwarfUnit::addSourceLine(DIE &Die, const MDLocalVariable *V) {
+void DwarfUnit::addSourceLine(DIE &Die, const DILocalVariable *V) {
   assert(V);
 
   addSourceLine(Die, V->getLine(), V->getScope()->getFilename(),
                 V->getScope()->getDirectory());
 }
 
-void DwarfUnit::addSourceLine(DIE &Die, const MDGlobalVariable *G) {
+void DwarfUnit::addSourceLine(DIE &Die, const DIGlobalVariable *G) {
   assert(G);
 
   addSourceLine(Die, G->getLine(), G->getFilename(), G->getDirectory());
 }
 
-void DwarfUnit::addSourceLine(DIE &Die, const MDSubprogram *SP) {
+void DwarfUnit::addSourceLine(DIE &Die, const DISubprogram *SP) {
   assert(SP);
 
   addSourceLine(Die, SP->getLine(), SP->getFilename(), SP->getDirectory());
 }
 
-void DwarfUnit::addSourceLine(DIE &Die, const MDType *Ty) {
+void DwarfUnit::addSourceLine(DIE &Die, const DIType *Ty) {
   assert(Ty);
 
   addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
 }
 
-void DwarfUnit::addSourceLine(DIE &Die, const MDObjCProperty *Ty) {
+void DwarfUnit::addSourceLine(DIE &Die, const DIObjCProperty *Ty) {
   assert(Ty);
 
   addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
 }
 
-void DwarfUnit::addSourceLine(DIE &Die, const MDNamespace *NS) {
+void DwarfUnit::addSourceLine(DIE &Die, const DINamespace *NS) {
   addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory());
 }
 
@@ -459,27 +459,27 @@
 void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die,
                                      dwarf::Attribute Attribute,
                                      const MachineLocation &Location) {
-  const MDType *Ty = DV.getType();
-  const MDType *TmpTy = Ty;
+  const DIType *Ty = DV.getType();
+  const DIType *TmpTy = Ty;
   uint16_t Tag = Ty->getTag();
   bool isPointer = false;
 
   StringRef varName = DV.getName();
 
   if (Tag == dwarf::DW_TAG_pointer_type) {
-    auto *DTy = cast<MDDerivedType>(Ty);
+    auto *DTy = cast<DIDerivedType>(Ty);
     TmpTy = resolve(DTy->getBaseType());
     isPointer = true;
   }
 
   // Find the __forwarding field and the variable field in the __Block_byref
   // struct.
-  DebugNodeArray Fields = cast<MDCompositeTypeBase>(TmpTy)->getElements();
-  const MDDerivedType *varField = nullptr;
-  const MDDerivedType *forwardingField = nullptr;
+  DINodeArray Fields = cast<DICompositeTypeBase>(TmpTy)->getElements();
+  const DIDerivedType *varField = nullptr;
+  const DIDerivedType *forwardingField = nullptr;
 
   for (unsigned i = 0, N = Fields.size(); i < N; ++i) {
-    auto *DT = cast<MDDerivedType>(Fields[i]);
+    auto *DT = cast<DIDerivedType>(Fields[i]);
     StringRef fieldName = DT->getName();
     if (fieldName == "__forwarding")
       forwardingField = DT;
@@ -534,8 +534,8 @@
 }
 
 /// Return true if type encoding is unsigned.
-static bool isUnsignedDIType(DwarfDebug *DD, const MDType *Ty) {
-  if (auto *DTy = dyn_cast<MDDerivedTypeBase>(Ty)) {
+static bool isUnsignedDIType(DwarfDebug *DD, const DIType *Ty) {
+  if (auto *DTy = dyn_cast<DIDerivedTypeBase>(Ty)) {
     dwarf::Tag T = (dwarf::Tag)Ty->getTag();
     // Encode pointer constants as unsigned bytes. This is used at least for
     // null pointer constant emission.
@@ -557,7 +557,7 @@
            T == dwarf::DW_TAG_volatile_type ||
            T == dwarf::DW_TAG_restrict_type ||
            T == dwarf::DW_TAG_enumeration_type);
-    if (MDTypeRef Deriv = DTy->getBaseType())
+    if (DITypeRef Deriv = DTy->getBaseType())
       return isUnsignedDIType(DD, DD->resolve(Deriv));
     // FIXME: Enums without a fixed underlying type have unknown signedness
     // here, leading to incorrectly emitted constants.
@@ -565,7 +565,7 @@
     return false;
   }
 
-  auto *BTy = cast<MDBasicType>(Ty);
+  auto *BTy = cast<DIBasicType>(Ty);
   unsigned Encoding = BTy->getEncoding();
   assert((Encoding == dwarf::DW_ATE_unsigned ||
           Encoding == dwarf::DW_ATE_unsigned_char ||
@@ -583,7 +583,7 @@
 }
 
 /// If this type is derived from a base type then return base type size.
-static uint64_t getBaseTypeSize(DwarfDebug *DD, const MDDerivedType *Ty) {
+static uint64_t getBaseTypeSize(DwarfDebug *DD, const DIDerivedType *Ty) {
   unsigned Tag = Ty->getTag();
 
   if (Tag != dwarf::DW_TAG_member && Tag != dwarf::DW_TAG_typedef &&
@@ -602,7 +602,7 @@
       BaseType->getTag() == dwarf::DW_TAG_rvalue_reference_type)
     return Ty->getSizeInBits();
 
-  if (auto *DT = dyn_cast<MDDerivedType>(BaseType))
+  if (auto *DT = dyn_cast<DIDerivedType>(BaseType))
     return getBaseTypeSize(DD, DT);
 
   return BaseType->getSizeInBits();
@@ -636,12 +636,12 @@
 }
 
 void DwarfUnit::addConstantValue(DIE &Die, const ConstantInt *CI,
-                                 const MDType *Ty) {
+                                 const DIType *Ty) {
   addConstantValue(Die, CI->getValue(), Ty);
 }
 
 void DwarfUnit::addConstantValue(DIE &Die, const MachineOperand &MO,
-                                 const MDType *Ty) {
+                                 const DIType *Ty) {
   assert(MO.isImm() && "Invalid machine operand!");
 
   addConstantValue(Die, isUnsignedDIType(DD, Ty), MO.getImm());
@@ -654,7 +654,7 @@
           Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val);
 }
 
-void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, const MDType *Ty) {
+void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, const DIType *Ty) {
   addConstantValue(Die, Val, isUnsignedDIType(DD, Ty));
 }
 
@@ -695,29 +695,29 @@
               GlobalValue::getRealLinkageName(LinkageName));
 }
 
-void DwarfUnit::addTemplateParams(DIE &Buffer, DebugNodeArray TParams) {
+void DwarfUnit::addTemplateParams(DIE &Buffer, DINodeArray TParams) {
   // Add template parameters.
   for (const auto *Element : TParams) {
-    if (auto *TTP = dyn_cast<MDTemplateTypeParameter>(Element))
+    if (auto *TTP = dyn_cast<DITemplateTypeParameter>(Element))
       constructTemplateTypeParameterDIE(Buffer, TTP);
-    else if (auto *TVP = dyn_cast<MDTemplateValueParameter>(Element))
+    else if (auto *TVP = dyn_cast<DITemplateValueParameter>(Element))
       constructTemplateValueParameterDIE(Buffer, TVP);
   }
 }
 
-DIE *DwarfUnit::getOrCreateContextDIE(const MDScope *Context) {
-  if (!Context || isa<MDFile>(Context))
+DIE *DwarfUnit::getOrCreateContextDIE(const DIScope *Context) {
+  if (!Context || isa<DIFile>(Context))
     return &getUnitDie();
-  if (auto *T = dyn_cast<MDType>(Context))
+  if (auto *T = dyn_cast<DIType>(Context))
     return getOrCreateTypeDIE(T);
-  if (auto *NS = dyn_cast<MDNamespace>(Context))
+  if (auto *NS = dyn_cast<DINamespace>(Context))
     return getOrCreateNameSpace(NS);
-  if (auto *SP = dyn_cast<MDSubprogram>(Context))
+  if (auto *SP = dyn_cast<DISubprogram>(Context))
     return getOrCreateSubprogramDIE(SP);
   return getDIE(Context);
 }
 
-DIE *DwarfUnit::createTypeDIE(const MDCompositeType *Ty) {
+DIE *DwarfUnit::createTypeDIE(const DICompositeType *Ty) {
   auto *Context = resolve(Ty->getScope());
   DIE *ContextDIE = getOrCreateContextDIE(Context);
 
@@ -727,7 +727,7 @@
   // Create new type.
   DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
 
-  constructTypeDIE(TyDIE, cast<MDCompositeType>(Ty));
+  constructTypeDIE(TyDIE, cast<DICompositeType>(Ty));
 
   updateAcceleratorTables(Context, Ty, TyDIE);
   return &TyDIE;
@@ -737,14 +737,13 @@
   if (!TyNode)
     return nullptr;
 
-  auto *Ty = cast<MDType>(TyNode);
+  auto *Ty = cast<DIType>(TyNode);
   assert(Ty == resolve(Ty->getRef()) &&
          "type was not uniqued, possible ODR violation.");
 
   // DW_TAG_restrict_type is not supported in DWARF2
   if (Ty->getTag() == dwarf::DW_TAG_restrict_type && DD->getDwarfVersion() <= 2)
-    return getOrCreateTypeDIE(
-        resolve(cast<MDDerivedType>(Ty)->getBaseType()));
+    return getOrCreateTypeDIE(resolve(cast<DIDerivedType>(Ty)->getBaseType()));
 
   // Construct the context before querying for the existence of the DIE in case
   // such construction creates the DIE.
@@ -760,11 +759,11 @@
 
   updateAcceleratorTables(Context, Ty, TyDIE);
 
-  if (auto *BT = dyn_cast<MDBasicType>(Ty))
+  if (auto *BT = dyn_cast<DIBasicType>(Ty))
     constructTypeDIE(TyDIE, BT);
-  else if (auto *STy = dyn_cast<MDSubroutineType>(Ty))
+  else if (auto *STy = dyn_cast<DISubroutineType>(Ty))
     constructTypeDIE(TyDIE, STy);
-  else if (auto *CTy = dyn_cast<MDCompositeType>(Ty)) {
+  else if (auto *CTy = dyn_cast<DICompositeType>(Ty)) {
     if (GenerateDwarfTypeUnits && !Ty->isForwardDecl())
       if (MDString *TypeId = CTy->getRawIdentifier()) {
         DD->addDwarfTypeUnitType(getCU(), TypeId->getString(), TyDIE, CTy);
@@ -773,17 +772,17 @@
       }
     constructTypeDIE(TyDIE, CTy);
   } else {
-    constructTypeDIE(TyDIE, cast<MDDerivedType>(Ty));
+    constructTypeDIE(TyDIE, cast<DIDerivedType>(Ty));
   }
 
   return &TyDIE;
 }
 
-void DwarfUnit::updateAcceleratorTables(const MDScope *Context,
-                                        const MDType *Ty, const DIE &TyDIE) {
+void DwarfUnit::updateAcceleratorTables(const DIScope *Context,
+                                        const DIType *Ty, const DIE &TyDIE) {
   if (!Ty->getName().empty() && !Ty->isForwardDecl()) {
     bool IsImplementation = 0;
-    if (auto *CT = dyn_cast<MDCompositeTypeBase>(Ty)) {
+    if (auto *CT = dyn_cast<DICompositeTypeBase>(Ty)) {
       // A runtime language of 0 actually means C/C++ and that any
       // non-negative value is some version of Objective-C/C++.
       IsImplementation = CT->getRuntimeLang() == 0 || CT->isObjcClassComplete();
@@ -791,13 +790,13 @@
     unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0;
     DD->addAccelType(Ty->getName(), TyDIE, Flags);
 
-    if (!Context || isa<MDCompileUnit>(Context) || isa<MDFile>(Context) ||
-        isa<MDNamespace>(Context))
+    if (!Context || isa<DICompileUnit>(Context) || isa<DIFile>(Context) ||
+        isa<DINamespace>(Context))
       addGlobalType(Ty, TyDIE, Context);
   }
 }
 
-void DwarfUnit::addType(DIE &Entity, const MDType *Ty,
+void DwarfUnit::addType(DIE &Entity, const DIType *Ty,
                         dwarf::Attribute Attribute) {
   assert(Ty && "Trying to add a type that doesn't exist?");
 
@@ -818,7 +817,7 @@
   addDIEEntry(Entity, Attribute, Entry);
 }
 
-std::string DwarfUnit::getParentContextString(const MDScope *Context) const {
+std::string DwarfUnit::getParentContextString(const DIScope *Context) const {
   if (!Context)
     return "";
 
@@ -827,8 +826,8 @@
     return "";
 
   std::string CS;
-  SmallVector<const MDScope *, 1> Parents;
-  while (!isa<MDCompileUnit>(Context)) {
+  SmallVector<const DIScope *, 1> Parents;
+  while (!isa<DICompileUnit>(Context)) {
     Parents.push_back(Context);
     if (Context->getScope())
       Context = resolve(Context->getScope());
@@ -841,9 +840,9 @@
   // Reverse iterate over our list to go from the outermost construct to the
   // innermost.
   for (auto I = Parents.rbegin(), E = Parents.rend(); I != E; ++I) {
-    const MDScope *Ctx = *I;
+    const DIScope *Ctx = *I;
     StringRef Name = Ctx->getName();
-    if (Name.empty() && isa<MDNamespace>(Ctx))
+    if (Name.empty() && isa<DINamespace>(Ctx))
       Name = "(anonymous namespace)";
     if (!Name.empty()) {
       CS += Name;
@@ -853,7 +852,7 @@
   return CS;
 }
 
-void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDBasicType *BTy) {
+void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIBasicType *BTy) {
   // Get core information.
   StringRef Name = BTy->getName();
   // Add name if not anonymous or intermediate type.
@@ -871,14 +870,14 @@
   addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size);
 }
 
-void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDDerivedType *DTy) {
+void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy) {
   // Get core information.
   StringRef Name = DTy->getName();
   uint64_t Size = DTy->getSizeInBits() >> 3;
   uint16_t Tag = Buffer.getTag();
 
   // Map to main type, void will not have a type.
-  const MDType *FromTy = resolve(DTy->getBaseType());
+  const DIType *FromTy = resolve(DTy->getBaseType());
   if (FromTy)
     addType(Buffer, FromTy);
 
@@ -894,15 +893,15 @@
   if (Tag == dwarf::DW_TAG_ptr_to_member_type)
     addDIEEntry(
         Buffer, dwarf::DW_AT_containing_type,
-        *getOrCreateTypeDIE(resolve(cast<MDDerivedType>(DTy)->getClassType())));
+        *getOrCreateTypeDIE(resolve(cast<DIDerivedType>(DTy)->getClassType())));
   // Add source line info if available and TyDesc is not a forward declaration.
   if (!DTy->isForwardDecl())
     addSourceLine(Buffer, DTy);
 }
 
-void DwarfUnit::constructSubprogramArguments(DIE &Buffer, MDTypeRefArray Args) {
+void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args) {
   for (unsigned i = 1, N = Args.size(); i < N; ++i) {
-    const MDType *Ty = resolve(Args[i]);
+    const DIType *Ty = resolve(Args[i]);
     if (!Ty) {
       assert(i == N-1 && "Unspecified parameter must be the last argument");
       createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
@@ -915,9 +914,9 @@
   }
 }
 
-void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDSubroutineType *CTy) {
+void DwarfUnit::constructTypeDIE(DIE &Buffer, const DISubroutineType *CTy) {
   // Add return type.  A void return won't have a type.
-  auto Elements = cast<MDSubroutineType>(CTy)->getTypeArray();
+  auto Elements = cast<DISubroutineType>(CTy)->getTypeArray();
   if (Elements.size())
     if (auto RTy = resolve(Elements[0]))
       addType(Buffer, RTy);
@@ -943,7 +942,7 @@
     addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
 }
 
-void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
+void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
   // Add name if not anonymous or intermediate type.
   StringRef Name = CTy->getName();
 
@@ -961,13 +960,13 @@
   case dwarf::DW_TAG_union_type:
   case dwarf::DW_TAG_class_type: {
     // Add elements to structure type.
-    DebugNodeArray Elements = CTy->getElements();
+    DINodeArray Elements = CTy->getElements();
     for (const auto *Element : Elements) {
       if (!Element)
         continue;
-      if (auto *SP = dyn_cast<MDSubprogram>(Element))
+      if (auto *SP = dyn_cast<DISubprogram>(Element))
         getOrCreateSubprogramDIE(SP);
-      else if (auto *DDTy = dyn_cast<MDDerivedType>(Element)) {
+      else if (auto *DDTy = dyn_cast<DIDerivedType>(Element)) {
         if (DDTy->getTag() == dwarf::DW_TAG_friend) {
           DIE &ElemDie = createAndAddDIE(dwarf::DW_TAG_friend, Buffer);
           addType(ElemDie, resolve(DDTy->getBaseType()), dwarf::DW_AT_friend);
@@ -976,7 +975,7 @@
         } else {
           constructMemberDIE(Buffer, DDTy);
         }
-      } else if (auto *Property = dyn_cast<MDObjCProperty>(Element)) {
+      } else if (auto *Property = dyn_cast<DIObjCProperty>(Element)) {
         DIE &ElemDie = createAndAddDIE(Property->getTag(), Buffer);
         StringRef PropertyName = Property->getName();
         addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
@@ -1007,7 +1006,7 @@
     // This is outside the DWARF spec, but GDB expects a DW_AT_containing_type
     // inside C++ composite types to point to the base class with the vtable.
     if (auto *ContainingType =
-            dyn_cast_or_null<MDCompositeType>(resolve(CTy->getVTableHolder())))
+            dyn_cast_or_null<DICompositeType>(resolve(CTy->getVTableHolder())))
       addDIEEntry(Buffer, dwarf::DW_AT_containing_type,
                   *getOrCreateTypeDIE(ContainingType));
 
@@ -1058,7 +1057,7 @@
 }
 
 void DwarfUnit::constructTemplateTypeParameterDIE(
-    DIE &Buffer, const MDTemplateTypeParameter *TP) {
+    DIE &Buffer, const DITemplateTypeParameter *TP) {
   DIE &ParamDIE =
       createAndAddDIE(dwarf::DW_TAG_template_type_parameter, Buffer);
   // Add the type if it exists, it could be void and therefore no type.
@@ -1069,7 +1068,7 @@
 }
 
 void DwarfUnit::constructTemplateValueParameterDIE(
-    DIE &Buffer, const MDTemplateValueParameter *VP) {
+    DIE &Buffer, const DITemplateValueParameter *VP) {
   DIE &ParamDIE = createAndAddDIE(VP->getTag(), Buffer);
 
   // Add the type if there is one, template template and template parameter
@@ -1100,7 +1099,7 @@
   }
 }
 
-DIE *DwarfUnit::getOrCreateNameSpace(const MDNamespace *NS) {
+DIE *DwarfUnit::getOrCreateNameSpace(const DINamespace *NS) {
   // Construct the context before querying for the existence of the DIE in case
   // such construction creates the DIE.
   DIE *ContextDIE = getOrCreateContextDIE(NS->getScope());
@@ -1120,7 +1119,7 @@
   return &NDie;
 }
 
-DIE *DwarfUnit::getOrCreateSubprogramDIE(const MDSubprogram *SP, bool Minimal) {
+DIE *DwarfUnit::getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal) {
   // Construct the context before querying for the existence of the DIE in case
   // such construction creates the DIE (as is the case for member function
   // declarations).
@@ -1151,7 +1150,7 @@
   return &SPDie;
 }
 
-bool DwarfUnit::applySubprogramDefinitionAttributes(const MDSubprogram *SP,
+bool DwarfUnit::applySubprogramDefinitionAttributes(const DISubprogram *SP,
                                                     DIE &SPDie) {
   DIE *DeclDie = nullptr;
   StringRef DeclLinkageName;
@@ -1183,7 +1182,7 @@
   return true;
 }
 
-void DwarfUnit::applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie,
+void DwarfUnit::applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie,
                                           bool Minimal) {
   if (!Minimal)
     if (applySubprogramDefinitionAttributes(SP, SPDie))
@@ -1207,7 +1206,7 @@
        Language == dwarf::DW_LANG_ObjC))
     addFlag(SPDie, dwarf::DW_AT_prototyped);
 
-  const MDSubroutineType *SPTy = SP->getType();
+  const DISubroutineType *SPTy = SP->getType();
   assert(SPTy->getTag() == dwarf::DW_TAG_subroutine_type &&
          "the type of a subprogram should be a subroutine");
 
@@ -1269,7 +1268,7 @@
     addFlag(SPDie, dwarf::DW_AT_explicit);
 }
 
-void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const MDSubrange *SR,
+void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const DISubrange *SR,
                                      DIE *IndexTy) {
   DIE &DW_Subrange = createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer);
   addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IndexTy);
@@ -1303,7 +1302,7 @@
   return IndexTyDie;
 }
 
-void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
+void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
   if (CTy->isVector())
     addFlag(Buffer, dwarf::DW_AT_GNU_vector);
 
@@ -1316,21 +1315,21 @@
   DIE *IdxTy = getIndexTyDie();
 
   // Add subranges to array type.
-  DebugNodeArray Elements = CTy->getElements();
+  DINodeArray Elements = CTy->getElements();
   for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
     // FIXME: Should this really be such a loose cast?
-    if (auto *Element = dyn_cast_or_null<DebugNode>(Elements[i]))
+    if (auto *Element = dyn_cast_or_null<DINode>(Elements[i]))
       if (Element->getTag() == dwarf::DW_TAG_subrange_type)
-        constructSubrangeDIE(Buffer, cast<MDSubrange>(Element), IdxTy);
+        constructSubrangeDIE(Buffer, cast<DISubrange>(Element), IdxTy);
   }
 }
 
-void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
-  DebugNodeArray Elements = CTy->getElements();
+void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
+  DINodeArray Elements = CTy->getElements();
 
   // Add enumerators to enumeration type.
   for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
-    auto *Enum = dyn_cast_or_null<MDEnumerator>(Elements[i]);
+    auto *Enum = dyn_cast_or_null<DIEnumerator>(Elements[i]);
     if (Enum) {
       DIE &Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
       StringRef Name = Enum->getName();
@@ -1340,7 +1339,7 @@
               Value);
     }
   }
-  const MDType *DTy = resolve(CTy->getBaseType());
+  const DIType *DTy = resolve(CTy->getBaseType());
   if (DTy) {
     addType(Buffer, DTy);
     addFlag(Buffer, dwarf::DW_AT_enum_class);
@@ -1351,7 +1350,7 @@
   for (auto CI = ContainingTypeMap.begin(), CE = ContainingTypeMap.end();
        CI != CE; ++CI) {
     DIE &SPDie = *CI->first;
-    const DebugNode *D = CI->second;
+    const DINode *D = CI->second;
     if (!D)
       continue;
     DIE *NDie = getDIE(D);
@@ -1361,7 +1360,7 @@
   }
 }
 
-void DwarfUnit::constructMemberDIE(DIE &Buffer, const MDDerivedType *DT) {
+void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) {
   DIE &MemberDie = createAndAddDIE(DT->getTag(), Buffer);
   StringRef Name = DT->getName();
   if (!Name.empty())
@@ -1449,7 +1448,7 @@
     addFlag(MemberDie, dwarf::DW_AT_artificial);
 }
 
-DIE *DwarfUnit::getOrCreateStaticMemberDIE(const MDDerivedType *DT) {
+DIE *DwarfUnit::getOrCreateStaticMemberDIE(const DIDerivedType *DT) {
   if (!DT)
     return nullptr;
 
@@ -1464,7 +1463,7 @@
 
   DIE &StaticMemberDIE = createAndAddDIE(DT->getTag(), *ContextDIE, DT);
 
-  const MDType *Ty = resolve(DT->getBaseType());
+  const DIType *Ty = resolve(DT->getBaseType());
 
   addString(StaticMemberDIE, dwarf::DW_AT_name, DT->getName());
   addType(StaticMemberDIE, Ty);
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
index 1cbf348..a0ea3c87 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -71,7 +71,7 @@
   unsigned UniqueID;
 
   /// MDNode for the compile unit.
-  const MDCompileUnit *CUNode;
+  const DICompileUnit *CUNode;
 
   /// Unit debug information entry.
   DIE UnitDie;
@@ -106,7 +106,7 @@
   /// This map is used to keep track of subprogram DIEs that need
   /// DW_AT_containing_type attribute. This attribute points to a DIE that
   /// corresponds to the MDNode mapped with the subprogram DIE.
-  DenseMap<DIE *, const DebugNode *> ContainingTypeMap;
+  DenseMap<DIE *, const DINode *> ContainingTypeMap;
 
   // All DIEValues are allocated through this allocator.
   BumpPtrAllocator DIEValueAllocator;
@@ -117,7 +117,7 @@
   /// The section this unit will be emitted in.
   const MCSection *Section;
 
-  DwarfUnit(unsigned UID, dwarf::Tag, const MDCompileUnit *CU, AsmPrinter *A,
+  DwarfUnit(unsigned UID, dwarf::Tag, const DICompileUnit *CU, AsmPrinter *A,
             DwarfDebug *DW, DwarfFile *DWU);
 
   /// \brief Add a string attribute data and value.
@@ -127,7 +127,7 @@
 
   void addIndexedString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
 
-  bool applySubprogramDefinitionAttributes(const MDSubprogram *SP, DIE &SPDie);
+  bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie);
 
 public:
   virtual ~DwarfUnit();
@@ -143,7 +143,7 @@
   AsmPrinter* getAsmPrinter() const { return Asm; }
   unsigned getUniqueID() const { return UniqueID; }
   uint16_t getLanguage() const { return CUNode->getSourceLanguage(); }
-  const MDCompileUnit *getCUNode() const { return CUNode; }
+  const DICompileUnit *getCUNode() const { return CUNode; }
   DIE &getUnitDie() { return UnitDie; }
 
   unsigned getDebugInfoOffset() const { return DebugInfoOffset; }
@@ -159,15 +159,15 @@
   /// metadata level because DIEs may not currently have been added to the
   /// parent context and walking the DIEs looking for names is more expensive
   /// than walking the metadata.
-  std::string getParentContextString(const MDScope *Context) const;
+  std::string getParentContextString(const DIScope *Context) const;
 
   /// Add a new global name to the compile unit.
-  virtual void addGlobalName(StringRef Name, DIE &Die, const MDScope *Context) {
+  virtual void addGlobalName(StringRef Name, DIE &Die, const DIScope *Context) {
   }
 
   /// Add a new global type to the compile unit.
-  virtual void addGlobalType(const MDType *Ty, const DIE &Die,
-                             const MDScope *Context) {}
+  virtual void addGlobalType(const DIType *Ty, const DIE &Die,
+                             const DIScope *Context) {}
 
   /// \brief Add a new name to the namespace accelerator table.
   void addAccelNamespace(StringRef Name, const DIE &Die);
@@ -177,7 +177,7 @@
   /// We delegate the request to DwarfDebug when the MDNode can be part of the
   /// type system, since DIEs for the type system can be shared across CUs and
   /// the mappings are kept in DwarfDebug.
-  DIE *getDIE(const DebugNode *D) const;
+  DIE *getDIE(const DINode *D) const;
 
   /// \brief Returns a fresh newly allocated DIELoc.
   DIELoc *getDIELoc() { return new (DIEValueAllocator) DIELoc(); }
@@ -187,7 +187,7 @@
   /// We delegate the request to DwarfDebug when the MDNode can be part of the
   /// type system, since DIEs for the type system can be shared across CUs and
   /// the mappings are kept in DwarfDebug.
-  void insertDIE(const DebugNode *Desc, DIE *D);
+  void insertDIE(const DINode *Desc, DIE *D);
 
   /// \brief Add a flag that is true to the DIE.
   void addFlag(DIE &Die, dwarf::Attribute Attribute);
@@ -246,17 +246,17 @@
   /// \brief Add location information to specified debug information entry.
   void addSourceLine(DIE &Die, unsigned Line, StringRef File,
                      StringRef Directory);
-  void addSourceLine(DIE &Die, const MDLocalVariable *V);
-  void addSourceLine(DIE &Die, const MDGlobalVariable *G);
-  void addSourceLine(DIE &Die, const MDSubprogram *SP);
-  void addSourceLine(DIE &Die, const MDType *Ty);
-  void addSourceLine(DIE &Die, const MDNamespace *NS);
-  void addSourceLine(DIE &Die, const MDObjCProperty *Ty);
+  void addSourceLine(DIE &Die, const DILocalVariable *V);
+  void addSourceLine(DIE &Die, const DIGlobalVariable *G);
+  void addSourceLine(DIE &Die, const DISubprogram *SP);
+  void addSourceLine(DIE &Die, const DIType *Ty);
+  void addSourceLine(DIE &Die, const DINamespace *NS);
+  void addSourceLine(DIE &Die, const DIObjCProperty *Ty);
 
   /// \brief Add constant value entry in variable DIE.
-  void addConstantValue(DIE &Die, const MachineOperand &MO, const MDType *Ty);
-  void addConstantValue(DIE &Die, const ConstantInt *CI, const MDType *Ty);
-  void addConstantValue(DIE &Die, const APInt &Val, const MDType *Ty);
+  void addConstantValue(DIE &Die, const MachineOperand &MO, const DIType *Ty);
+  void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty);
+  void addConstantValue(DIE &Die, const APInt &Val, const DIType *Ty);
   void addConstantValue(DIE &Die, const APInt &Val, bool Unsigned);
   void addConstantValue(DIE &Die, bool Unsigned, uint64_t Val);
 
@@ -268,7 +268,7 @@
   void addLinkageName(DIE &Die, StringRef LinkageName);
 
   /// \brief Add template parameters in buffer.
-  void addTemplateParams(DIE &Buffer, DebugNodeArray TParams);
+  void addTemplateParams(DIE &Buffer, DINodeArray TParams);
 
   /// \brief Add register operand.
   /// \returns false if the register does not exist, e.g., because it was never
@@ -294,33 +294,33 @@
   ///
   /// This takes and attribute parameter because DW_AT_friend attributes are
   /// also type references.
-  void addType(DIE &Entity, const MDType *Ty,
+  void addType(DIE &Entity, const DIType *Ty,
                dwarf::Attribute Attribute = dwarf::DW_AT_type);
 
-  DIE *getOrCreateNameSpace(const MDNamespace *NS);
-  DIE *getOrCreateSubprogramDIE(const MDSubprogram *SP, bool Minimal = false);
+  DIE *getOrCreateNameSpace(const DINamespace *NS);
+  DIE *getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal = false);
 
-  void applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie,
+  void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie,
                                  bool Minimal = false);
 
   /// \brief Find existing DIE or create new DIE for the given type.
   DIE *getOrCreateTypeDIE(const MDNode *N);
 
   /// \brief Get context owner's DIE.
-  DIE *createTypeDIE(const MDCompositeType *Ty);
+  DIE *createTypeDIE(const DICompositeType *Ty);
 
   /// \brief Get context owner's DIE.
-  DIE *getOrCreateContextDIE(const MDScope *Context);
+  DIE *getOrCreateContextDIE(const DIScope *Context);
 
   /// \brief Construct DIEs for types that contain vtables.
   void constructContainingTypeDIEs();
 
   /// \brief Construct function argument DIEs.
-  void constructSubprogramArguments(DIE &Buffer, MDTypeRefArray Args);
+  void constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args);
 
   /// Create a DIE with the given Tag, add the DIE to its parent, and
   /// call insertDIE if MD is not null.
-  DIE &createAndAddDIE(unsigned Tag, DIE &Parent, const DebugNode *N = nullptr);
+  DIE &createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N = nullptr);
 
   /// Compute the size of a header for this unit, not including the initial
   /// length field.
@@ -335,11 +335,11 @@
 
   virtual DwarfCompileUnit &getCU() = 0;
 
-  void constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy);
+  void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy);
 
 protected:
   /// \brief Create new static data member DIE.
-  DIE *getOrCreateStaticMemberDIE(const MDDerivedType *DT);
+  DIE *getOrCreateStaticMemberDIE(const DIDerivedType *DT);
 
   /// Look up the source ID with the given directory and source file names. If
   /// none currently exists, create a new ID and insert it in the line table.
@@ -347,22 +347,22 @@
 
   /// \brief Look in the DwarfDebug map for the MDNode that corresponds to the
   /// reference.
-  template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
+  template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
     return DD->resolve(Ref);
   }
 
 private:
-  void constructTypeDIE(DIE &Buffer, const MDBasicType *BTy);
-  void constructTypeDIE(DIE &Buffer, const MDDerivedType *DTy);
-  void constructTypeDIE(DIE &Buffer, const MDSubroutineType *DTy);
-  void constructSubrangeDIE(DIE &Buffer, const MDSubrange *SR, DIE *IndexTy);
-  void constructArrayTypeDIE(DIE &Buffer, const MDCompositeType *CTy);
-  void constructEnumTypeDIE(DIE &Buffer, const MDCompositeType *CTy);
-  void constructMemberDIE(DIE &Buffer, const MDDerivedType *DT);
+  void constructTypeDIE(DIE &Buffer, const DIBasicType *BTy);
+  void constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy);
+  void constructTypeDIE(DIE &Buffer, const DISubroutineType *DTy);
+  void constructSubrangeDIE(DIE &Buffer, const DISubrange *SR, DIE *IndexTy);
+  void constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy);
+  void constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy);
+  void constructMemberDIE(DIE &Buffer, const DIDerivedType *DT);
   void constructTemplateTypeParameterDIE(DIE &Buffer,
-                                         const MDTemplateTypeParameter *TP);
+                                         const DITemplateTypeParameter *TP);
   void constructTemplateValueParameterDIE(DIE &Buffer,
-                                          const MDTemplateValueParameter *TVP);
+                                          const DITemplateValueParameter *TVP);
 
   /// \brief Return the default lower bound for an array.
   ///
@@ -391,7 +391,7 @@
 
   /// If this is a named finished type then include it in the list of types for
   /// the accelerator tables.
-  void updateAcceleratorTables(const MDScope *Context, const MDType *Ty,
+  void updateAcceleratorTables(const DIScope *Context, const DIType *Ty,
                                const DIE &TyDIE);
 
   virtual bool isDwoUnit() const = 0;
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp
index ff21781..f394aba 100644
--- a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp
@@ -20,11 +20,11 @@
 
 StringRef WinCodeViewLineTables::getFullFilepath(const MDNode *S) {
   assert(S);
-  assert((isa<MDCompileUnit>(S) || isa<MDFile>(S) || isa<MDSubprogram>(S) ||
-          isa<MDLexicalBlockBase>(S)) &&
+  assert((isa<DICompileUnit>(S) || isa<DIFile>(S) || isa<DISubprogram>(S) ||
+          isa<DILexicalBlockBase>(S)) &&
          "Unexpected scope info");
 
-  auto *Scope = cast<MDScope>(S);
+  auto *Scope = cast<DIScope>(S);
   StringRef Dir = Scope->getDirectory(),
             Filename = Scope->getFilename();
   char *&Result = DirAndFilenameToFilepathMap[std::make_pair(Dir, Filename)];
diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp
index c7e7e58..59a9289 100644
--- a/llvm/lib/CodeGen/InlineSpiller.cpp
+++ b/llvm/lib/CodeGen/InlineSpiller.cpp
@@ -1232,7 +1232,7 @@
       DebugLoc DL = MI->getDebugLoc();
       DEBUG(dbgs() << "Modifying debug info due to spill:" << "\t" << *MI);
       MachineBasicBlock *MBB = MI->getParent();
-      assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
+      assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
              "Expected inlined-at fields to agree");
       BuildMI(*MBB, MBB->erase(MI), DL, TII.get(TargetOpcode::DBG_VALUE))
           .addFrameIndex(StackSlot)
diff --git a/llvm/lib/CodeGen/LexicalScopes.cpp b/llvm/lib/CodeGen/LexicalScopes.cpp
index d6998d6..be61a20 100644
--- a/llvm/lib/CodeGen/LexicalScopes.cpp
+++ b/llvm/lib/CodeGen/LexicalScopes.cpp
@@ -59,10 +59,10 @@
   for (const auto &MBB : *MF) {
     const MachineInstr *RangeBeginMI = nullptr;
     const MachineInstr *PrevMI = nullptr;
-    const MDLocation *PrevDL = nullptr;
+    const DILocation *PrevDL = nullptr;
     for (const auto &MInsn : MBB) {
       // Check if instruction has valid location information.
-      const MDLocation *MIDL = MInsn.getDebugLoc();
+      const DILocation *MIDL = MInsn.getDebugLoc();
       if (!MIDL) {
         PrevMI = &MInsn;
         continue;
@@ -106,14 +106,14 @@
 
 /// findLexicalScope - Find lexical scope, either regular or inlined, for the
 /// given DebugLoc. Return NULL if not found.
-LexicalScope *LexicalScopes::findLexicalScope(const MDLocation *DL) {
-  MDLocalScope *Scope = DL->getScope();
+LexicalScope *LexicalScopes::findLexicalScope(const DILocation *DL) {
+  DILocalScope *Scope = DL->getScope();
   if (!Scope)
     return nullptr;
 
   // The scope that we were created with could have an extra file - which
   // isn't what we care about in this case.
-  if (auto *File = dyn_cast<MDLexicalBlockFile>(Scope))
+  if (auto *File = dyn_cast<DILexicalBlockFile>(Scope))
     Scope = File->getScope();
 
   if (auto *IA = DL->getInlinedAt()) {
@@ -125,8 +125,8 @@
 
 /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
 /// not available then create new lexical scope.
-LexicalScope *LexicalScopes::getOrCreateLexicalScope(const MDLocalScope *Scope,
-                                                     const MDLocation *IA) {
+LexicalScope *LexicalScopes::getOrCreateLexicalScope(const DILocalScope *Scope,
+                                                     const DILocation *IA) {
   if (IA) {
     // Create an abstract scope for inlined function.
     getOrCreateAbstractScope(Scope);
@@ -139,17 +139,17 @@
 
 /// getOrCreateRegularScope - Find or create a regular lexical scope.
 LexicalScope *
-LexicalScopes::getOrCreateRegularScope(const MDLocalScope *Scope) {
-  if (auto *File = dyn_cast<MDLexicalBlockFile>(Scope))
+LexicalScopes::getOrCreateRegularScope(const DILocalScope *Scope) {
+  if (auto *File = dyn_cast<DILexicalBlockFile>(Scope))
     Scope = File->getScope();
 
   auto I = LexicalScopeMap.find(Scope);
   if (I != LexicalScopeMap.end())
     return &I->second;
 
-  // FIXME: Should the following dyn_cast be MDLexicalBlock?
+  // FIXME: Should the following dyn_cast be DILexicalBlock?
   LexicalScope *Parent = nullptr;
-  if (auto *Block = dyn_cast<MDLexicalBlockBase>(Scope))
+  if (auto *Block = dyn_cast<DILexicalBlockBase>(Scope))
     Parent = getOrCreateLexicalScope(Block->getScope());
   I = LexicalScopeMap.emplace(std::piecewise_construct,
                               std::forward_as_tuple(Scope),
@@ -157,7 +157,7 @@
                                                     false)).first;
 
   if (!Parent) {
-    assert(cast<MDSubprogram>(Scope)->describes(MF->getFunction()));
+    assert(cast<DISubprogram>(Scope)->describes(MF->getFunction()));
     assert(!CurrentFnLexicalScope);
     CurrentFnLexicalScope = &I->second;
   }
@@ -167,15 +167,15 @@
 
 /// getOrCreateInlinedScope - Find or create an inlined lexical scope.
 LexicalScope *
-LexicalScopes::getOrCreateInlinedScope(const MDLocalScope *Scope,
-                                       const MDLocation *InlinedAt) {
-  std::pair<const MDLocalScope *, const MDLocation *> P(Scope, InlinedAt);
+LexicalScopes::getOrCreateInlinedScope(const DILocalScope *Scope,
+                                       const DILocation *InlinedAt) {
+  std::pair<const DILocalScope *, const DILocation *> P(Scope, InlinedAt);
   auto I = InlinedLexicalScopeMap.find(P);
   if (I != InlinedLexicalScopeMap.end())
     return &I->second;
 
   LexicalScope *Parent;
-  if (auto *Block = dyn_cast<MDLexicalBlockBase>(Scope))
+  if (auto *Block = dyn_cast<DILexicalBlockBase>(Scope))
     Parent = getOrCreateInlinedScope(Block->getScope(), InlinedAt);
   else
     Parent = getOrCreateLexicalScope(InlinedAt);
@@ -190,25 +190,25 @@
 
 /// getOrCreateAbstractScope - Find or create an abstract lexical scope.
 LexicalScope *
-LexicalScopes::getOrCreateAbstractScope(const MDLocalScope *Scope) {
+LexicalScopes::getOrCreateAbstractScope(const DILocalScope *Scope) {
   assert(Scope && "Invalid Scope encoding!");
 
-  if (auto *File = dyn_cast<MDLexicalBlockFile>(Scope))
+  if (auto *File = dyn_cast<DILexicalBlockFile>(Scope))
     Scope = File->getScope();
   auto I = AbstractScopeMap.find(Scope);
   if (I != AbstractScopeMap.end())
     return &I->second;
 
-  // FIXME: Should the following isa be MDLexicalBlock?
+  // FIXME: Should the following isa be DILexicalBlock?
   LexicalScope *Parent = nullptr;
-  if (auto *Block = dyn_cast<MDLexicalBlockBase>(Scope))
+  if (auto *Block = dyn_cast<DILexicalBlockBase>(Scope))
     Parent = getOrCreateAbstractScope(Block->getScope());
 
   I = AbstractScopeMap.emplace(std::piecewise_construct,
                                std::forward_as_tuple(Scope),
                                std::forward_as_tuple(Parent, Scope,
                                                      nullptr, true)).first;
-  if (isa<MDSubprogram>(Scope))
+  if (isa<DISubprogram>(Scope))
     AbstractScopesList.push_back(&I->second);
   return &I->second;
 }
@@ -269,7 +269,7 @@
 /// have machine instructions that belong to lexical scope identified by
 /// DebugLoc.
 void LexicalScopes::getMachineBasicBlocks(
-    const MDLocation *DL, SmallPtrSetImpl<const MachineBasicBlock *> &MBBs) {
+    const DILocation *DL, SmallPtrSetImpl<const MachineBasicBlock *> &MBBs) {
   MBBs.clear();
   LexicalScope *Scope = getOrCreateLexicalScope(DL);
   if (!Scope)
@@ -292,7 +292,7 @@
 
 /// dominates - Return true if DebugLoc's lexical scope dominates at least one
 /// machine instruction's lexical scope in a given machine basic block.
-bool LexicalScopes::dominates(const MDLocation *DL, MachineBasicBlock *MBB) {
+bool LexicalScopes::dominates(const DILocation *DL, MachineBasicBlock *MBB) {
   LexicalScope *Scope = getOrCreateLexicalScope(DL);
   if (!Scope)
     return false;
@@ -304,7 +304,7 @@
   bool Result = false;
   for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E;
        ++I) {
-    if (const MDLocation *IDL = I->getDebugLoc())
+    if (const DILocation *IDL = I->getDebugLoc())
       if (LexicalScope *IScope = getOrCreateLexicalScope(IDL))
         if (Scope->dominates(IScope))
           return true;
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index df48c53..1571551 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -158,7 +158,7 @@
   UserValue *getNext() const { return next; }
 
   /// match - Does this UserValue match the parameters?
-  bool match(const MDNode *Var, const MDNode *Expr, const MDLocation *IA,
+  bool match(const MDNode *Var, const MDNode *Expr, const DILocation *IA,
              unsigned Offset, bool indirect) const {
     return Var == Variable && Expr == Expression && dl->getInlinedAt() == IA &&
            Offset == offset && indirect == IsIndirect;
@@ -362,7 +362,7 @@
   if (!DL)
     return;
 
-  auto *Scope = cast<MDScope>(DL.getScope());
+  auto *Scope = cast<DIScope>(DL.getScope());
   // Omit the directory, because it's likely to be long and uninteresting.
   CommentOS << Scope->getFilename();
   CommentOS << ':' << DL.getLine();
@@ -378,8 +378,8 @@
   CommentOS << " ]";
 }
 
-static void printExtendedName(raw_ostream &OS, const MDLocalVariable *V,
-                              const MDLocation *DL) {
+static void printExtendedName(raw_ostream &OS, const DILocalVariable *V,
+                              const DILocation *DL) {
   const LLVMContext &Ctx = V->getContext();
   StringRef Res = V->getName();
   if (!Res.empty())
@@ -394,7 +394,7 @@
 }
 
 void UserValue::print(raw_ostream &OS, const TargetRegisterInfo *TRI) {
-  auto *DV = cast<MDLocalVariable>(Variable);
+  auto *DV = cast<DILocalVariable>(Variable);
   OS << "!\"";
   printExtendedName(OS, DV, dl);
 
@@ -981,7 +981,7 @@
   MachineOperand &Loc = locations[LocNo];
   ++NumInsertedDebugValues;
 
-  assert(cast<MDLocalVariable>(Variable)
+  assert(cast<DILocalVariable>(Variable)
              ->isValidLocationForIntrinsic(getDebugLoc()) &&
          "Expected inlined-at fields to agree");
   if (Loc.isReg())
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.h b/llvm/lib/CodeGen/LiveDebugVariables.h
index 88a34dd..ac2d1a1 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.h
+++ b/llvm/lib/CodeGen/LiveDebugVariables.h
@@ -33,7 +33,7 @@
 
 class LiveDebugVariables : public MachineFunctionPass {
   void *pImpl;
-  DenseMap<const Function *, MDSubprogram *> FunctionDIs;
+  DenseMap<const Function *, DISubprogram *> FunctionDIs;
 
 public:
   static char ID; // Pass identification, replacement for typeid
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index 86d33b0..7f3c3e9 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -1619,7 +1619,7 @@
     }
     if (isDebugValue() && MO.isMetadata()) {
       // Pretty print DBG_VALUE instructions.
-      auto *DIV = dyn_cast<MDLocalVariable>(MO.getMetadata());
+      auto *DIV = dyn_cast<DILocalVariable>(MO.getMetadata());
       if (DIV && !DIV->getName().empty())
         OS << "!\"" << DIV->getName() << '\"';
       else
@@ -1710,7 +1710,7 @@
   // Print debug location information.
   if (isDebugValue() && getOperand(e - 2).isMetadata()) {
     if (!HaveSemi) OS << ";";
-    auto *DV = cast<MDLocalVariable>(getOperand(e - 2).getMetadata());
+    auto *DV = cast<DILocalVariable>(getOperand(e - 2).getMetadata());
     OS << " line no:" <<  DV->getLine();
     if (auto *InlinedAt = debugLoc->getInlinedAt()) {
       DebugLoc InlinedAtDL(InlinedAt);
diff --git a/llvm/lib/CodeGen/RegAllocFast.cpp b/llvm/lib/CodeGen/RegAllocFast.cpp
index c311c7b..fd3d4d7 100644
--- a/llvm/lib/CodeGen/RegAllocFast.cpp
+++ b/llvm/lib/CodeGen/RegAllocFast.cpp
@@ -302,7 +302,7 @@
       bool IsIndirect = DBG->isIndirectDebugValue();
       uint64_t Offset = IsIndirect ? DBG->getOperand(1).getImm() : 0;
       DebugLoc DL = DBG->getDebugLoc();
-      assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
+      assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
              "Expected inlined-at fields to agree");
       MachineInstr *NewDV =
           BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::DBG_VALUE))
@@ -874,7 +874,7 @@
               DebugLoc DL = MI->getDebugLoc();
               MachineBasicBlock *MBB = MI->getParent();
               assert(
-                  cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
+                  cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
                   "Expected inlined-at fields to agree");
               MachineInstr *NewDV = BuildMI(*MBB, MBB->erase(MI), DL,
                                             TII->get(TargetOpcode::DBG_VALUE))
diff --git a/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp b/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
index ff81fd1..7abc0c4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
@@ -650,7 +650,7 @@
   MDNode *Var = SD->getVariable();
   MDNode *Expr = SD->getExpression();
   DebugLoc DL = SD->getDebugLoc();
-  assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
+  assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
          "Expected inlined-at fields to agree");
 
   if (SD->getKind() == SDDbgValue::FRAMEIX) {
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 8441696..d289406 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5978,7 +5978,7 @@
 SDDbgValue *SelectionDAG::getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N,
                                       unsigned R, bool IsIndirect, uint64_t Off,
                                       DebugLoc DL, unsigned O) {
-  assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
+  assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
          "Expected inlined-at fields to agree");
   return new (Allocator) SDDbgValue(Var, Expr, N, R, IsIndirect, Off, DL, O);
 }
@@ -5987,7 +5987,7 @@
 SDDbgValue *SelectionDAG::getConstantDbgValue(MDNode *Var, MDNode *Expr,
                                               const Value *C, uint64_t Off,
                                               DebugLoc DL, unsigned O) {
-  assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
+  assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
          "Expected inlined-at fields to agree");
   return new (Allocator) SDDbgValue(Var, Expr, C, Off, DL, O);
 }
@@ -5996,7 +5996,7 @@
 SDDbgValue *SelectionDAG::getFrameIndexDbgValue(MDNode *Var, MDNode *Expr,
                                                 unsigned FI, uint64_t Off,
                                                 DebugLoc DL, unsigned O) {
-  assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
+  assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
          "Expected inlined-at fields to agree");
   return new (Allocator) SDDbgValue(Var, Expr, FI, Off, DL, O);
 }
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 08bdccd..db41c40 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -999,8 +999,8 @@
     const DbgValueInst *DI = DDI.getDI();
     DebugLoc dl = DDI.getdl();
     unsigned DbgSDNodeOrder = DDI.getSDNodeOrder();
-    MDLocalVariable *Variable = DI->getVariable();
-    MDExpression *Expr = DI->getExpression();
+    DILocalVariable *Variable = DI->getVariable();
+    DIExpression *Expr = DI->getExpression();
     assert(Variable->isValidLocationForIntrinsic(dl) &&
            "Expected inlined-at fields to agree");
     uint64_t Offset = DI->getOffset();
@@ -3980,8 +3980,8 @@
 /// argument, create the corresponding DBG_VALUE machine instruction for it now.
 /// At the end of instruction selection, they will be inserted to the entry BB.
 bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
-    const Value *V, MDLocalVariable *Variable, MDExpression *Expr,
-    MDLocation *DL, int64_t Offset, bool IsIndirect, const SDValue &N) {
+    const Value *V, DILocalVariable *Variable, DIExpression *Expr,
+    DILocation *DL, int64_t Offset, bool IsIndirect, const SDValue &N) {
   const Argument *Arg = dyn_cast<Argument>(V);
   if (!Arg)
     return false;
@@ -4175,8 +4175,8 @@
   }
   case Intrinsic::dbg_declare: {
     const DbgDeclareInst &DI = cast<DbgDeclareInst>(I);
-    MDLocalVariable *Variable = DI.getVariable();
-    MDExpression *Expression = DI.getExpression();
+    DILocalVariable *Variable = DI.getVariable();
+    DIExpression *Expression = DI.getExpression();
     const Value *Address = DI.getAddress();
     assert(Variable && "Missing variable");
     if (!Address) {
@@ -4257,8 +4257,8 @@
     const DbgValueInst &DI = cast<DbgValueInst>(I);
     assert(DI.getVariable() && "Missing variable");
 
-    MDLocalVariable *Variable = DI.getVariable();
-    MDExpression *Expression = DI.getExpression();
+    DILocalVariable *Variable = DI.getVariable();
+    DIExpression *Expression = DI.getExpression();
     uint64_t Offset = DI.getOffset();
     const Value *V = DI.getValue();
     if (!V)
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
index 3e232e7..f812507 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
@@ -866,8 +866,8 @@
   /// EmitFuncArgumentDbgValue - If V is an function argument then create
   /// corresponding DBG_VALUE machine instruction for it now. At the end of
   /// instruction selection, they will be inserted to the entry BB.
-  bool EmitFuncArgumentDbgValue(const Value *V, MDLocalVariable *Variable,
-                                MDExpression *Expr, MDLocation *DL,
+  bool EmitFuncArgumentDbgValue(const Value *V, DILocalVariable *Variable,
+                                DIExpression *Expr, DILocation *DL,
                                 int64_t Offset, bool IsIndirect,
                                 const SDValue &N);
 
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
index 636c0a7..b728833 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -523,7 +523,7 @@
   if (!G)
     return;
 
-  MDLocation *L = getDebugLoc();
+  DILocation *L = getDebugLoc();
   if (!L)
     return;
 
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 7213a5b..e208076 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -504,7 +504,7 @@
       DebugLoc DL = MI->getDebugLoc();
       bool IsIndirect = MI->isIndirectDebugValue();
       unsigned Offset = IsIndirect ? MI->getOperand(1).getImm() : 0;
-      assert(cast<MDLocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
+      assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
              "Expected inlined-at fields to agree");
       // Def is never a terminator here, so it is ok to increment InsertPos.
       BuildMI(*EntryMBB, ++InsertPos, DL, TII->get(TargetOpcode::DBG_VALUE),
diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp
index 2bf2d64..f9a2072 100644
--- a/llvm/lib/CodeGen/StackColoring.cpp
+++ b/llvm/lib/CodeGen/StackColoring.cpp
@@ -464,7 +464,7 @@
       continue;
     if (SlotRemap.count(VI.Slot)) {
       DEBUG(dbgs() << "Remapping debug info for ["
-                   << cast<MDLocalVariable>(VI.Var)->getName() << "].\n");
+                   << cast<DILocalVariable>(VI.Var)->getName() << "].\n");
       VI.Slot = SlotRemap[VI.Slot];
       FixedDbg++;
     }