[clang] 5ea2d4f - Avoid conflicts between debug-info and pseudo-probe profiling

Paul Robinson via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 10 07:34:56 PST 2021


Author: Paul Robinson
Date: 2021-02-10T07:09:18-08:00
New Revision: 5ea2d4fa481160c9843b8651df265ce1fbfd9316

URL: https://github.com/llvm/llvm-project/commit/5ea2d4fa481160c9843b8651df265ce1fbfd9316
DIFF: https://github.com/llvm/llvm-project/commit/5ea2d4fa481160c9843b8651df265ce1fbfd9316.diff

LOG: Avoid conflicts between debug-info and pseudo-probe profiling

After 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 existing CodeGen test was using the driver when it should be
running cc1.

Differential Revision: https://reviews.llvm.org/D96354

Added: 
    clang/test/Driver/pseudo-probe.c

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 5df6238b211b..d2a9ea3c9ef8 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3746,6 +3746,12 @@ static void renderDebugOptions(const ToolChain &TC, const Driver &D,
                                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(

diff  --git a/clang/test/CodeGen/pseudo-probe-emit.c b/clang/test/CodeGen/pseudo-probe-emit.c
index fccc8f04844d..5fe1d2384676 100644
--- a/clang/test/CodeGen/pseudo-probe-emit.c
+++ b/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
 

diff  --git a/clang/test/Driver/pseudo-probe.c b/clang/test/Driver/pseudo-probe.c
new file mode 100644
index 000000000000..297992cfd1a1
--- /dev/null
+++ b/clang/test/Driver/pseudo-probe.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### -fpseudo-probe-for-profiling %s 2>&1 | FileCheck %s --check-prefix=YESPROBE
+// RUN: %clang -### -fno-pseudo-probe-for-profiling %s 2>&1 | FileCheck %s --check-prefix=NOPROBE
+// RUN: %clang -### -fpseudo-probe-for-profiling -fdebug-info-for-profiling %s 2>&1 | FileCheck %s --check-prefix=CONFLICT
+
+// YESPROBE: -fpseudo-probe-for-profiling
+// NOPROBE-NOT: -fpseudo-probe-for-profiling
+// CONFLICT: invalid argument


        


More information about the cfe-commits mailing list