[clang] 3e2ad26 - [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing
Amy Huang via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 22 14:52:45 PDT 2021
Author: Amy Huang
Date: 2021-07-22T14:52:36-07:00
New Revision: 3e2ad26b08a23e786e64e8e47547d25a1b5a7f28
URL: https://github.com/llvm/llvm-project/commit/3e2ad26b08a23e786e64e8e47547d25a1b5a7f28
DIFF: https://github.com/llvm/llvm-project/commit/3e2ad26b08a23e786e64e8e47547d25a1b5a7f28.diff
LOG: [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing
Add an opt out flag for constructor homing.
Differential Revision: https://reviews.llvm.org/D106582
Added:
Modified:
clang/docs/UsersManual.rst
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
Removed:
################################################################################
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index f7f76ed3f3e20..20be01a5f40ac 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2563,7 +2563,8 @@ below. If multiple flags are present, the last one is used.
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.
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 79955f4fa4f08..1815cd4621e87 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4836,6 +4836,8 @@ def mrelocation_model : Separate<["-"], "mrelocation-model">,
def fno_math_builtin : Flag<["-"], "fno-math-builtin">,
HelpText<"Disable implicit builtin knowledge of math functions">,
MarshallingInfoFlag<LangOpts<"NoMathBuiltin">>;
+def fno_use_ctor_homing: Flag<["-"], "fno-use-ctor-homing">,
+ HelpText<"Don't use constructor homing for debug info">;
def fuse_ctor_homing: Flag<["-"], "fuse-ctor-homing">,
HelpText<"Use constructor homing if we are using limited debug info already">;
}
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 2c696b5394538..a8f25fa7c11c4 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1369,9 +1369,6 @@ void CompilerInvocation::GenerateCodeGenArgs(
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 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
}
// 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('=');
diff --git a/clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp b/clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
index 5443fa9ade237..e0832f48c5e21 100644
--- a/clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
+++ b/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.
More information about the cfe-commits
mailing list