From 37dcf6bf9754ea87045453f536c9ebdb0358e24c Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 31 Aug 2016 20:54:35 +0000 Subject: [PATCH] DebugInfo: Fix -gsplit-dwarf + -fno-split-dwarf-inlining 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 | 20 ++++++++++++-------- clang/test/Driver/split-debug.c | 7 +++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 129b25c..98724ee 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -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"); diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index 6c69346..eaa1e99 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -47,6 +47,13 @@ // 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 // -- 2.7.4