llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-debuginfo

Author: J. Ryan Stinnett (jryans)

<details>
<summary>Changes</summary>

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 
https://github.com/llvm/llvm-project/issues/168851.

---
Full diff: https://github.com/llvm/llvm-project/pull/169574.diff


6 Files Affected:

- (modified) clang/include/clang/Basic/DebugOptions.def (+3) 
- (modified) clang/include/clang/Options/Options.td (+8) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+2-1) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+4) 
- (modified) clang/test/DebugInfo/Generic/dbg-info-all-calls-described.c (+7) 
- (modified) clang/test/Driver/debug-options.c (+5) 


``````````diff
diff --git a/clang/include/clang/Basic/DebugOptions.def 
b/clang/include/clang/Basic/DebugOptions.def
index ea3636ffa1af1..34f5a313947a4 100644
--- a/clang/include/clang/Basic/DebugOptions.def
+++ b/clang/include/clang/Basic/DebugOptions.def
@@ -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.
 
diff --git a/clang/include/clang/Options/Options.td 
b/clang/include/clang/Options/Options.td
index 34a6651d2445c..f06bf03f7d133 100644
--- a/clang/include/clang/Options/Options.td
+++ b/clang/include/clang/Options/Options.td
@@ -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>,
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 4eb99cc342275..c50f372c1f331 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -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,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 2f0aec3ec3c37..ea82730a5b78e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -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
diff --git a/clang/test/DebugInfo/Generic/dbg-info-all-calls-described.c 
b/clang/test/DebugInfo/Generic/dbg-info-all-calls-described.c
index 3ca3aaa0b70f4..0ba4767c8ddda 100644
--- a/clang/test/DebugInfo/Generic/dbg-info-all-calls-described.c
+++ b/clang/test/DebugInfo/Generic/dbg-info-all-calls-described.c
@@ -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)
diff --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index 45ac450ac8faa..27e2728f15948 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -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
 //
@@ -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

``````````

</details>


https://github.com/llvm/llvm-project/pull/169574
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to