[clang] 5c1ddab - [clang][Darwin] Externalize pseudoprobe and debug info (#186873)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 27 09:48:55 PDT 2026
Author: Henry Jiang
Date: 2026-03-27T09:48:50-07:00
New Revision: 5c1ddab1d8d2daa2b23f7c9e8c69e11b27e4f2c7
URL: https://github.com/llvm/llvm-project/commit/5c1ddab1d8d2daa2b23f7c9e8c69e11b27e4f2c7
DIFF: https://github.com/llvm/llvm-project/commit/5c1ddab1d8d2daa2b23f7c9e8c69e11b27e4f2c7.diff
LOG: [clang][Darwin] Externalize pseudoprobe and debug info (#186873)
Added:
Modified:
clang/lib/Driver/Driver.cpp
clang/test/Driver/pseudo-probe.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index ba5e50381c9f8..925754799817a 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2932,13 +2932,21 @@ void Driver::BuildUniversalActions(Compilation &C, const ToolChain &TC,
Arg *A = Args.getLastArg(options::OPT_g_Group);
bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
!A->getOption().matches(options::OPT_gstabs);
- if ((enablesDebugInfo || willEmitRemarks(Args)) &&
+ bool enablesPseudoProbe =
+ Args.hasFlag(options::OPT_fpseudo_probe_for_profiling,
+ options::OPT_fno_pseudo_probe_for_profiling, false);
+ bool enablesDebugInfoForProfiling =
+ Args.hasFlag(options::OPT_fdebug_info_for_profiling,
+ options::OPT_fno_debug_info_for_profiling, false);
+ if ((enablesDebugInfo || willEmitRemarks(Args) || enablesPseudoProbe ||
+ enablesDebugInfoForProfiling) &&
ContainsCompileOrAssembleAction(Actions.back())) {
- // Add a 'dsymutil' step if necessary, when debug info is enabled and we
- // have a compile input. We need to run 'dsymutil' ourselves in such cases
- // because the debug info will refer to a temporary object file which
- // will be removed at the end of the compilation process.
+ // Add a 'dsymutil' step if necessary, when debug info, remarks, or
+ // pseudo probes are enabled and we have a compile input. We need to run
+ // 'dsymutil' ourselves in such cases because the debug info will refer
+ // to a temporary object file which will be removed at the end of the
+ // compilation process.
if (Act->getType() == types::TY_Image) {
ActionList Inputs;
Inputs.push_back(Actions.back());
diff --git a/clang/test/Driver/pseudo-probe.c b/clang/test/Driver/pseudo-probe.c
index 76c4364e609d0..66490382295ba 100644
--- a/clang/test/Driver/pseudo-probe.c
+++ b/clang/test/Driver/pseudo-probe.c
@@ -11,3 +11,25 @@
// NOPROBE-NOT: -funique-internal-linkage-names
// NONAME: -fpseudo-probe-for-profiling
// NONAME-NOT: -funique-internal-linkage-names
+
+// On Darwin, -fpseudo-probe-for-profiling should trigger dsymutil
+// RUN: %clang -target arm64-apple-darwin -### -o foo -fpseudo-probe-for-profiling %s 2>&1 | FileCheck %s --check-prefix=CHECK-DSYMUTIL-PSEUDO-PROBE
+// CHECK-DSYMUTIL-PSEUDO-PROBE: "-cc1"
+// CHECK-DSYMUTIL-PSEUDO-PROBE: ld
+// CHECK-DSYMUTIL-PSEUDO-PROBE: dsymutil
+
+// RUN: %clang -target arm64-apple-darwin -### -o foo -fno-pseudo-probe-for-profiling %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-DSYMUTIL-PSEUDO-PROBE
+// CHECK-NO-DSYMUTIL-PSEUDO-PROBE: "-cc1"
+// CHECK-NO-DSYMUTIL-PSEUDO-PROBE: ld
+// CHECK-NO-DSYMUTIL-PSEUDO-PROBE-NOT: dsymutil
+
+// On Darwin, -fdebug-info-for-profiling should trigger dsymutil
+// RUN: %clang -target arm64-apple-darwin -### -o foo -fdebug-info-for-profiling %s 2>&1 | FileCheck %s --check-prefix=CHECK-DSYMUTIL-DEBUG-PROF
+// CHECK-DSYMUTIL-DEBUG-PROF: "-cc1"
+// CHECK-DSYMUTIL-DEBUG-PROF: ld
+// CHECK-DSYMUTIL-DEBUG-PROF: dsymutil
+
+// RUN: %clang -target arm64-apple-darwin -### -o foo -fno-debug-info-for-profiling %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-DSYMUTIL-DEBUG-PROF
+// CHECK-NO-DSYMUTIL-DEBUG-PROF: "-cc1"
+// CHECK-NO-DSYMUTIL-DEBUG-PROF: ld
+// CHECK-NO-DSYMUTIL-DEBUG-PROF-NOT: dsymutil
More information about the cfe-commits
mailing list