Author: dblaikie Date: Wed Aug 24 18:22:36 2016 New Revision: 279687 URL: http://llvm.org/viewvc/llvm-project?rev=279687&view=rev Log: DebugInfo: Let -gsplit-dwarf and -gmlt compose if -fno-split-dwarf-inlining is used
If the inline info is not duplicated into the skeleton CU, then there's value in using -gsplit-dwarf and -gmlt together (to keep all those extra subprograms out of the skeleton CU, while also producing smaller .dwo files) Modified: cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/test/Driver/split-debug.c Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=279687&r1=279686&r2=279687&view=diff ============================================================================== --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Wed Aug 24 18:22:36 2016 @@ -4597,6 +4597,12 @@ void Clang::ConstructJob(Compilation &C, : "-"); } + 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); if (Arg *A = Args.getLastArg(options::OPT_g_Group)) { @@ -4606,8 +4612,15 @@ void Clang::ConstructJob(Compilation &C, // If you say "-gsplit-dwarf -gline-tables-only", -gsplit-dwarf loses. // But -gsplit-dwarf is not a g_group option, hence we have to check the // order explicitly. (If -gsplit-dwarf wins, we fix DebugInfoKind later.) - if (SplitDwarfArg && DebugInfoKind < codegenoptions::LimitedDebugInfo && - A->getIndex() > SplitDwarfArg->getIndex()) + // This gets a bit more complicated if you've disabled inline info in the + // skeleton CUs (splitDwarfInlining) - then there's value in composing + // 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; } else // For any other 'g' option, use Limited. @@ -4659,7 +4672,8 @@ void Clang::ConstructJob(Compilation &C, // splitting and extraction. // FIXME: Currently only works on Linux. if (getToolChain().getTriple().isOSLinux() && SplitDwarfArg) { - DebugInfoKind = codegenoptions::LimitedDebugInfo; + if (splitDwarfInlining) + DebugInfoKind = codegenoptions::LimitedDebugInfo; CmdArgs.push_back("-backend-option"); CmdArgs.push_back("-split-dwarf=Enable"); } @@ -4697,10 +4711,6 @@ void Clang::ConstructJob(Compilation &C, CmdArgs.push_back("-generate-type-units"); } - if (!Args.hasFlag(options::OPT_fsplit_dwarf_inlining, - options::OPT_fno_split_dwarf_inlining, true)) - CmdArgs.push_back("-fno-split-dwarf-inlining"); - // CloudABI and WebAssembly use -ffunction-sections and -fdata-sections by // default. bool UseSeparateSections = Triple.getOS() == llvm::Triple::CloudABI || Modified: cfe/trunk/test/Driver/split-debug.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/split-debug.c?rev=279687&r1=279686&r2=279687&view=diff ============================================================================== --- cfe/trunk/test/Driver/split-debug.c (original) +++ cfe/trunk/test/Driver/split-debug.c Wed Aug 24 18:22:36 2016 @@ -33,11 +33,25 @@ // // CHECK-IAS: objcopy +// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -gmlt -fno-split-dwarf-inlining -S -### %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-GMLT-WITH-SPLIT < %t %s +// +// CHECK-GMLT-WITH-SPLIT: "-split-dwarf=Enable" +// CHECK-GMLT-WITH-SPLIT: "-debug-info-kind=line-tables-only" +// CHECK-GMLT-WITH-SPLIT: "-split-dwarf-file" + +// RUN: %clang -target x86_64-unknown-linux-gnu -gmlt -gsplit-dwarf -fno-split-dwarf-inlining -S -### %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-SPLIT-WITH-GMLT < %t %s +// +// CHECK-SPLIT-WITH-GMLT: "-split-dwarf=Enable" +// 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 -gmlt -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-GMLT-OVER-SPLIT < %t %s // -// CHECK-GMLT-OVER-SPLIT: "-debug-info-kind=line-tables-only" // CHECK-GMLT-OVER-SPLIT-NOT: "-split-dwarf=Enable" +// CHECK-GMLT-OVER-SPLIT: "-debug-info-kind=line-tables-only" // CHECK-GMLT-OVER-SPLIT-NOT: "-split-dwarf-file" // RUN: %clang -target x86_64-unknown-linux-gnu -gmlt -gsplit-dwarf -S -### %s 2> %t @@ -46,11 +60,18 @@ // CHECK-SPLIT-OVER-GMLT: "-split-dwarf=Enable" "-debug-info-kind=limited" // CHECK-SPLIT-OVER-GMLT: "-split-dwarf-file" -// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -g0 -S -### %s 2> %t +// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -g0 -fno-split-dwarf-inlining -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-G0-OVER-SPLIT < %t %s // +// CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf=Enable" // CHECK-G0-OVER-SPLIT-NOT: "-debug-info-kind +// CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf-file" + +// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -g0 -S -### %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-G0-OVER-SPLIT < %t %s +// // CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf=Enable" +// CHECK-G0-OVER-SPLIT-NOT: "-debug-info-kind // CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf-file" // RUN: %clang -target x86_64-unknown-linux-gnu -g0 -gsplit-dwarf -S -### %s 2> %t _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits