[PATCH] Tolerate unmangled names in sample profiles.

Chandler Carruth chandlerc at gmail.com
Mon Mar 17 13:19:58 PDT 2014


  Looks good w/o dead code and with the comment requested below.


================
Comment at: lib/Transforms/Scalar/SampleProfile.cpp:260-265
@@ -259,1 +259,8 @@
 
+  /// \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);
+  }
+
----------------
Now dead code?

================
Comment at: lib/Transforms/Scalar/SampleProfile.cpp:472
@@ -464,3 +471,3 @@
   // 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]+)(.*)$");
----------------
I would at least comment about the heuristic used to discard invalid samples. It is really hard to mentally verify that this switches us to consume names containing a ':'. I had to ask others to become confident. I think we've crossed the threshold at which I like REs for parsing. ;]

It is also possible in theory to use an asm label or other hack to create a symbol starting with a number. Not sure how or why this would ever be relevant for us though, so I'm happy with this approach, but again, the documentation will be essential if we ever get a bug filed on this.


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

BRANCH
  accept-unmangled

ARCANIST PROJECT
  llvm



More information about the llvm-commits mailing list