Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DebugOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ DEBUGOPT(DebugKeyInstructions, 1, 0, Benign)
DEBUGOPT(DebugColumnInfo, 1, 0, Compatible) ///< Whether or not to use column information
///< in debug info.

/// Whether or not to include call site information in debug info.
DEBUGOPT(DebugCallSiteInfo, 1, 1, Benign)

DEBUGOPT(DebugTypeExtRefs, 1, 0, Compatible) ///< Whether or not debug info should contain
///< external references to a PCH or module.

Expand Down
8 changes: 8 additions & 0 deletions clang/include/clang/Options/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -4823,6 +4823,14 @@ defm column_info : BoolOption<"g", "column-info",
NegFlag<SetFalse, [], [ClangOption, CC1Option]>,
PosFlag<SetTrue>, BothFlags<[], [ClangOption, CLOption, DXCOption]>>,
Group<g_flags_Group>;
defm call_site_info : BoolOption<"g", "call-site-info",
CodeGenOpts<"DebugCallSiteInfo">,
DefaultTrue,
PosFlag<SetTrue, [], [], "Enable">,
NegFlag<SetFalse, [], [], "Disable">,
BothFlags<[], [ClangOption, CC1Option], " call site debug info">>,
Group<g_flags_Group>,
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.}]>;
def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group<g_flags_Group>,
Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
def gsplit_dwarf_EQ : Joined<["-"], "gsplit-dwarf=">, Group<g_flags_Group>,
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6519,7 +6519,8 @@ llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const {
// when there's a possibility of debugging backtraces.
if (CGM.getCodeGenOpts().OptimizationLevel == 0 ||
DebugKind == llvm::codegenoptions::NoDebugInfo ||
DebugKind == llvm::codegenoptions::LocTrackingOnly)
DebugKind == llvm::codegenoptions::LocTrackingOnly ||
!CGM.getCodeGenOpts().DebugCallSiteInfo)
return llvm::DINode::FlagZero;

// Call site-related attributes are available in DWARF v5. Some debuggers,
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4443,6 +4443,10 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
DebuggerTuning != llvm::DebuggerKind::DBX)))
CmdArgs.push_back("-gno-column-info");

if (!Args.hasFlag(options::OPT_gcall_site_info,
options::OPT_gno_call_site_info, true))
CmdArgs.push_back("-gno-call-site-info");

// FIXME: Move backend command line options to the module.
if (Args.hasFlag(options::OPT_gmodules, options::OPT_gno_modules, false)) {
// If -gline-tables-only or -gline-directives-only is the last option it
Expand Down
7 changes: 7 additions & 0 deletions clang/test/DebugInfo/Generic/dbg-info-all-calls-described.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
// RUN: -debug-info-kind=standalone -dwarf-version=4 \
// RUN: | FileCheck %s -check-prefix=NO-ATTR

// Disabled by feature flag (enabled by default)
// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
// RUN: -O1 -disable-llvm-passes \
// RUN: -debug-info-kind=standalone -dwarf-version=5 \
// RUN: -gno-call-site-info \
// RUN: | FileCheck %s -check-prefix=NO-ATTR

// NO-ATTR-NOT: FlagAllCallsDescribed

// HAS-ATTR-DAG: DISubprogram(name: "declaration1", {{.*}}, spFlags: DISPFlagOptimized)
Expand Down
5 changes: 5 additions & 0 deletions clang/test/Driver/debug-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@
// RUN: %clang -### -g -gno-column-info %s 2>&1 \
// RUN: | FileCheck -check-prefix=NOCI %s
//
// RUN: %clang -### -g -gno-call-site-info %s 2>&1 \
// RUN: | FileCheck -check-prefix=NOCALLSITE %s
//
// RUN: %clang -### -g -target x86_64-unknown-unknown %s 2>&1 \
// | FileCheck -check-prefix=CI %s
//
Expand Down Expand Up @@ -426,6 +429,8 @@
//
// NOCI-DAG: "-gno-column-info"
//
// NOCALLSITE: "-gno-call-site-info"
//
// GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj"
// GEXTREFS: "-debug-info-kind={{standalone|constructor}}"
// NOGEXTREFS-NOT: -dwarf-ext-refs
Expand Down