[PATCH] Tolerate unmangled names in sample profiles.

Diego Novillo dnovillo at google.com
Mon Mar 17 12:57:05 PDT 2014


  Remove warning message. Silently accept any name that does not start
  with a number.

Hi chandlerc, echristo,

http://llvm-reviews.chandlerc.com/D3087

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D3087?vs=7849&id=7895#toc

Files:
  lib/Transforms/Scalar/SampleProfile.cpp
  test/Transforms/SampleProfile/Inputs/bad_fn_header.prof
  test/Transforms/SampleProfile/Inputs/bad_mangle.prof
  test/Transforms/SampleProfile/syntax.ll

Index: lib/Transforms/Scalar/SampleProfile.cpp
===================================================================
--- lib/Transforms/Scalar/SampleProfile.cpp
+++ lib/Transforms/Scalar/SampleProfile.cpp
@@ -251,12 +251,19 @@
     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);
   }
 
+  /// \brief Report a parse warning message.
+  void reportParseWarning(int64_t LineNumber, Twine Msg) const {
+    DiagnosticInfoSampleProfile Diag(Filename.data(), LineNumber, Msg,
+                                     DS_Warning);
+    M.getContext().diagnose(Diag);
+  }
+
 protected:
   /// \brief Map every function to its associated profile.
   ///
@@ -462,7 +469,7 @@
   // 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
Index: test/Transforms/SampleProfile/Inputs/bad_fn_header.prof
===================================================================
--- test/Transforms/SampleProfile/Inputs/bad_fn_header.prof
+++ test/Transforms/SampleProfile/Inputs/bad_fn_header.prof
@@ -1,3 +1,3 @@
-empty:100:BAD
+3empty:100:BAD
 0: 0
 1: 100
Index: test/Transforms/SampleProfile/Inputs/bad_mangle.prof
===================================================================
--- /dev/null
+++ test/Transforms/SampleProfile/Inputs/bad_mangle.prof
@@ -0,0 +1,3 @@
+double convert<std::string, float>(float):2909472:181842
+0: 181842
+1: 181842
Index: test/Transforms/SampleProfile/syntax.ll
===================================================================
--- test/Transforms/SampleProfile/syntax.ll
+++ test/Transforms/SampleProfile/syntax.ll
@@ -5,14 +5,15 @@
 ; RUN: not opt < %s -sample-profile -sample-profile-file=%S/Inputs/bad_line_values.prof 2>&1 | FileCheck -check-prefix=BAD-LINE-VALUES %s
 ; RUN: not opt < %s -sample-profile -sample-profile-file=%S/Inputs/bad_discriminator_value.prof 2>&1 | FileCheck -check-prefix=BAD-DISCRIMINATOR-VALUE %s
 ; RUN: not opt < %s -sample-profile -sample-profile-file=%S/Inputs/bad_samples.prof 2>&1 | FileCheck -check-prefix=BAD-SAMPLES %s
+; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/bad_mangle.prof 2>&1 >/dev/null
 
 define void @empty() {
 entry:
   ret void
 }
 ; NO-DEBUG: error: No debug information found in function empty
 ; MISSING-FILE: error: missing.prof:
-; BAD-FN-HEADER: error: {{.*}}bad_fn_header.prof:1: Expected 'mangled_name:NUM:NUM', found empty:100:BAD
+; BAD-FN-HEADER: error: {{.*}}bad_fn_header.prof:1: Expected 'mangled_name:NUM:NUM', found 3empty:100:BAD
 ; BAD-SAMPLE-LINE: error: {{.*}}bad_sample_line.prof:3: Expected 'NUM[.NUM]: NUM[ mangled_name:NUM]*', found 1: BAD
 ; BAD-LINE-VALUES: error: {{.*}}bad_line_values.prof:2: Expected 'mangled_name:NUM:NUM', found -1: 10
 ; BAD-DISCRIMINATOR-VALUE: error: {{.*}}bad_discriminator_value.prof:2: Expected 'NUM[.NUM]: NUM[ mangled_name:NUM]*', found 1.-3: 10
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3087.2.patch
Type: text/x-patch
Size: 3445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140317/bcbc44ee/attachment.bin>


More information about the llvm-commits mailing list