[llvm-branch-commits] [llvm] [NFC][ProfileData] Add canonical name tests for CFI and LTO suffixes (PR #240697)
Vitaly Buka via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Nov 9 20:16:46 PST 2026
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/240697
Pre-commit unit test coverage for `FunctionSamples::getCanonicalFnName`
with combined `.cfi`, `.llvm.`, `.part.`, and `.__uniq.` suffixes and
for `InstrProfSymtab::getCanonicalName`.
CC: @benschlueter
Assisted-by: Gemini
>From aebd6f92d406f800748f42bf323b8a4799f5e855 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Mon, 9 Nov 2026 20:16:34 -0800
Subject: [PATCH] [spr] update
Created using spr 2.0.0-beta.2
---
llvm/unittests/ProfileData/InstrProfTest.cpp | 11 +++++++++++
llvm/unittests/ProfileData/SampleProfTest.cpp | 14 +++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index 0c09467169abe3..a7fe530c607648 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -811,6 +811,17 @@ TEST_F(InstrProfTest, test_symtab_lookup_vtable_with_assigned_guid) {
GV);
}
+TEST_F(InstrProfTest, test_symtab_get_canonical_name) {
+ EXPECT_EQ(InstrProfSymtab::getCanonicalName("foo.llvm.1234"), "foo");
+ EXPECT_EQ(InstrProfSymtab::getCanonicalName("foo.part.1"), "foo");
+ EXPECT_EQ(
+ InstrProfSymtab::getCanonicalName("foo.__uniq.123.part.1.llvm.9999"),
+ "foo.__uniq.123");
+ // Coroutine clone suffixes are preserved.
+ EXPECT_EQ(InstrProfSymtab::getCanonicalName("coro.llvm.1234.resume"),
+ "coro.llvm.1234.resume");
+}
+
// callee1 to callee6 are from vtable1 to vtable6 respectively.
static const char callee1[] = "callee1";
static const char callee2[] = "callee2";
diff --git a/llvm/unittests/ProfileData/SampleProfTest.cpp b/llvm/unittests/ProfileData/SampleProfTest.cpp
index a991333ef2bcf3..6dd7b701dec5f0 100644
--- a/llvm/unittests/ProfileData/SampleProfTest.cpp
+++ b/llvm/unittests/ProfileData/SampleProfTest.cpp
@@ -1236,8 +1236,14 @@ TEST(SampleProfCanonicalNameTest, SelectedPolicyDefault) {
EXPECT_EQ("foo.part.1.bar",
FunctionSamples::getCanonicalFnName("foo.part.1.bar"));
- // Combined suffixes in canonical order.
+ // Combined suffixes in canonical order (including split-LTO 32-hex module ID
+ // promotion and CFI .cfi suffix).
EXPECT_EQ("foo", FunctionSamples::getCanonicalFnName("foo.part.1.llvm.456"));
+ EXPECT_EQ("foo", FunctionSamples::getCanonicalFnName("foo.cfi"));
+ EXPECT_EQ("foo", FunctionSamples::getCanonicalFnName(
+ "foo.llvm.13757e0fb71915e385efa4dc9d1e08fd.cfi"));
+ EXPECT_EQ("foo", FunctionSamples::getCanonicalFnName(
+ "foo.part.1.llvm.13757e0fb71915e385efa4dc9d1e08fd.cfi"));
// Suffixes in non-canonical order: .llvm. cannot be stripped if .part.
// follows it, but .part. can be stripped leaving .llvm.
@@ -1260,6 +1266,9 @@ TEST(SampleProfCanonicalNameTest, SelectedPolicyHasUniqSuffix) {
FunctionSamples::getCanonicalFnName("foo.__uniq.123.part.1"));
EXPECT_EQ("foo", FunctionSamples::getCanonicalFnName(
"foo.__uniq.123.part.1.llvm.456"));
+ EXPECT_EQ("foo",
+ FunctionSamples::getCanonicalFnName(
+ "foo.__uniq.123.llvm.13757e0fb71915e385efa4dc9d1e08fd.cfi"));
EXPECT_EQ("foo", FunctionSamples::getCanonicalFnName("foo.llvm.456"));
EXPECT_EQ("foo", FunctionSamples::getCanonicalFnName("foo.part.1"));
}
@@ -1275,6 +1284,9 @@ TEST(SampleProfCanonicalNameTest, SelectedPolicyHasUniqSuffix) {
FunctionSamples::getCanonicalFnName("foo.__uniq.123.part.1"));
EXPECT_EQ("foo.__uniq.123", FunctionSamples::getCanonicalFnName(
"foo.__uniq.123.part.1.llvm.456"));
+ EXPECT_EQ("foo.__uniq.123",
+ FunctionSamples::getCanonicalFnName(
+ "foo.__uniq.123.llvm.13757e0fb71915e385efa4dc9d1e08fd.cfi"));
EXPECT_EQ("foo", FunctionSamples::getCanonicalFnName("foo.llvm.456"));
EXPECT_EQ("foo", FunctionSamples::getCanonicalFnName("foo.part.1"));
}
More information about the llvm-branch-commits
mailing list