[PATCH] D15243: [PGO]: Do not use invalid Char in instrumentation variable names
David Li via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 10 22:16:05 PST 2015
davidxl updated this revision to Diff 42498.
davidxl added a comment.
Update the patch with a test case.
http://reviews.llvm.org/D15243
Files:
include/llvm/ProfileData/InstrProf.h
lib/ProfileData/InstrProf.cpp
test/tools/llvm-profdata/Inputs/compat.profdata.v4
test/tools/llvm-profdata/compat.proftext
Index: test/tools/llvm-profdata/compat.proftext
===================================================================
--- test/tools/llvm-profdata/compat.proftext
+++ test/tools/llvm-profdata/compat.proftext
@@ -65,3 +65,10 @@
# FORMATV2-NEXT: Maximum internal block count: 1000000
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v4 -all-functions --counts | FileCheck %s -check-prefix=FORMATV4
+# FORMATV4: instrprof.c__foo_static:
+# FORMATV4-NEXT: Hash: 0x000000000000000a
+# FORMATV4-NEXT: Counters: 2
+# FORMATV4-NEXT: Function count: 500500
+# FORMATV4-NEXT: Block counts: [180100]
+
Index: lib/ProfileData/InstrProf.cpp
===================================================================
--- lib/ProfileData/InstrProf.cpp
+++ lib/ProfileData/InstrProf.cpp
@@ -74,25 +74,26 @@
std::string getPGOFuncName(StringRef RawFuncName,
GlobalValue::LinkageTypes Linkage,
- StringRef FileName,
- uint64_t Version LLVM_ATTRIBUTE_UNUSED) {
+ StringRef FileName, uint64_t Version) {
// Function names may be prefixed with a binary '1' to indicate
// that the backend should not modify the symbols due to any platform
// naming convention. Do not include that '1' in the PGO profile name.
if (RawFuncName[0] == '\1')
RawFuncName = RawFuncName.substr(1);
+ const char *Unknown = (Version <= 3 ? "<unknown>:" : "__unknown__");
+ const char *Sep = (Version <= 3 ? ":" : "__");
std::string FuncName = RawFuncName;
if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
// For local symbols, prepend the main file name to distinguish them.
// Do not include the full path in the file name since there's no guarantee
// that it will stay the same, e.g., if the files are checked out from
// version control in different locations.
if (FileName.empty())
- FuncName = FuncName.insert(0, "<unknown>:");
+ FuncName = FuncName.insert(0, Unknown);
else
- FuncName = FuncName.insert(0, FileName.str() + ":");
+ FuncName = FuncName.insert(0, FileName.str() + Sep);
}
return FuncName;
}
Index: include/llvm/ProfileData/InstrProf.h
===================================================================
--- include/llvm/ProfileData/InstrProf.h
+++ include/llvm/ProfileData/InstrProf.h
@@ -30,7 +30,7 @@
#include <system_error>
#include <vector>
-#define INSTR_PROF_INDEX_VERSION 3
+#define INSTR_PROF_INDEX_VERSION 4
namespace llvm {
class Function;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15243.42498.patch
Type: text/x-patch
Size: 2542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151211/14a251b3/attachment.bin>
More information about the llvm-commits
mailing list