[llvm] [CtxProf] Emit fatal usage error when flatten-prethinlink runs without assign-guid (PR #194186)
Arda Serdar Pektezol via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 07:00:13 PDT 2026
https://github.com/pektezol updated https://github.com/llvm/llvm-project/pull/194186
>From df9ca2a2e9d2af871883b5ee20226acc62091538 Mon Sep 17 00:00:00 2001
From: Arda Serdar Pektezol <arda at pektezol.dev>
Date: Sun, 26 Apr 2026 01:20:53 +0300
Subject: [PATCH] [CtxProf] Emit fatal usage error when flatten-prethinlink
runs without assign-guid
---
llvm/lib/Analysis/CtxProfAnalysis.cpp | 4 +++-
.../flatten-prethinlink-requires-assign-guid.ll | 7 +++++++
2 files changed, 10 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/Analysis/CtxProfAnalysis/flatten-prethinlink-requires-assign-guid.ll
diff --git a/llvm/lib/Analysis/CtxProfAnalysis.cpp b/llvm/lib/Analysis/CtxProfAnalysis.cpp
index c4abec02e765a..54acb1366f8ae 100644
--- a/llvm/lib/Analysis/CtxProfAnalysis.cpp
+++ b/llvm/lib/Analysis/CtxProfAnalysis.cpp
@@ -441,7 +441,9 @@ GlobalValue::GUID AssignGUIDPass::getGUID(const Function &F) {
return F.getGUID();
}
auto *MD = F.getMetadata(GUIDMetadataName);
- assert(MD && "guid not found for defined function");
+ if (!MD)
+ reportFatalUsageError(
+ "this pass requires the assign-guid module analysis to be available.");
return cast<ConstantInt>(cast<ConstantAsMetadata>(MD->getOperand(0))
->getValue()
->stripPointerCasts())
diff --git a/llvm/test/Analysis/CtxProfAnalysis/flatten-prethinlink-requires-assign-guid.ll b/llvm/test/Analysis/CtxProfAnalysis/flatten-prethinlink-requires-assign-guid.ll
new file mode 100644
index 0000000000000..d3c8c0f259fd5
--- /dev/null
+++ b/llvm/test/Analysis/CtxProfAnalysis/flatten-prethinlink-requires-assign-guid.ll
@@ -0,0 +1,7 @@
+; RUN: not opt -passes='ctx-prof-flatten-prethinlink' %s -disable-output 2>&1 | FileCheck %s
+
+; CHECK: LLVM ERROR: this pass requires the assign-guid module analysis to be available.
+
+define void @test() {
+ ret void
+}
More information about the llvm-commits
mailing list