DebugInfo: Fix -gsplit-dwarf + -fno-split-dwarf-inlining
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 31 Aug 2016 20:54:35 +0000 (20:54 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 31 Aug 2016 20:54:35 +0000 (20:54 +0000)
I tested the cases involving split-dwarf + gmlt +
no-split-dwarf-inlining, but didn't verify the simpler case without
gmlt.

The logic is, admittedly, a little hairy, but seems about as simple as I
could wrangle it.

llvm-svn: 280290

clang/lib/Driver/Tools.cpp
clang/test/Driver/split-debug.c

index 129b25c..98724ee 100644 (file)
@@ -4602,8 +4602,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   bool splitDwarfInlining =
       Args.hasFlag(options::OPT_fsplit_dwarf_inlining,
                    options::OPT_fno_split_dwarf_inlining, true);
-  if (!splitDwarfInlining)
-    CmdArgs.push_back("-fno-split-dwarf-inlining");
 
   Args.ClaimAllArgs(options::OPT_g_Group);
   Arg *SplitDwarfArg = Args.getLastArg(options::OPT_gsplit_dwarf);
@@ -4619,11 +4617,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
       // split-dwarf and line-tables-only, so let those compose naturally in
       // that case.
       // And if you just turned off debug info, (-gsplit-dwarf -g0) - do that.
-      if (SplitDwarfArg && A->getIndex() > SplitDwarfArg->getIndex() &&
-          ((DebugInfoKind == codegenoptions::DebugLineTablesOnly &&
-            splitDwarfInlining) ||
-           DebugInfoKind == codegenoptions::NoDebugInfo))
-        SplitDwarfArg = nullptr;
+      if (SplitDwarfArg) {
+        if (A->getIndex() > SplitDwarfArg->getIndex()) {
+          if (DebugInfoKind == codegenoptions::NoDebugInfo ||
+              (DebugInfoKind == codegenoptions::DebugLineTablesOnly &&
+               splitDwarfInlining))
+            SplitDwarfArg = nullptr;
+        } else if (splitDwarfInlining)
+          DebugInfoKind = codegenoptions::NoDebugInfo;
+      }
     } else
       // For any other 'g' option, use Limited.
       DebugInfoKind = codegenoptions::LimitedDebugInfo;
@@ -4678,7 +4680,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   // splitting and extraction.
   // FIXME: Currently only works on Linux.
   if (getToolChain().getTriple().isOSLinux() && SplitDwarfArg) {
-    if (splitDwarfInlining)
+    if (!splitDwarfInlining)
+      CmdArgs.push_back("-fno-split-dwarf-inlining");
+    if (DebugInfoKind == codegenoptions::NoDebugInfo)
       DebugInfoKind = codegenoptions::LimitedDebugInfo;
     CmdArgs.push_back("-backend-option");
     CmdArgs.push_back("-split-dwarf=Enable");
index 6c69346..eaa1e99 100644 (file)
 // CHECK-SPLIT-WITH-GMLT: "-debug-info-kind=line-tables-only"
 // CHECK-SPLIT-WITH-GMLT: "-split-dwarf-file"
 
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -fno-split-dwarf-inlining -S -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-SPLIT-WITH-NOINL < %t %s
+//
+// CHECK-SPLIT-WITH-NOINL: "-split-dwarf=Enable"
+// CHECK-SPLIT-WITH-NOINL: "-debug-info-kind=limited"
+// CHECK-SPLIT-WITH-NOINL: "-split-dwarf-file"
+
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -gmlt -S -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-GMLT-OVER-SPLIT < %t %s
 //