[llvm-branch-commits] [llvm] [ProfileData] Handle .cfi suffixes in InstrProf and Coro SampleProf (PR #240698)
Kazu Hirata via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Nov 9 21:15:42 PST 2026
================
@@ -814,12 +814,79 @@ TEST_F(InstrProfTest, test_symtab_lookup_vtable_with_assigned_guid) {
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.cfi"), "foo");
EXPECT_EQ(
InstrProfSymtab::getCanonicalName("foo.__uniq.123.part.1.llvm.9999"),
"foo.__uniq.123");
- // Coroutine clone suffixes are preserved.
+ EXPECT_EQ(InstrProfSymtab::getCanonicalName(
+ "foo.__uniq.123.llvm.13757e0fb71915e385efa4dc9d1e08fd.cfi"),
+ "foo.__uniq.123");
+ EXPECT_EQ(
+ InstrProfSymtab::getCanonicalName("foo.__uniq.123.part.1.llvm.9999.cfi"),
+ "foo.__uniq.123");
+ // Coroutine clone and non-canonical jump-table suffixes are preserved.
EXPECT_EQ(InstrProfSymtab::getCanonicalName("coro.llvm.1234.resume"),
"coro.llvm.1234.resume");
+ EXPECT_EQ(InstrProfSymtab::getCanonicalName("foo.cfi_jt"), "foo.cfi_jt");
+}
+
+// Verify that non-naked definitions take precedence over CFI jump-table
+// declarations and naked jump-table stubs in InstrProfSymtab regardless of
+// symbol order in the module, while standalone declarations remain reachable.
+TEST_F(InstrProfTest, test_symtab_cfi_def_precedence) {
+ LLVMContext Ctx;
+ auto M = std::make_unique<Module>("MyModule.cpp", Ctx);
+ auto *FTy = FunctionType::get(Type::getVoidTy(Ctx), /*isVarArg=*/false);
+
+ // Place jump-table declaration BEFORE the .cfi definition in module order.
+ auto *JTDecl = Function::Create(
+ FTy, Function::ExternalLinkage,
+ "InternalLambda.__uniq.42.llvm.13757e0fb71915e385efa4dc9d1e08fd",
+ M.get());
+ (void)JTDecl;
----------------
kazutakahirata wrote:
Nit: Could we drop `JTDecl` and call `Function::Create` directly, or use `[[maybe_unused]]` instead of `(void)JTDecl;` if you prefer keeping the name?
```suggestion
Function::Create(
FTy, Function::ExternalLinkage,
"InternalLambda.__uniq.42.llvm.13757e0fb71915e385efa4dc9d1e08fd",
M.get());
```
https://github.com/llvm/llvm-project/pull/240698
More information about the llvm-branch-commits
mailing list