https://github.com/HaohaiWen created https://github.com/llvm/llvm-project/pull/174927
Do not verify GUID existence in pseudo probe desc by default since it
generates false positive warnings with ThinLTO.
User can use -pseudo-probe-verify-guid-existence-in-desc to verify it
explicitly.
>From 5115fbf3c91faada255114ed35be352bb1f08726 Mon Sep 17 00:00:00 2001
From: Haohai Wen <haohai.wen at intel.com>
Date: Thu, 8 Jan 2026 16:44:50 +0800
Subject: [PATCH] [PseudoProbe] Add switch to control illegal guid warnings
Do not verify GUID existence in pseudo probe desc since it generates
false positive warnings with ThinLTO.
User can use -pseudo-probe-verify-guid-existence-in-desc to verify it
explicitly.
---
.../CodeGen/AsmPrinter/PseudoProbePrinter.cpp | 18 +++++++++++++++---
.../CodeGen/X86/pseudo-probe-desc-check.ll | 4 ++--
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
index 4bf3bdfb5adfd..a945c961d8faa 100644
--- a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
@@ -25,6 +25,16 @@
using namespace llvm;
+#ifndef NDEBUG
+// Deprecated with ThinLTO. For some modules compiled with ThinLTO, certain
+// pseudo probe descriptors may not be imported, resulting in false positive
+// warning.
+static cl::opt<bool> VerifyGuidExistence(
+ "pseudo-probe-verify-guid-existence-in-desc",
+ cl::desc("Verify whether GUID exists in the .pseudo_probe_desc."),
+ cl::Hidden, cl::init(false));
+#endif
+
void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, uint64_t Index,
uint64_t Type, uint64_t Attr,
const DILocation *DebugLoc) {
@@ -41,7 +51,8 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, uint64_t Index,
if (!CallerGuid)
CallerGuid = Function::getGUIDAssumingExternalLinkage(Name);
#ifndef NDEBUG
- verifyGuidExistenceInDesc(CallerGuid, Name);
+ if (VerifyGuidExistence)
+ verifyGuidExistenceInDesc(CallerGuid, Name);
#endif
uint64_t CallerProbeId = PseudoProbeDwarfDiscriminator::extractProbeIndex(
InlinedAt->getDiscriminator());
@@ -60,8 +71,9 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, uint64_t Index,
Asm->OutStreamer->emitPseudoProbe(Guid, Index, Type, Attr, Discriminator,
InlineStack, Asm->CurrentFnSym);
#ifndef NDEBUG
- verifyGuidExistenceInDesc(
- Guid, DebugLoc ? DebugLoc->getSubprogramLinkageName() : "");
+ if (VerifyGuidExistence)
+ verifyGuidExistenceInDesc(
+ Guid, DebugLoc ? DebugLoc->getSubprogramLinkageName() : "");
#endif
}
diff --git a/llvm/test/CodeGen/X86/pseudo-probe-desc-check.ll b/llvm/test/CodeGen/X86/pseudo-probe-desc-check.ll
index 841061c37e4ed..0c2bdfe9adcb1 100644
--- a/llvm/test/CodeGen/X86/pseudo-probe-desc-check.ll
+++ b/llvm/test/CodeGen/X86/pseudo-probe-desc-check.ll
@@ -1,6 +1,6 @@
; REQUIRES: asserts
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s -o /dev/null 2>&1 | FileCheck %s
-; RUN: llc -mtriple=x86_64-unknown-windows-msvc < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -pseudo-probe-verify-guid-existence-in-desc < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-windows-msvc -pseudo-probe-verify-guid-existence-in-desc < %s -o /dev/null 2>&1 | FileCheck %s
; CHECK: warning: Guid:8314849053352128226 Name:inlinee does not exist in pseudo probe desc
; CHECK: warning: Guid:6492337042787843907 Name:extract2 does not exist in pseudo probe desc