Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -3155,9 +3155,11 @@ SplitDWARFInlining = false; } - if (const Arg *A = Args.getLastArg(options::OPT_g_Group)) { + if (const Arg *A = Args.getLastArg(options::OPT_g_Group, options::OPT_gsplit_dwarf)) { + DebugInfoKind = codegenoptions::LimitedDebugInfo; + + // If the last option explicitly specified a debug-info level, use it. if (checkDebugInfoOption(A, Args, D, TC)) { - // If the last option explicitly specified a debug-info level, use it. if (A->getOption().matches(options::OPT_gN_Group)) { DebugInfoKind = DebugLevelToInfoKind(*A); // If you say "-gsplit-dwarf -gline-tables-only", -gsplit-dwarf loses. @@ -3168,22 +3170,12 @@ // 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 (DwarfFission != DwarfFissionKind::None) { - if (A->getIndex() > SplitDWARFArg->getIndex()) { - if (DebugInfoKind == codegenoptions::NoDebugInfo || - DebugInfoKind == codegenoptions::DebugDirectivesOnly || - (DebugInfoKind == codegenoptions::DebugLineTablesOnly && - SplitDWARFInlining)) - DwarfFission = DwarfFissionKind::None; - } else if (SplitDWARFInlining) - DebugInfoKind = codegenoptions::NoDebugInfo; - } - } else { - // For any other 'g' option, use Limited. - DebugInfoKind = codegenoptions::LimitedDebugInfo; + if (DebugInfoKind == codegenoptions::NoDebugInfo || + DebugInfoKind == codegenoptions::DebugDirectivesOnly || + (DebugInfoKind == codegenoptions::DebugLineTablesOnly && + SplitDWARFInlining)) + DwarfFission = DwarfFissionKind::None; } - } else { - DebugInfoKind = codegenoptions::LimitedDebugInfo; } } @@ -3265,9 +3257,6 @@ CmdArgs.push_back("-fno-split-dwarf-inlining"); if (DwarfFission != DwarfFissionKind::None) { - if (DebugInfoKind == codegenoptions::NoDebugInfo) - DebugInfoKind = codegenoptions::LimitedDebugInfo; - if (DwarfFission == DwarfFissionKind::Single) CmdArgs.push_back("-enable-split-dwarf=single"); else Index: test/Driver/split-debug.c =================================================================== --- test/Driver/split-debug.c +++ test/Driver/split-debug.c @@ -68,7 +68,7 @@ // RUN: FileCheck -check-prefix=CHECK-SPLIT-WITH-GMLT < %t %s // // CHECK-SPLIT-WITH-GMLT: "-enable-split-dwarf" -// CHECK-SPLIT-WITH-GMLT: "-debug-info-kind=line-tables-only" +// CHECK-SPLIT-WITH-GMLT: "-debug-info-kind=limited" // 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