Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 3b862f6

Browse files
committed
[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
1 parent 06fad44 commit 3b862f6

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

include/clang/Driver/CC1Options.td

+3
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ def arange_sections : Flag<["-"], "arange_sections">,
200200
def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">,
201201
HelpText<"Generate debug info with external references to clang modules"
202202
" or precompiled headers">;
203+
def dwarf_explicit_import : Flag<["-"], "dwarf-explicit-import">,
204+
HelpText<"Generate explicit import from anonymous namespace to containing"
205+
" scope">;
203206
def debug_forward_template_params : Flag<["-"], "debug-forward-template-params">,
204207
HelpText<"Emit complete descriptions of template parameters in forward"
205208
" declarations">;

lib/Driver/ToolChains/Clang.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -2816,8 +2816,6 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
28162816
ArgStringList &CmdArgs,
28172817
codegenoptions::DebugInfoKind &DebugInfoKind,
28182818
const Arg *&SplitDWARFArg) {
2819-
bool IsPS4CPU = T.isPS4CPU();
2820-
28212819
if (Args.hasFlag(options::OPT_fdebug_info_for_profiling,
28222820
options::OPT_fno_debug_info_for_profiling, false))
28232821
CmdArgs.push_back("-fdebug-info-for-profiling");
@@ -2900,13 +2898,14 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
29002898
// And we handle flag -grecord-gcc-switches later with DWARFDebugFlags.
29012899
Args.ClaimAllArgs(options::OPT_g_flags_Group);
29022900

2903-
// Column info is included by default for everything except PS4 and CodeView.
2901+
// Column info is included by default for everything except SCE and CodeView.
29042902
// Clang doesn't track end columns, just starting columns, which, in theory,
29052903
// is fine for CodeView (and PDB). In practice, however, the Microsoft
29062904
// debuggers don't handle missing end columns well, so it's better not to
29072905
// include any column info.
29082906
if (Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info,
2909-
/*Default=*/ !IsPS4CPU && !(IsWindowsMSVC && EmitCodeView)))
2907+
/*Default=*/!(IsWindowsMSVC && EmitCodeView) &&
2908+
DebuggerTuning != llvm::DebuggerKind::SCE))
29102909
CmdArgs.push_back("-dwarf-column-info");
29112910

29122911
// FIXME: Move backend command line options to the module.
@@ -2957,8 +2956,9 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
29572956

29582957
// -gdwarf-aranges turns on the emission of the aranges section in the
29592958
// backend.
2960-
// Always enabled on the PS4.
2961-
if (Args.hasArg(options::OPT_gdwarf_aranges) || IsPS4CPU) {
2959+
// Always enabled for SCE tuning.
2960+
if (Args.hasArg(options::OPT_gdwarf_aranges) ||
2961+
DebuggerTuning == llvm::DebuggerKind::SCE) {
29622962
CmdArgs.push_back("-backend-option");
29632963
CmdArgs.push_back("-generate-arange-section");
29642964
}
@@ -2974,6 +2974,10 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
29742974
if (DebuggerTuning == llvm::DebuggerKind::SCE)
29752975
CmdArgs.push_back("-debug-forward-template-params");
29762976

2977+
// Do we need to explicitly import anonymous namespaces into the parent scope?
2978+
if (DebuggerTuning == llvm::DebuggerKind::SCE)
2979+
CmdArgs.push_back("-dwarf-explicit-import");
2980+
29772981
RenderDebugInfoCompressionArgs(Args, CmdArgs, D);
29782982
}
29792983

lib/Frontend/CompilerInvocation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
527527
Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
528528
Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
529529
Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
530-
Opts.DebugExplicitImport = Triple.isPS4CPU();
530+
Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import);
531531
Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
532532

533533
for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
+8-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-scei-ps4 -O0 %s -o - | FileCheck --check-prefix=PS4 %s
2-
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-unknown-linux-gnu -O0 %s -o - | FileCheck --check-prefix=NON-PS4 %s
1+
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -dwarf-explicit-import -O0 %s -o - | FileCheck --check-prefix=IMPORT %s
2+
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -O0 %s -o - | FileCheck --check-prefix=NOIMPORT %s
33

44
namespace
55
{
@@ -17,11 +17,9 @@ namespace
1717
int *b1 = &a1;
1818
int *b2 = &a2;
1919

20-
21-
// PS4: [[NS:![0-9]+]] = !DINamespace
22-
// PS4: [[CU:![0-9]+]] = distinct !DICompileUnit
23-
// PS4: [[NS2:![0-9]+]] = !DINamespace
24-
// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CU]], entity: [[NS]], file: {{![0-9]+}})
25-
// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[NS]], entity: [[NS2]], file: {{![0-9]+}}, line: {{[0-9]+}})
26-
// NON-PS4-NOT: !DIImportedEntity
27-
20+
// IMPORT: [[NS:![0-9]+]] = !DINamespace
21+
// IMPORT: [[CU:![0-9]+]] = distinct !DICompileUnit
22+
// IMPORT: [[NS2:![0-9]+]] = !DINamespace
23+
// IMPORT: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CU]], entity: [[NS]], file: {{![0-9]+}})
24+
// IMPORT: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[NS]], entity: [[NS2]], file: {{![0-9]+}}, line: {{[0-9]+}})
25+
// NOIMPORT-NOT: !DIImportedEntity

test/Driver/debug-options.c

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
// RUN: | FileCheck -check-prefix=NOCI %s
7777
// RUN: %clang -### -c %s -g -gcolumn-info -target x86_64-scei-ps4 2>&1 \
7878
// RUN: | FileCheck -check-prefix=CI %s
79+
// RUN: %clang -### -c %s -gsce -target x86_64-unknown-linux 2>&1 \
80+
// RUN: | FileCheck -check-prefix=NOCI %s
7981

8082
// RUN: %clang -### -c -gdwarf-2 %s 2>&1 \
8183
// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s

0 commit comments

Comments
 (0)