Skip to content

Commit 80855eb

Browse files
authored
[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.
1 parent 598ec8c commit 80855eb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Transforms/IPO/SampleProfileMatcher.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,11 +737,11 @@ bool SampleProfileMatcher::functionMatchesProfileHelper(
737737
auto FunctionName = FName.str();
738738
if (Demangler.partialDemangle(FunctionName.c_str()))
739739
return std::string();
740-
constexpr size_t MaxBaseNameSize = 4096;
741-
char BaseNameBuf[MaxBaseNameSize] = {};
740+
constexpr size_t MaxBaseNameSize = 65536;
741+
std::vector<char> BaseNameBuf(MaxBaseNameSize, 0);
742742
size_t BaseNameSize = MaxBaseNameSize;
743743
char *BaseNamePtr =
744-
Demangler.getFunctionBaseName(BaseNameBuf, &BaseNameSize);
744+
Demangler.getFunctionBaseName(BaseNameBuf.data(), &BaseNameSize);
745745
return (BaseNamePtr && BaseNameSize)
746746
? std::string(BaseNamePtr, BaseNameSize)
747747
: std::string();

0 commit comments

Comments
 (0)