projects
/
oota-llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c5273dd
)
[PGO]: reserve space for string to avoid excessive memory realloc/copy (non linear)
author
Xinliang David Li
<davidxl@google.com>
Mon, 4 Jan 2016 20:26:05 +0000
(20:26 +0000)
committer
Xinliang David Li
<davidxl@google.com>
Mon, 4 Jan 2016 20:26:05 +0000
(20:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256776
91177308
-0d34-0410-b5e6-
96231b3b80d8
lib/ProfileData/InstrProf.cpp
patch
|
blob
|
history
diff --git
a/lib/ProfileData/InstrProf.cpp
b/lib/ProfileData/InstrProf.cpp
index 3c752699a2750e7b7f3508d7c387abe0f21e71e3..dd5f04bee324b72d57bdd2455055d48f7cb5b47f 100644
(file)
--- a/
lib/ProfileData/InstrProf.cpp
+++ b/
lib/ProfileData/InstrProf.cpp
@@
-168,6
+168,12
@@
int collectPGOFuncNameStrings(const std::vector<std::string> &NameStrs,
bool doCompression, std::string &Result) {
uint8_t Header[16], *P = Header;
std::string UncompressedNameStrings;
+ size_t UncompressedStringLen = 0;
+
+ for (auto NameStr : NameStrs)
+ UncompressedStringLen += (NameStr.length() + 1);
+
+ UncompressedNameStrings.reserve(UncompressedStringLen + 1);
for (auto NameStr : NameStrs) {
UncompressedNameStrings += NameStr;