summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/SampleProfile.cpp
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2014-03-18 12:03:12 +0000
committerDiego Novillo <dnovillo@google.com>2014-03-18 12:03:12 +0000
commit213bb0024564cbd0119452bd1c21b273857b9531 (patch)
tree039518fa85cf3aad1e8e9e433245d79861d09d3b /llvm/lib/Transforms/Scalar/SampleProfile.cpp
parent9e5341d64ad32d3d4eec7c892a4f601039dd6c8f (diff)
downloadbcm5719-llvm-213bb0024564cbd0119452bd1c21b273857b9531.tar.gz
bcm5719-llvm-213bb0024564cbd0119452bd1c21b273857b9531.zip
Tolerate unmangled names in sample profiles.
Summary: The compiler does not always generate linkage names. If a function has been inlined and its body elided, its linkage name may not be generated. When the binary executes, the profiler will use its unmangled name when attributing samples. This results in unmangled names in the input profile. We are currently failing hard when this happens. However, in this case all that happens is that we fail to attribute samples to the inlined function. While this means fewer optimization opportunities, it should not cause a compilation failure. This patch accepts all valid function names, regardless of whether they were mangled or not. Reviewers: chandlerc CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3087 llvm-svn: 204142
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SampleProfile.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/SampleProfile.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/SampleProfile.cpp b/llvm/lib/Transforms/Scalar/SampleProfile.cpp
index 221aa0a1861..20d6daab24b 100644
--- a/llvm/lib/Transforms/Scalar/SampleProfile.cpp
+++ b/llvm/lib/Transforms/Scalar/SampleProfile.cpp
@@ -251,7 +251,7 @@ public:
return Profiles[F.getName()];
}
- /// \brief Report a parse error message and stop compilation.
+ /// \brief Report a parse error message.
void reportParseError(int64_t LineNumber, Twine Msg) const {
DiagnosticInfoSampleProfile Diag(Filename.data(), LineNumber, Msg);
M.getContext().diagnose(Diag);
@@ -462,15 +462,21 @@ bool SampleModuleProfile::loadText() {
// Read the profile of each function. Since each function may be
// mentioned more than once, and we are collecting flat profiles,
// accumulate samples as we parse them.
- Regex HeadRE("^([^:]+):([0-9]+):([0-9]+)$");
+ Regex HeadRE("^([^0-9].*):([0-9]+):([0-9]+)$");
Regex LineSample("^([0-9]+)\\.?([0-9]+)?: ([0-9]+)(.*)$");
while (!LineIt.is_at_eof()) {
- // Read the header of each function. The function header should
- // have this format:
+ // Read the header of each function.
//
- // function_name:total_samples:total_head_samples
+ // Note that for function identifiers we are actually expecting
+ // mangled names, but we may not always get them. This happens when
+ // the compiler decides not to emit the function (e.g., it was inlined
+ // and removed). In this case, the binary will not have the linkage
+ // name for the function, so the profiler will emit the function's
+ // unmangled name, which may contain characters like ':' and '>' in its
+ // name (member functions, templates, etc).
//
- // See above for an explanation of each field.
+ // The only requirement we place on the identifier, then, is that it
+ // should not begin with a number.
SmallVector<StringRef, 3> Matches;
if (!HeadRE.match(*LineIt, &Matches)) {
reportParseError(LineIt.line_number(),
OpenPOWER on IntegriCloud