[llvm] 80855eb - [SampleFDO] Extend the function base name max size (#135863)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 16 13:11:58 PDT 2025
Author: Lei Wang
Date: 2025-04-16T13:11:55-07:00
New Revision: 80855eb6f11b06c194939eb305761eb2b62822f9
URL: https://github.com/llvm/llvm-project/commit/80855eb6f11b06c194939eb305761eb2b62822f9
DIFF: https://github.com/llvm/llvm-project/commit/80855eb6f11b06c194939eb305761eb2b62822f9.diff
LOG: [SampleFDO] Extend the function base name max size (#135863)
The function base name could be way long which overflows and leads to a
crash. Update to extend the max size.
Also changed to use heap allocation( `std::vector<char>` ) to avoid
stack overflow.
Added:
Modified:
llvm/lib/Transforms/IPO/SampleProfileMatcher.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/SampleProfileMatcher.cpp b/llvm/lib/Transforms/IPO/SampleProfileMatcher.cpp
index d6d1b7c51d4c0..963c321772d6e 100644
--- a/llvm/lib/Transforms/IPO/SampleProfileMatcher.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfileMatcher.cpp
@@ -737,11 +737,11 @@ bool SampleProfileMatcher::functionMatchesProfileHelper(
auto FunctionName = FName.str();
if (Demangler.partialDemangle(FunctionName.c_str()))
return std::string();
- constexpr size_t MaxBaseNameSize = 4096;
- char BaseNameBuf[MaxBaseNameSize] = {};
+ constexpr size_t MaxBaseNameSize = 65536;
+ std::vector<char> BaseNameBuf(MaxBaseNameSize, 0);
size_t BaseNameSize = MaxBaseNameSize;
char *BaseNamePtr =
- Demangler.getFunctionBaseName(BaseNameBuf, &BaseNameSize);
+ Demangler.getFunctionBaseName(BaseNameBuf.data(), &BaseNameSize);
return (BaseNamePtr && BaseNameSize)
? std::string(BaseNamePtr, BaseNameSize)
: std::string();
More information about the llvm-commits
mailing list