[PATCH] D96354: Avoid conflicts between debug-info and pseudo-probe profiling

Paul Robinson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 9 09:50:47 PST 2021


probinson created this revision.
probinson added reviewers: hoy, wmi.
probinson requested review of this revision.
Herald added a project: clang.

After D93264 <https://reviews.llvm.org/D93264>, using both -fdebug-info-for-profiling and -fpseudo-probe-for-profiling will cause the compiler to crash.  Diagnose these conflicting options in the driver.

Also, the driver had a redundant pass-through of the option, and the existing CodeGen test was using the driver when it should be running cc1.  Fixed up those as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96354

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/pseudo-probe-emit.c
  clang/test/Driver/pseudo-probe.c


Index: clang/test/Driver/pseudo-probe.c
===================================================================
--- /dev/null
+++ clang/test/Driver/pseudo-probe.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### -fpseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=YESPROBE
+// RUN: %clang -### -fno-pseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=NOPROBE
+// RUN: %clang -### -fpseudo-probe-for-profiling -fdebug-info-for-profiling 2>&1 | FileCheck %s --check-prefix=CONFLICT
+
+// YESPROBE: -fpseudo-probe-for-profiling
+// NOPROBE-NOT: -fpseudo-probe-for-profiling
+// CONFLICT: invalid argument
Index: clang/test/CodeGen/pseudo-probe-emit.c
===================================================================
--- clang/test/CodeGen/pseudo-probe-emit.c
+++ clang/test/CodeGen/pseudo-probe-emit.c
@@ -1,4 +1,4 @@
-// RUN: %clang -O2  -fexperimental-new-pass-manager -fpseudo-probe-for-profiling -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang_cc1 -O2 -fno-legacy-pass-manager -fpseudo-probe-for-profiling -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
 
 // Check the generation of pseudoprobe intrinsic call
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3746,6 +3746,12 @@
                                ArgStringList &CmdArgs,
                                codegenoptions::DebugInfoKind &DebugInfoKind,
                                DwarfFissionKind &DwarfFission) {
+  // These two forms of profiling info can't be used together.
+  if (const Arg *A1 = Args.getLastArg(options::OPT_fpseudo_probe_for_profiling))
+    if (const Arg *A2 = Args.getLastArg(options::OPT_fdebug_info_for_profiling))
+      D.Diag(diag::err_drv_argument_not_allowed_with)
+          << A1->getAsString(Args) << A2->getAsString(Args);
+
   if (Args.hasFlag(options::OPT_fdebug_info_for_profiling,
                    options::OPT_fno_debug_info_for_profiling, false) &&
       checkDebugInfoOption(
@@ -5727,10 +5733,6 @@
   }
   Args.AddLastArg(CmdArgs, options::OPT_fprofile_remapping_file_EQ);
 
-  if (Args.hasFlag(options::OPT_fpseudo_probe_for_profiling,
-                   options::OPT_fno_pseudo_probe_for_profiling, false))
-    CmdArgs.push_back("-fpseudo-probe-for-profiling");
-
   RenderBuiltinOptions(TC, RawTriple, Args, CmdArgs);
 
   if (!Args.hasFlag(options::OPT_fassume_sane_operator_new,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96354.322428.patch
Type: text/x-patch
Size: 2482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210209/92e88b84/attachment.bin>


More information about the cfe-commits mailing list