From: Paul Robinson Date: Fri, 29 Sep 2017 21:25:07 +0000 (+0000) Subject: [PS4] Tidy up some debug-tuning v. triple decision-making. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b862f67453ad24060274ad29dc28f56a435025a;p=clang [PS4] Tidy up some debug-tuning v. triple decision-making. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314558 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index e70a707d76..385d34d4e7 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -200,6 +200,9 @@ def arange_sections : Flag<["-"], "arange_sections">, def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">, HelpText<"Generate debug info with external references to clang modules" " or precompiled headers">; +def dwarf_explicit_import : Flag<["-"], "dwarf-explicit-import">, + HelpText<"Generate explicit import from anonymous namespace to containing" + " scope">; def debug_forward_template_params : Flag<["-"], "debug-forward-template-params">, HelpText<"Emit complete descriptions of template parameters in forward" " declarations">; diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 90d912511e..4e1bf51d64 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -2816,8 +2816,6 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, ArgStringList &CmdArgs, codegenoptions::DebugInfoKind &DebugInfoKind, const Arg *&SplitDWARFArg) { - bool IsPS4CPU = T.isPS4CPU(); - if (Args.hasFlag(options::OPT_fdebug_info_for_profiling, options::OPT_fno_debug_info_for_profiling, false)) CmdArgs.push_back("-fdebug-info-for-profiling"); @@ -2900,13 +2898,14 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, // And we handle flag -grecord-gcc-switches later with DWARFDebugFlags. Args.ClaimAllArgs(options::OPT_g_flags_Group); - // Column info is included by default for everything except PS4 and CodeView. + // Column info is included by default for everything except SCE and CodeView. // Clang doesn't track end columns, just starting columns, which, in theory, // is fine for CodeView (and PDB). In practice, however, the Microsoft // debuggers don't handle missing end columns well, so it's better not to // include any column info. if (Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info, - /*Default=*/ !IsPS4CPU && !(IsWindowsMSVC && EmitCodeView))) + /*Default=*/!(IsWindowsMSVC && EmitCodeView) && + DebuggerTuning != llvm::DebuggerKind::SCE)) CmdArgs.push_back("-dwarf-column-info"); // FIXME: Move backend command line options to the module. @@ -2957,8 +2956,9 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, // -gdwarf-aranges turns on the emission of the aranges section in the // backend. - // Always enabled on the PS4. - if (Args.hasArg(options::OPT_gdwarf_aranges) || IsPS4CPU) { + // Always enabled for SCE tuning. + if (Args.hasArg(options::OPT_gdwarf_aranges) || + DebuggerTuning == llvm::DebuggerKind::SCE) { CmdArgs.push_back("-backend-option"); CmdArgs.push_back("-generate-arange-section"); } @@ -2974,6 +2974,10 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, if (DebuggerTuning == llvm::DebuggerKind::SCE) CmdArgs.push_back("-debug-forward-template-params"); + // Do we need to explicitly import anonymous namespaces into the parent scope? + if (DebuggerTuning == llvm::DebuggerKind::SCE) + CmdArgs.push_back("-dwarf-explicit-import"); + RenderDebugInfoCompressionArgs(Args, CmdArgs, D); } diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index e1b14d0c15..37ba39dfd0 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -527,7 +527,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file); Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining); Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs); - Opts.DebugExplicitImport = Triple.isPS4CPU(); + Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import); Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params); for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) diff --git a/test/CodeGenCXX/debug-info-anon-namespace.cpp b/test/CodeGenCXX/debug-info-anon-namespace.cpp index 3f4ef2a383..56c8528abd 100644 --- a/test/CodeGenCXX/debug-info-anon-namespace.cpp +++ b/test/CodeGenCXX/debug-info-anon-namespace.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-scei-ps4 -O0 %s -o - | FileCheck --check-prefix=PS4 %s -// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-unknown-linux-gnu -O0 %s -o - | FileCheck --check-prefix=NON-PS4 %s +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -dwarf-explicit-import -O0 %s -o - | FileCheck --check-prefix=IMPORT %s +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -O0 %s -o - | FileCheck --check-prefix=NOIMPORT %s namespace { @@ -17,11 +17,9 @@ namespace int *b1 = &a1; int *b2 = &a2; - -// PS4: [[NS:![0-9]+]] = !DINamespace -// PS4: [[CU:![0-9]+]] = distinct !DICompileUnit -// PS4: [[NS2:![0-9]+]] = !DINamespace -// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CU]], entity: [[NS]], file: {{![0-9]+}}) -// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[NS]], entity: [[NS2]], file: {{![0-9]+}}, line: {{[0-9]+}}) -// NON-PS4-NOT: !DIImportedEntity - +// IMPORT: [[NS:![0-9]+]] = !DINamespace +// IMPORT: [[CU:![0-9]+]] = distinct !DICompileUnit +// IMPORT: [[NS2:![0-9]+]] = !DINamespace +// IMPORT: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CU]], entity: [[NS]], file: {{![0-9]+}}) +// IMPORT: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[NS]], entity: [[NS2]], file: {{![0-9]+}}, line: {{[0-9]+}}) +// NOIMPORT-NOT: !DIImportedEntity diff --git a/test/Driver/debug-options.c b/test/Driver/debug-options.c index 9445156f4b..3bec1e141d 100644 --- a/test/Driver/debug-options.c +++ b/test/Driver/debug-options.c @@ -76,6 +76,8 @@ // RUN: | FileCheck -check-prefix=NOCI %s // RUN: %clang -### -c %s -g -gcolumn-info -target x86_64-scei-ps4 2>&1 \ // RUN: | FileCheck -check-prefix=CI %s +// RUN: %clang -### -c %s -gsce -target x86_64-unknown-linux 2>&1 \ +// RUN: | FileCheck -check-prefix=NOCI %s // RUN: %clang -### -c -gdwarf-2 %s 2>&1 \ // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s