--- 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/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index e5a30c8..c37f8cd 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -28,6 +28,7 @@
 #include "llvm/CallingConv.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
+#include "llvm/Function.h"
 #include "llvm/GlobalVariable.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
@@ -1289,17 +1290,23 @@
         
         unsigned Line = DSP->getLine();
         unsigned Col = DSP->getColumn();
-        
-        // A bit self-referential to have DebugLoc on Debug_Loc nodes, but
-        // it won't hurt anything.
-        if (useDEBUG_LOC) {
-          SDValue Ops[] = { Tmp1, DAG.getConstant(Line, MVT::i32),
+
+        const Function *F = DAG.getMachineFunction().getFunction();
+
+        if (!F->hasFnAttr(Attribute::OptimizeForSize)) {
+          // A bit self-referential to have DebugLoc on Debug_Loc nodes, but it
+          // won't hurt anything.
+          if (useDEBUG_LOC) {
+            SDValue Ops[] = { Tmp1, DAG.getConstant(Line, MVT::i32),
                               DAG.getConstant(Col, MVT::i32),
                               DAG.getConstant(SrcFile, MVT::i32) };
-          Result = DAG.getNode(ISD::DEBUG_LOC, dl, MVT::Other, Ops, 4);
+            Result = DAG.getNode(ISD::DEBUG_LOC, dl, MVT::Other, Ops, 4);
+          } else {
+            unsigned ID = DW->RecordSourceLine(Line, Col, SrcFile);
+            Result = DAG.getLabel(ISD::DBG_LABEL, dl, Tmp1, ID);
+          }
         } else {
-          unsigned ID = DW->RecordSourceLine(Line, Col, SrcFile);
-          Result = DAG.getLabel(ISD::DBG_LABEL, dl, Tmp1, ID);
+          Result = Tmp1;  // chain
         }
       } else {
         Result = Tmp1;  // chain