Follow-up to r204790: don't try to emit line tables if there are no functions with DI in the TU

llvm-svn: 204795
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp
index 9363303..50b2ca8 100644
--- a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp
@@ -304,11 +304,18 @@
   }
 }
 
-void WinCodeViewLineTables::endFunction(const MachineFunction *) {
+void WinCodeViewLineTables::endFunction(const MachineFunction *MF) {
   if (!Asm || !CurFn)  // We haven't created any debug info for this function.
     return;
 
-  if (!CurFn->Instrs.empty()) {
+  const Function *GV = MF->getFunction();
+  assert(FnDebugInfo.count(GV) == true);
+  assert(CurFn == &FnDebugInfo[GV]);
+
+  if (CurFn->Instrs.empty()) {
+    FnDebugInfo.erase(GV);
+    VisitedFunctions.pop_back();
+  } else {
     // Define end label for subprogram.
     MCSymbol *FunctionEndSym = Asm->OutStreamer.getContext().CreateTempSymbol();
     Asm->OutStreamer.EmitLabel(FunctionEndSym);