Revert "[DebugInfo] Generate DWARF debug information for labels."

This reverts commit b454fa1b4079b6c0a5b1565982d16516385838d7.

llvm-svn: 337812
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index a433ceb..f1e61b4 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -188,12 +188,12 @@
 }
 
 bool DbgVariable::isBlockByrefVariable() const {
-  assert(getVariable() && "Invalid complex DbgVariable!");
-  return getVariable()->getType().resolve()->isBlockByrefStruct();
+  assert(Var && "Invalid complex DbgVariable!");
+  return Var->getType().resolve()->isBlockByrefStruct();
 }
 
 const DIType *DbgVariable::getType() const {
-  DIType *Ty = getVariable()->getType().resolve();
+  DIType *Ty = Var->getType().resolve();
   // FIXME: isBlockByrefVariable should be reformulated in terms of complex
   // addresses instead.
   if (Ty->isBlockByrefStruct()) {
@@ -258,8 +258,8 @@
 void DbgVariable::addMMIEntry(const DbgVariable &V) {
   assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
   assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry");
-  assert(V.getVariable() == getVariable() && "conflicting variable");
-  assert(V.getInlinedAt() == getInlinedAt() && "conflicting inlined-at location");
+  assert(V.Var == Var && "conflicting variable");
+  assert(V.IA == IA && "conflicting inlined-at location");
 
   assert(!FrameIndexExprs.empty() && "Expected an MMI entry");
   assert(!V.FrameIndexExprs.empty() && "Expected an MMI entry");
@@ -726,16 +726,16 @@
   }
 }
 
-void DwarfDebug::finishEntityDefinitions() {
-  for (const auto &Entity : ConcreteEntities) {
-    DIE *Die = Entity->getDIE();
-    assert(Die);
+void DwarfDebug::finishVariableDefinitions() {
+  for (const auto &Var : ConcreteVariables) {
+    DIE *VariableDie = Var->getDIE();
+    assert(VariableDie);
     // FIXME: Consider the time-space tradeoff of just storing the unit pointer
-    // in the ConcreteEntities list, rather than looking it up again here.
+    // in the ConcreteVariables list, rather than looking it up again here.
     // DIE::getUnit isn't simple - it walks parent pointers, etc.
-    DwarfCompileUnit *Unit = CUDieMap.lookup(Die->getUnitDie());
+    DwarfCompileUnit *Unit = CUDieMap.lookup(VariableDie->getUnitDie());
     assert(Unit);
-    Unit->finishEntityDefinition(Entity.get());
+    Unit->finishVariableDefinition(*Var);
   }
 }
 
@@ -753,7 +753,7 @@
 
   finishSubprogramDefinitions();
 
-  finishEntityDefinitions();
+  finishVariableDefinitions();
 
   // Include the DWO file name in the hash if there's more than one CU.
   // This handles ThinLTO's situation where imported CUs may very easily be
@@ -910,24 +910,25 @@
   // FIXME: AbstractVariables.clear();
 }
 
-void DwarfDebug::ensureAbstractEntityIsCreated(DwarfCompileUnit &CU,
-                                               const DINode *Node,
-                                               const MDNode *ScopeNode) {
-  if (CU.getExistingAbstractEntity(Node))
+void DwarfDebug::ensureAbstractVariableIsCreated(DwarfCompileUnit &CU, InlinedVariable IV,
+                                                 const MDNode *ScopeNode) {
+  const DILocalVariable *Cleansed = nullptr;
+  if (CU.getExistingAbstractVariable(IV, Cleansed))
     return;
 
-  CU.createAbstractEntity(Node, LScopes.getOrCreateAbstractScope(
+  CU.createAbstractVariable(Cleansed, LScopes.getOrCreateAbstractScope(
                                        cast<DILocalScope>(ScopeNode)));
 }
 
-void DwarfDebug::ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &CU,
-    const DINode *Node, const MDNode *ScopeNode) {
-  if (CU.getExistingAbstractEntity(Node))
+void DwarfDebug::ensureAbstractVariableIsCreatedIfScoped(DwarfCompileUnit &CU,
+    InlinedVariable IV, const MDNode *ScopeNode) {
+  const DILocalVariable *Cleansed = nullptr;
+  if (CU.getExistingAbstractVariable(IV, Cleansed))
     return;
 
   if (LexicalScope *Scope =
           LScopes.findAbstractScope(cast_or_null<DILocalScope>(ScopeNode)))
-    CU.createAbstractEntity(Node, Scope);
+    CU.createAbstractVariable(Cleansed, Scope);
 }
 
 // Collect variable information from side table maintained by MF.
@@ -948,14 +949,14 @@
     if (!Scope)
       continue;
 
-    ensureAbstractEntityIsCreatedIfScoped(TheCU, Var.first, Scope->getScopeNode());
+    ensureAbstractVariableIsCreatedIfScoped(TheCU, Var, Scope->getScopeNode());
     auto RegVar = llvm::make_unique<DbgVariable>(Var.first, Var.second);
     RegVar->initializeMMI(VI.Expr, VI.Slot);
     if (DbgVariable *DbgVar = MFVars.lookup(Var))
       DbgVar->addMMIEntry(*RegVar);
     else if (InfoHolder.addScopeVariable(Scope, RegVar.get())) {
       MFVars.insert({Var, RegVar.get()});
-      ConcreteEntities.push_back(std::move(RegVar));
+      ConcreteVariables.push_back(std::move(RegVar));
     }
   }
 }
@@ -1120,26 +1121,14 @@
   }
 }
 
-DbgEntity *DwarfDebug::createConcreteEntity(DwarfCompileUnit &TheCU,
-                                            LexicalScope &Scope,
-                                            const DINode *Node,
-                                            const DILocation *Location,
-                                            const MCSymbol *Sym) {
-  ensureAbstractEntityIsCreatedIfScoped(TheCU, Node, Scope.getScopeNode());
-  if (isa<const DILocalVariable>(Node)) {
-    ConcreteEntities.push_back(
-        llvm::make_unique<DbgVariable>(cast<const DILocalVariable>(Node),
-	                               Location));
-    InfoHolder.addScopeVariable(&Scope,
-        cast<DbgVariable>(ConcreteEntities.back().get()));
-  } else if (isa<const DILabel>(Node)) {
-    ConcreteEntities.push_back(
-        llvm::make_unique<DbgLabel>(cast<const DILabel>(Node),
-	                            Location, Sym));
-    InfoHolder.addScopeLabel(&Scope,
-        cast<DbgLabel>(ConcreteEntities.back().get()));
-  }
-  return ConcreteEntities.back().get();
+DbgVariable *DwarfDebug::createConcreteVariable(DwarfCompileUnit &TheCU,
+                                                LexicalScope &Scope,
+                                                InlinedVariable IV) {
+  ensureAbstractVariableIsCreatedIfScoped(TheCU, IV, Scope.getScopeNode());
+  ConcreteVariables.push_back(
+      llvm::make_unique<DbgVariable>(IV.first, IV.second));
+  InfoHolder.addScopeVariable(&Scope, ConcreteVariables.back().get());
+  return ConcreteVariables.back().get();
 }
 
 /// Determine whether a *singular* DBG_VALUE is valid for the entirety of its
@@ -1201,9 +1190,9 @@
 }
 
 // Find variables for each lexical scope.
-void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
-                                   const DISubprogram *SP,
-                                   DenseSet<InlinedVariable> &Processed) {
+void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
+                                     const DISubprogram *SP,
+                                     DenseSet<InlinedVariable> &Processed) {
   // Grab the variable info that was squirreled away in the MMI side-table.
   collectVariableInfoFromMFTable(TheCU, Processed);
 
@@ -1227,8 +1216,7 @@
       continue;
 
     Processed.insert(IV);
-    DbgVariable *RegVar = cast<DbgVariable>(createConcreteEntity(TheCU,
-	                                      *Scope, IV.first, IV.second));
+    DbgVariable *RegVar = createConcreteVariable(TheCU, *Scope, IV);
 
     const MachineInstr *MInsn = Ranges.front().first;
     assert(MInsn->isDebugValue() && "History must begin with debug value");
@@ -1261,44 +1249,13 @@
       Entry.finalize(*Asm, List, BT);
   }
 
-  // For each InlinedLabel collected from DBG_LABEL instructions, convert to
-  // DWARF-related DbgLabel.
-  for (const auto &I : DbgLabels) {
-    InlinedLabel IL = I.first;
-    const MachineInstr *MI = I.second;
-    if (MI == nullptr)
-      continue;
-
-    LexicalScope *Scope = nullptr;
-    // Get inlined DILocation if it is inlined label.
-    if (const DILocation *IA = IL.second)
-      Scope = LScopes.findInlinedScope(IL.first->getScope(), IA);
-    else
-      Scope = LScopes.findLexicalScope(IL.first->getScope());
-    // If label scope is not found then skip this label.
-    if (!Scope)
-      continue;
-
-    /// At this point, the temporary label is created.
-    /// Save the temporary label to DbgLabel entity to get the
-    /// actually address when generating Dwarf DIE.
-    MCSymbol *Sym = getLabelBeforeInsn(MI);
-    createConcreteEntity(TheCU, *Scope, IL.first, IL.second, Sym);
-  }
-
-  // Collect info for variables/labels that were optimized out.
+  // Collect info for variables that were optimized out.
   for (const DINode *DN : SP->getRetainedNodes()) {
-    LexicalScope *Scope = nullptr;
     if (auto *DV = dyn_cast<DILocalVariable>(DN)) {
-      if (!Processed.insert(InlinedVariable(DV, nullptr)).second)
-	continue;
-      Scope = LScopes.findLexicalScope(DV->getScope());
-    } else if (auto *DL = dyn_cast<DILabel>(DN)) {
-      Scope = LScopes.findLexicalScope(DL->getScope());
+      if (Processed.insert(InlinedVariable(DV, nullptr)).second)
+        if (LexicalScope *Scope = LScopes.findLexicalScope(DV->getScope()))
+          createConcreteVariable(TheCU, *Scope, InlinedVariable(DV, nullptr));
     }
-
-    if (Scope)
-      createConcreteEntity(TheCU, *Scope, DN, nullptr);
   }
 }
 
@@ -1456,7 +1413,7 @@
   DwarfCompileUnit &TheCU = *CUMap.lookup(SP->getUnit());
 
   DenseSet<InlinedVariable> ProcessedVars;
-  collectEntityInfo(TheCU, SP, ProcessedVars);
+  collectVariableInfo(TheCU, SP, ProcessedVars);
 
   // Add the range of this function to the list of ranges for the CU.
   TheCU.addRange(RangeSpan(Asm->getFunctionBegin(), Asm->getFunctionEnd()));
@@ -1484,11 +1441,10 @@
         // Collect info for variables that were optimized out.
         if (!ProcessedVars.insert(InlinedVariable(DV, nullptr)).second)
           continue;
-        ensureAbstractEntityIsCreated(TheCU, DV, DV->getScope());
+        ensureAbstractVariableIsCreated(TheCU, InlinedVariable(DV, nullptr),
+                                        DV->getScope());
         assert(LScopes.getAbstractScopesList().size() == NumAbstractScopes
-               && "ensureAbstractEntityIsCreated inserted abstract scopes");
-      } else if (auto *DL = dyn_cast<DILabel>(DN)) {
-        ensureAbstractEntityIsCreated(TheCU, DL, DL->getScope());
+               && "ensureAbstractVariableIsCreated inserted abstract scopes");
       }
     }
     constructAbstractSubprogramScopeDIE(TheCU, AScope);
@@ -1506,7 +1462,6 @@
   // DbgVariables except those that are also in AbstractVariables (since they
   // can be used cross-function)
   InfoHolder.getScopeVariables().clear();
-  InfoHolder.getScopeLabels().clear();
   PrevLabel = nullptr;
   CurFn = nullptr;
 }