Skip to content

Commit 70f373d

Browse files
jryans丹治秀樹
authored andcommitted
[clang][DebugInfo] Add call site debug info flag (llvm#169574)
This adds a default enabled flag to control attachment of call site debug info. `-gno-call-site-info` can be used to disable this feature when needed. This should help those concerned about debug info size in llvm#168851.
1 parent cd6f108 commit 70f373d

File tree

6 files changed

+29
-1
lines changed

6 files changed

+29
-1
lines changed

clang/include/clang/Basic/DebugOptions.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ DEBUGOPT(DebugKeyInstructions, 1, 0, Benign)
6565
DEBUGOPT(DebugColumnInfo, 1, 0, Compatible) ///< Whether or not to use column information
6666
///< in debug info.
6767

68+
/// Whether or not to include call site information in debug info.
69+
DEBUGOPT(DebugCallSiteInfo, 1, 1, Benign)
70+
6871
DEBUGOPT(DebugTypeExtRefs, 1, 0, Compatible) ///< Whether or not debug info should contain
6972
///< external references to a PCH or module.
7073

clang/include/clang/Options/Options.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4832,6 +4832,14 @@ defm column_info : BoolOption<"g", "column-info",
48324832
NegFlag<SetFalse, [], [ClangOption, CC1Option]>,
48334833
PosFlag<SetTrue>, BothFlags<[], [ClangOption, CLOption, DXCOption]>>,
48344834
Group<g_flags_Group>;
4835+
defm call_site_info : BoolOption<"g", "call-site-info",
4836+
CodeGenOpts<"DebugCallSiteInfo">,
4837+
DefaultTrue,
4838+
PosFlag<SetTrue, [], [], "Enable">,
4839+
NegFlag<SetFalse, [], [], "Disable">,
4840+
BothFlags<[], [ClangOption, CC1Option], " call site debug info">>,
4841+
Group<g_flags_Group>,
4842+
DocBrief<[{Call site debug info enables various debugger features including detecting tail calls for display in backtraces and displaying some source variable values that reference the call entry value.}]>;
48354843
def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group<g_flags_Group>,
48364844
Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
48374845
def gsplit_dwarf_EQ : Joined<["-"], "gsplit-dwarf=">, Group<g_flags_Group>,

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6519,7 +6519,8 @@ llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const {
65196519
// when there's a possibility of debugging backtraces.
65206520
if (CGM.getCodeGenOpts().OptimizationLevel == 0 ||
65216521
DebugKind == llvm::codegenoptions::NoDebugInfo ||
6522-
DebugKind == llvm::codegenoptions::LocTrackingOnly)
6522+
DebugKind == llvm::codegenoptions::LocTrackingOnly ||
6523+
!CGM.getCodeGenOpts().DebugCallSiteInfo)
65236524
return llvm::DINode::FlagZero;
65246525

65256526
// Call site-related attributes are available in DWARF v5. Some debuggers,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4442,6 +4442,10 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
44424442
DebuggerTuning != llvm::DebuggerKind::DBX)))
44434443
CmdArgs.push_back("-gno-column-info");
44444444

4445+
if (!Args.hasFlag(options::OPT_gcall_site_info,
4446+
options::OPT_gno_call_site_info, true))
4447+
CmdArgs.push_back("-gno-call-site-info");
4448+
44454449
// FIXME: Move backend command line options to the module.
44464450
if (Args.hasFlag(options::OPT_gmodules, options::OPT_gno_modules, false)) {
44474451
// If -gline-tables-only or -gline-directives-only is the last option it

clang/test/DebugInfo/Generic/dbg-info-all-calls-described.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@
5959
// RUN: -debug-info-kind=standalone -dwarf-version=4 \
6060
// RUN: | FileCheck %s -check-prefix=NO-ATTR
6161

62+
// Disabled by feature flag (enabled by default)
63+
// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
64+
// RUN: -O1 -disable-llvm-passes \
65+
// RUN: -debug-info-kind=standalone -dwarf-version=5 \
66+
// RUN: -gno-call-site-info \
67+
// RUN: | FileCheck %s -check-prefix=NO-ATTR
68+
6269
// NO-ATTR-NOT: FlagAllCallsDescribed
6370

6471
// HAS-ATTR-DAG: DISubprogram(name: "declaration1", {{.*}}, spFlags: DISPFlagOptimized)

clang/test/Driver/debug-options.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@
297297
// RUN: %clang -### -g -gno-column-info %s 2>&1 \
298298
// RUN: | FileCheck -check-prefix=NOCI %s
299299
//
300+
// RUN: %clang -### -g -gno-call-site-info %s 2>&1 \
301+
// RUN: | FileCheck -check-prefix=NOCALLSITE %s
302+
//
300303
// RUN: %clang -### -g -target x86_64-unknown-unknown %s 2>&1 \
301304
// | FileCheck -check-prefix=CI %s
302305
//
@@ -426,6 +429,8 @@
426429
//
427430
// NOCI-DAG: "-gno-column-info"
428431
//
432+
// NOCALLSITE: "-gno-call-site-info"
433+
//
429434
// GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj"
430435
// GEXTREFS: "-debug-info-kind={{standalone|constructor}}"
431436
// NOGEXTREFS-NOT: -dwarf-ext-refs

0 commit comments

Comments
 (0)