[llvm] [CGProfile] Fix unhandled error crash on empty canonical function names (PR #201821)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 05:03:18 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Arseniy Obolenskiy (aobolensk)
<details>
<summary>Changes</summary>
A function whose entire name is a strippable suffix canonicalizes to an empty name, making InstrProfSymtab::create return an error
The current solution with `(void)(bool)` does not really suppress the error which leads to the crash
---
Full diff: https://github.com/llvm/llvm-project/pull/201821.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Instrumentation/CGProfile.cpp (+1-1)
- (added) llvm/test/Instrumentation/cgprofile-empty-canonical-name.ll (+10)
``````````diff
diff --git a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
index 60e7acc77ca29..07bbd2b8fccfd 100644
--- a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
+++ b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
@@ -60,7 +60,7 @@ static bool runCGProfilePass(Module &M, FunctionAnalysisManager &FAM,
Count = SaturatingAdd(Count, NewCount);
};
// Ignore error here. Indirect calls are ignored if this fails.
- (void)(bool)Symtab.create(M, InLTO);
+ consumeError(Symtab.create(M, InLTO));
for (auto &F : M) {
// Avoid extra cost of running passes for BFI when the function doesn't have
// entry count.
diff --git a/llvm/test/Instrumentation/cgprofile-empty-canonical-name.ll b/llvm/test/Instrumentation/cgprofile-empty-canonical-name.ll
new file mode 100644
index 0000000000000..a4fbf1d18ece0
--- /dev/null
+++ b/llvm/test/Instrumentation/cgprofile-empty-canonical-name.ll
@@ -0,0 +1,10 @@
+; RUN: opt < %s -passes='cg-profile' -S | FileCheck %s
+
+; A function whose entire name is a strippable suffix (e.g. ".llvm.123")
+; canonicalizes to an empty name. Building the InstrProfSymtab
+; for such a name returns an error that cg-profile intentionally ignores.
+
+; CHECK: define void @.llvm.123()
+define void @.llvm.123() {
+ ret void
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/201821
More information about the llvm-commits
mailing list