[PATCH] D152017: [DebugInfo] Add flag to only emit referenced member functions
David Blaikie via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 2 11:30:26 PDT 2023
dblaikie updated this revision to Diff 527920.
dblaikie added a comment.
Updating commit message with extra details
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152017/new/
https://reviews.llvm.org/D152017
Files:
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGenCXX/debug-info-incomplete-types.cpp
clang/test/Driver/debug-options.c
Index: clang/test/Driver/debug-options.c
===================================================================
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -259,6 +259,9 @@
// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s
// RUN: %clang -### -c -fdebug-ranges-base-address -fno-debug-ranges-base-address %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s
//
+// RUN: %clang -### -c -gincomplete-types %s 2>&1 | FileCheck -check-prefix=INCTYPES %s
+// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NOINCTYPES %s
+//
// RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
// RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
//
@@ -398,6 +401,9 @@
// RNGBSE: -fdebug-ranges-base-address
// NORNGBSE-NOT: -fdebug-ranges-base-address
//
+// INCTYPES: -gincomplete-types
+// NOINCTYPES-NOT: -gincomplete-types
+//
// GARANGE-DAG: -generate-arange-section
//
// FDTS: "-mllvm" "-generate-type-units"
Index: clang/test/CodeGenCXX/debug-info-incomplete-types.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-incomplete-types.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -gincomplete-types %s -emit-llvm -o - | FileCheck %s
+
+struct t1 {
+ void f1();
+ void f2();
+};
+
+void t1::f1() { }
+
+// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1"
+// CHECK-SAME: elements: [[ELEMENTS:![0-9]+]]
+// CHECK: [[ELEMENTS]] = !{}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4308,6 +4308,12 @@
DebuggerTuning != llvm::DebuggerKind::DBX)))
CmdArgs.push_back("-gno-column-info");
+ if (const Arg *A = Args.getLastArg(options::OPT_gincomplete_types))
+ (void)checkDebugInfoOption(A, Args, D, TC);
+ if (Args.hasFlag(options::OPT_gincomplete_types,
+ options::OPT_gno_incomplete_types, false))
+ CmdArgs.push_back("-gincomplete-types");
+
// 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
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2740,7 +2740,7 @@
// Collect data fields (including static variables and any initializers).
CollectRecordFields(RD, DefUnit, EltTys, FwdDecl);
- if (CXXDecl)
+ if (CXXDecl && !CGM.getCodeGenOpts().DebugIncompleteTypes)
CollectCXXMemberFunctions(CXXDecl, DefUnit, EltTys, FwdDecl);
LexicalBlockStack.pop_back();
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3346,6 +3346,10 @@
CodeGenOpts<"DebugStrictDwarf">, DefaultFalse,
PosFlag<SetTrue, [CC1Option]>, NegFlag<SetFalse>, BothFlags<[CoreOption]>>,
Group<g_flags_Group>;
+defm incomplete_types : BoolOption<"g", "incomplete-types",
+ CodeGenOpts<"DebugIncompleteTypes">, DefaultFalse,
+ PosFlag<SetTrue, [CC1Option]>, NegFlag<SetFalse>, BothFlags<[CoreOption]>>,
+ Group<g_flags_Group>;
defm column_info : BoolOption<"g", "column-info",
CodeGenOpts<"DebugColumnInfo">, DefaultTrue,
NegFlag<SetFalse, [CC1Option]>, PosFlag<SetTrue>, BothFlags<[CoreOption]>>,
Index: clang/include/clang/Basic/CodeGenOptions.def
===================================================================
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -333,6 +333,8 @@
VALUE_CODEGENOPT(WarnStackSize , 32, UINT_MAX) ///< Set via -fwarn-stack-size.
CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used
CODEGENOPT(DebugStrictDwarf, 1, 1) ///< Whether or not to use strict DWARF info.
+/// Whether or not to include all members in a type in debug info.
+CODEGENOPT(DebugIncompleteTypes, 1, 0)
/// Control the Assignment Tracking debug info feature.
ENUM_CODEGENOPT(AssignmentTrackingMode, AssignmentTrackingOpts, 2, AssignmentTrackingOpts::Disabled)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152017.527920.patch
Type: text/x-patch
Size: 4433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230602/46226b5c/attachment-0001.bin>
More information about the cfe-commits
mailing list