[clang] [clang][Darwin] Externalize pseudoprobe and debug info (PR #186873)
Henry Jiang via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 26 14:01:47 PDT 2026
https://github.com/mustartt updated https://github.com/llvm/llvm-project/pull/186873
>From 3f557d87a3b92fb8d5526cf463b9c68448594f81 Mon Sep 17 00:00:00 2001
From: Henry Jiang <henry_jiang2 at apple.com>
Date: Mon, 16 Mar 2026 12:47:54 -0700
Subject: [PATCH 1/2] Externalize pseudo probe and debug info
---
clang/lib/Driver/Driver.cpp | 9 ++++++++-
clang/test/Driver/pseudo-probe.c | 12 ++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index b7f65b7b74401..cc050152f5fa9 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2913,7 +2913,14 @@ 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
diff --git a/clang/test/Driver/pseudo-probe.c b/clang/test/Driver/pseudo-probe.c
index 76c4364e609d0..b0fe271443b1b 100644
--- a/clang/test/Driver/pseudo-probe.c
+++ b/clang/test/Driver/pseudo-probe.c
@@ -11,3 +11,15 @@
// 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 x86_64-apple-darwin10 -### -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
+
+// On Darwin, -fdebug-info-for-profiling should trigger dsymutil
+// RUN: %clang -target x86_64-apple-darwin10 -### -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
>From 7b61802b3cc4965eb31484d70ef18be7902cab9b Mon Sep 17 00:00:00 2001
From: Henry Jiang <henry_jiang2 at apple.com>
Date: Thu, 26 Mar 2026 14:01:26 -0700
Subject: [PATCH 2/2] address review
---
clang/lib/Driver/Driver.cpp | 9 +++++----
clang/test/Driver/pseudo-probe.c | 14 ++++++++++++--
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index cc050152f5fa9..8473fa92fc9ac 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2923,10 +2923,11 @@ void Driver::BuildUniversalActions(Compilation &C, const ToolChain &TC,
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 b0fe271443b1b..66490382295ba 100644
--- a/clang/test/Driver/pseudo-probe.c
+++ b/clang/test/Driver/pseudo-probe.c
@@ -13,13 +13,23 @@
// NONAME-NOT: -funique-internal-linkage-names
// On Darwin, -fpseudo-probe-for-profiling should trigger dsymutil
-// RUN: %clang -target x86_64-apple-darwin10 -### -o foo -fpseudo-probe-for-profiling %s 2>&1 | FileCheck %s --check-prefix=CHECK-DSYMUTIL-PSEUDO-PROBE
+// 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 x86_64-apple-darwin10 -### -o foo -fdebug-info-for-profiling %s 2>&1 | FileCheck %s --check-prefix=CHECK-DSYMUTIL-DEBUG-PROF
+// 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