[PATCH] D14558: [llvm-profdata] Add check for text profile formats and improve error reporting

Nathan Slingerland via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 10 16:33:54 PST 2015


slingn created this revision.
slingn added reviewers: dnovillo, bogner, davidxl.
slingn added a subscriber: llvm-commits.

This change addresses two possible instances of user error / confusion when
merging sampled profile data.

Previously any input that didn't match the raw or processed instrumented format
would automatically be interpreted as instrumented profile text format data.
No error would be reported during the merge.

Example:
If foo-sampled.profdata and bar-sampled.profdata are binary sampled profiles:

Old behavior:
$ llvm-profdata merge foo-sampled.profdata bar-sampled.profdata -output foobar-sampled.profdata
$ llvm-profdata show -sample foobar-sampled.profdata
error: foobar-sampled.profdata:1: Expected 'mangled_name:NUM:NUM', found  lprofi

This change adds basic checks for plain ASCII input data when assuming text
input. It also makes error messages related to file format validity more
specific about the assumbed profile data type.

New behavior:
$ llvm-profdata merge foo-sampled.profdata bar-sampled.profdata -output foobar-sampled.profdata
error: foo.profdata: Malformed instrumented profile data

http://reviews.llvm.org/D14558

Files:
  include/llvm/ProfileData/InstrProfReader.h
  include/llvm/ProfileData/SampleProfReader.h
  lib/ProfileData/InstrProf.cpp
  lib/ProfileData/InstrProfReader.cpp
  lib/ProfileData/SampleProf.cpp
  lib/ProfileData/SampleProfReader.cpp
  test/tools/llvm-profdata/raw-magic-but-no-header.test
  test/tools/llvm-profdata/text-format-errors.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14558.39869.patch
Type: text/x-patch
Size: 8395 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151111/cf987c50/attachment.bin>


More information about the llvm-commits mailing list