Revert this. It was breaking stuff.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64428 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
index 0918e6c..47335d3 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -3912,18 +3912,24 @@
   case Intrinsic::dbg_region_start: {
     DwarfWriter *DW = DAG.getDwarfWriter();
     DbgRegionStartInst &RSI = cast<DbgRegionStartInst>(I);
-
-    if (DW && DW->ValidDebugInfo(RSI.getContext()))
-      DW->RecordRegionStart(cast<GlobalVariable>(RSI.getContext()));
+    if (DW && DW->ValidDebugInfo(RSI.getContext())) {
+      unsigned LabelID =
+        DW->RecordRegionStart(cast<GlobalVariable>(RSI.getContext()));
+      DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
+                               getRoot(), LabelID));
+    }
 
     return 0;
   }
   case Intrinsic::dbg_region_end: {
     DwarfWriter *DW = DAG.getDwarfWriter();
     DbgRegionEndInst &REI = cast<DbgRegionEndInst>(I);
-
-    if (DW && DW->ValidDebugInfo(REI.getContext()))
-      DW->RecordRegionEnd(cast<GlobalVariable>(REI.getContext()));
+    if (DW && DW->ValidDebugInfo(REI.getContext())) {
+      unsigned LabelID =
+        DW->RecordRegionEnd(cast<GlobalVariable>(REI.getContext()));
+      DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
+                               getRoot(), LabelID));
+    }
 
     return 0;
   }
@@ -3944,15 +3950,27 @@
       // function start. It will be emitted at asm emission time. However,
       // create a label if this is a beginning of inlined function.
       unsigned Line = Subprogram.getLineNumber();
+      unsigned LabelID = DW->RecordSourceLine(Line, 0, SrcFile);
+
+      if (DW->getRecordSourceLineCount() != 1)
+        DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
+                                 getRoot(), LabelID));
+
       setCurDebugLoc(DebugLoc::get(DAG.getMachineFunction().
-                                   getOrCreateDebugLocID(SrcFile, Line, 0)));
+                         getOrCreateDebugLocID(SrcFile, Line, 0)));
     }
 
     return 0;
   }
-  case Intrinsic::dbg_declare:
-    // FIXME: Do something correct here when declare stuff is working again.
+  case Intrinsic::dbg_declare: {
+    DwarfWriter *DW = DAG.getDwarfWriter();
+    DbgDeclareInst &DI = cast<DbgDeclareInst>(I);
+    Value *Variable = DI.getVariable();
+    if (DW && DW->ValidDebugInfo(Variable))
+      DAG.setRoot(DAG.getNode(ISD::DECLARE, dl, MVT::Other, getRoot(),
+                              getValue(DI.getAddress()), getValue(Variable)));
     return 0;
+  }
 
   case Intrinsic::eh_exception: {
     if (!CurMBB->isLandingPad()) {