--- Merging (from foreign repository) r64714 into '.':
U    include/llvm/CodeGen/DebugLoc.h
U    lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
U    lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
U    lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp

Enable debug location generation at -Os. This goes with the reapplication of the
r63639 patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64715 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
index 847355c..75a34a6 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
@@ -726,15 +726,20 @@
   ++EmittedInsts;
 
   if (TAI->doesSupportDebugInformation()) {
-    static DebugLoc PrevDL = DebugLoc::getUnknownLoc();
-    DebugLoc CurDL = MI->getDebugLoc();
+    const Function *F = MF->getFunction();
 
-    if (!CurDL.isInvalid() && !CurDL.isUnknown() && PrevDL != CurDL) {
-      DebugLocTuple DLT = MF->getDebugLocTuple(CurDL);
-      printLabel(DW->RecordSourceLine(DLT.Line, DLT.Col, DLT.Src));
+    // FIXME: Support more than '-Os'.
+    if (F->hasFnAttr(Attribute::OptimizeForSize)) {
+      static DebugLoc PrevDL = DebugLoc::getUnknownLoc();
+      DebugLoc CurDL = MI->getDebugLoc();
+
+      if (!CurDL.isUnknown() && PrevDL != CurDL) {
+        DebugLocTuple DLT = MF->getDebugLocTuple(CurDL);
+        printLabel(DW->RecordSourceLine(DLT.Line, DLT.Col, DLT.Src));
+      }
+
+      PrevDL = CurDL;
     }
-
-    PrevDL = CurDL;
   }
 
   // Call the autogenerated instruction printer routines.