[PATCH] D106582: [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing

Amy Huang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 22 12:23:20 PDT 2021


akhuang created this revision.
akhuang added reviewers: dblaikie, probinson.
akhuang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add an opt out flag for constructor homing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106582

Files:
  clang/docs/UsersManual.rst
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp


Index: clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
+++ clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
@@ -8,6 +8,9 @@
 // RUN:        | FileCheck %s -check-prefix=NO_DEBUG
 // RUN: %clang -cc1 -fuse-ctor-homing -emit-llvm %s -o - \
 // RUN:        | FileCheck %s -check-prefix=NO_DEBUG
+//
+// RUN: %clang -cc1 -debug-info-kind=constructor -fno-use-ctor-homing \
+// RUN:        -emit-llvm %s -o - | FileCheck %s -check-prefix=FULL_DEBUG
 
 // This tests that the -fuse-ctor-homing is only used if limited debug info would have
 // been used otherwise.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1369,9 +1369,6 @@
   if (DebugInfoVal)
     GenerateArg(Args, OPT_debug_info_kind_EQ, *DebugInfoVal, SA);
 
-  if (Opts.DebugInfo == codegenoptions::DebugInfoConstructor)
-    GenerateArg(Args, OPT_fuse_ctor_homing, SA);
-
   for (const auto &Prefix : Opts.DebugPrefixMap)
     GenerateArg(Args, OPT_fdebug_prefix_map_EQ,
                 Prefix.first + "=" + Prefix.second, SA);
@@ -1627,10 +1624,16 @@
   }
 
   // If -fuse-ctor-homing is set and limited debug info is already on, then use
-  // constructor homing.
-  if (Args.getLastArg(OPT_fuse_ctor_homing))
-    if (Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
+  // constructor homing, and vice versa for -fno-use-ctor-homing.
+  if (const Arg *A =
+          Args.getLastArg(OPT_fuse_ctor_homing, OPT_fno_use_ctor_homing)) {
+    if (A->getOption().matches(OPT_fuse_ctor_homing) &&
+        Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
       Opts.setDebugInfo(codegenoptions::DebugInfoConstructor);
+    if (A->getOption().matches(OPT_fno_use_ctor_homing) &&
+        Opts.getDebugInfo() == codegenoptions::DebugInfoConstructor)
+      Opts.setDebugInfo(codegenoptions::LimitedDebugInfo);
+  }
 
   for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
     auto Split = StringRef(Arg).split('=');
Index: clang/docs/UsersManual.rst
===================================================================
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2563,7 +2563,8 @@
    non-trivial, non-aggregate C++ class in the modules that contain a
    definition of one of its constructors. This relies on the additional
    assumption that all classes that are not trivially constructible have a
-   non-trivial constructor that is used somewhere.
+   non-trivial constructor that is used somewhere. The negation,
+   -fno-use-ctor-homing, ensures that constructor homing is not used.
 
    This flag is not enabled by default, and needs to be used with -cc1 or
    -Xclang.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106582.360921.patch
Type: text/x-patch
Size: 2895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210722/1f5e11a6/attachment.bin>


More information about the cfe-commits mailing list