1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00
Commit Graph

159 Commits

Author SHA1 Message Date
David Blaikie
ade81caa2c llvm-profdata: Reduce memory usage by using Error callback rather than member
Reduces llvm-profdata memory usage on a large profile from 7.8GB to 5.1GB.

The ProfData API now supports reporting all the errors/warnings rather
than only the first, though llvm-profdata ignores everything after the
first for now to preserve existing behavior. (if there's a desire for
other behavior, happy to implement that - but might be as well left for
a separate patch)

Reviewers: davidxl

Differential Revision: https://reviews.llvm.org/D35149

llvm-svn: 307516
2017-07-10 03:04:59 +00:00
David Blaikie
d02fba9580 Prototype: Reduce llvm-profdata merge memory usage further
The InstrProfWriter already stores the name and hash of the record in
the nested maps it uses for lookup while merging - this data is
duplicated in the value within the maps.

Refactor the InstrProfRecord to use a nested struct for the counters
themselves so that InstrProfWriter can use this nested struct alone
without the name or hash duplicated there.

This work is incomplete, but enough to demonstrate the value (around a
50% decrease in memory usage for a large test case (10GB -> 5GB)).
Though most of that decrease is probably from removing the
SoftInstrProfError as well, but I haven't implemented a replacement for
it yet. (it needs to go with the counters, because the operations on the
counters - merging, etc, are where the failures are - unlike the
name/hash which are totally unused by those counter-related operations
and thus easy to split out)

Ongoing discussion about removing SoftInstrProfError as a field of the
InstrProfRecord is happening on the thread that added it - including
the possibility of moving back towards an earlier version of that
proposed patch that passed SoftInstrProfError through the various APIs,
rather than as a member of InstrProfRecord.

Reviewers: davidxl

Differential Revision: https://reviews.llvm.org/D34838

llvm-svn: 307298
2017-07-06 19:00:12 +00:00
Vedant Kumar
30059fc639 [ProfileData] PR33517: Check for failure of symtab creation
With PR33517, it became apparent that symbol table creation can fail
when presented with malformed inputs. This patch makes that sort of
error detectable, so llvm-cov etc. can fail more gracefully.

Specifically, we now check that function names within the symbol table
aren't empty.

Testing: check-{llvm,clang,profile}, some unit test updates.
llvm-svn: 305765
2017-06-20 01:38:56 +00:00
Teresa Johnson
6b6d815883 Fix a couple of typos in memory intrinsic optimization output (NFC)
s/instrinsic/intrinsic

llvm-svn: 303782
2017-05-24 17:55:25 +00:00
Rong Xu
cd36e86346 Resubmit r297897: [PGO] Value profile for size of memory intrinsic calls
R297897 inadvertently enabled annotation for memop profiling. This new patch
fixed it.

llvm-svn: 297996
2017-03-16 21:15:48 +00:00
Eric Liu
236e5336c2 Revert "[PGO] Value profile for size of memory intrinsic calls"
This commit reverts r297897 and r297909.

llvm-svn: 297951
2017-03-16 13:16:35 +00:00
Rong Xu
4f45e0df06 [PGO] Value profile for size of memory intrinsic calls
This patch adds the value profile support to profile the size parameter of
memory intrinsic calls: memcpy, memcmp, and memmov.

Differential Revision: http://reviews.llvm.org/D28965

llvm-svn: 297897
2017-03-15 21:47:27 +00:00
Rong Xu
78ba7376be [PGO] Refactor profile dumping function for ease of adding other profile kind
Refactor the dumping function so that we can add other value profile kind easily.

Differential Revision: https://reviews.llvm.org/D30752

llvm-svn: 297399
2017-03-09 19:03:57 +00:00
Chris Bieneman
68298db4f6 [CMake] llvm-profdata depends on intrinsics_gen
llvm-profdata.cpp has the following include chain:

llvm/ProfileData/SampleProfReader.h
llvm/IR/Function.h
llvm/IR/Argument.h
llvm/IR/Attributes.h
llvm/IR/Attributes.gen

This means llvm-profdata needs to depend on intrinsics_gen.

llvm-svn: 287394
2016-11-18 23:04:15 +00:00
Rong Xu
ceabec2f7e [PGO] Fix a use-after-move. NFC.
llvm-svn: 284664
2016-10-19 23:31:59 +00:00
Rong Xu
040e4952d0 [PGO] Fix bogus warning for merging empty llvm profile file
Profile runtime can generate an empty raw profile (when there is no function in
the shared library). This empty profile is treated as a text format profile.  A
test format profile without the flag of "#IR" is thought to be a clang
generated profile.  So in llvm profile merging, we will get a bogus warning of
"Merge IR generated profile with Clang generated profile."

The fix here is to skip the empty profile (when the buffer size is 0) for
profile merge.

Reviewers: vsk, davidxl

Differential Revision: http://reviews.llvm.org/D25687

llvm-svn: 284659
2016-10-19 22:51:17 +00:00
Mehdi Amini
a6cfd067ac Turn cl::values() (for enum) from a vararg function to using C++ variadic template
The core of the change is supposed to be NFC, however it also fixes
what I believe was an undefined behavior when calling:

 va_start(ValueArgs, Desc);

with Desc being a StringRef.

Differential Revision: https://reviews.llvm.org/D25342

llvm-svn: 283671
2016-10-08 19:41:06 +00:00
Xinliang David Li
71316d5b37 [Profile] dump ic value profile value/site-count histogram
Differential Revision: http://reviews.google.com/D24783

llvm-svn: 282017
2016-09-20 21:04:22 +00:00
Justin Bogner
c8c589f243 llvm-profdata: Clarify the top level help
It wasn't very obvious that you're supposed to call help on the
subcommands. This should help.

llvm-svn: 277678
2016-08-03 23:10:51 +00:00
Benjamin Kramer
a96697aa5e [llvm-profdata] Bring back reading profile data from STDIN.
This feature was lost in r276197.

llvm-svn: 276407
2016-07-22 12:39:55 +00:00
Benjamin Kramer
a4f804055a [profdata] Remove constructor that MSVC 2013 pretends to not understand.
No functionality change intended.

llvm-svn: 276284
2016-07-21 14:29:11 +00:00
Xinliang David Li
40622c593b Reapply r276185
Fix the test case that should not depend on dir iteration order.

llvm-svn: 276197
2016-07-20 22:24:52 +00:00
Xinliang David Li
31d2c7e14d Revert r276185 -- build bot failure
llvm-svn: 276194
2016-07-20 21:50:38 +00:00
Xinliang David Li
a600368d3e [Profile] support directory reading in profile merging
Differential Revision:  http://reviews.llvm.org/D22560

llvm-svn: 276185
2016-07-20 21:31:29 +00:00
Vedant Kumar
78dfceef4b Retry: [llvm-profdata] Speed up merging by using a thread pool
Add a "-j" option to llvm-profdata to control the number of threads used.
Auto-detect NumThreads when it isn't specified, and avoid spawning threads when
they wouldn't be beneficial.

I tested this patch using a raw profile produced by clang (147MB). Here is the
time taken to merge 4 copies together on my laptop:

  No thread pool: 112.87s user 5.92s system 97% cpu 2:01.08 total
  With 2 threads: 134.99s user 26.54s system 164% cpu 1:33.31 total

Changes since the initial commit:

  - When handling odd-length inputs, call ThreadPool::wait() before merging the
    last profile. Should fix a race/off-by-one (see r275937).

Differential Revision: https://reviews.llvm.org/D22438

llvm-svn: 275938
2016-07-19 01:17:20 +00:00
Vedant Kumar
338daec4d5 Revert "[llvm-profdata] Speed up merging by using a thread pool"
This reverts commit r275921. It broke the ppc64be bot:

  http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/3537

I'm not sure why it broke, but based on the output, it looks like an
off-by-one (one profile left un-merged).

llvm-svn: 275937
2016-07-19 00:57:09 +00:00
Vedant Kumar
498432e86b [llvm-profdata] Speed up merging by using a thread pool
Add a "-j" option to llvm-profdata to control the number of threads
used. Auto-detect NumThreads when it isn't specified, and avoid spawning
threads when they wouldn't be beneficial.

I tested this patch using a raw profile produced by clang (147MB). Here is the
time taken to merge 4 copies together on my laptop:

  No thread pool: 112.87s user 5.92s system 97% cpu 2:01.08 total
  With 2 threads: 134.99s user 26.54s system 164% cpu 1:33.31 total

Differential Revision: https://reviews.llvm.org/D22438

llvm-svn: 275921
2016-07-18 22:02:39 +00:00
Benjamin Kramer
0d4a698a65 Apply another batch of fixes from clang-tidy's performance-unnecessary-value-param.
Contains some manual fixes. No functionality change intended.

llvm-svn: 273047
2016-06-17 20:41:14 +00:00
Richard Smith
f7f711ffaa Search for llvm-symbolizer binary in the same directory as argv[0], before
looking for it along $PATH. This allows installs of LLVM tools outside of
$PATH to find the symbolizer and produce pretty backtraces if they crash.

llvm-svn: 272232
2016-06-09 00:53:21 +00:00
Vedant Kumar
f43ae6493c Retry^4 "[llvm-profdata] Add option to ingest filepaths from a file"
Changes since the initial commit:
- Use echo instead of printf. This should side-step the character
  escaping issues on Windows.

Differential Revision: http://reviews.llvm.org/D20980

llvm-svn: 272068
2016-06-07 22:47:31 +00:00
Vedant Kumar
5d5b447dbe Revert "Retry^2 "[llvm-profdata] Add option to ingest filepaths from a file""
This reverts commit r271953. It's still breaking on Windows, though the
list initialization issue is fixed:

http://bb.pgr.jp/builders/ninja-clang-i686-msc19-R/builds/3751

llvm-svn: 271963
2016-06-06 23:43:56 +00:00
Vedant Kumar
d32e283fe4 Retry^2 "[llvm-profdata] Add option to ingest filepaths from a file"
Changes since the initial commit:
- Normalize file paths read from the file to prevent Windows path
  separators from escaping parts of the path.
- Since we need to store the normalized file paths in WeightedFile,
  don't do tricky things to keep the source MemoryBuffer alive.
- Don't use list-initialization for a std::string in WeightedFile.

Differential Revision: http://reviews.llvm.org/D20980

llvm-svn: 271953
2016-06-06 23:17:22 +00:00
Vedant Kumar
196f3e9316 Revert "Retry "[llvm-profdata] Add option to ingest filepaths from a file"
This reverts commit r271949. It breaks the Windows build:

http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/12796

llvm-svn: 271952
2016-06-06 23:01:42 +00:00
Vedant Kumar
6357ddf5ed Retry "[llvm-profdata] Add option to ingest filepaths from a file"
Changes since the initial commit:
- Normalize file paths read from the file to prevent Windows path
  separators from escaping parts of the path.
- Since we need to store the normalized file paths in WeightedFile,
  don't do tricky things to keep the source MemoryBuffer alive.

Differential Revision: http://reviews.llvm.org/D20980

llvm-svn: 271949
2016-06-06 22:39:22 +00:00
Chandler Carruth
85f0f82387 [llvm-profdata] Revert r271709 and the 3 subsequent commits - the code
and/or tests aren't working on Windows currently.

There seems to be some problem with quoting the file paths. I don't
understand the test structure here or the code well enough to try to
come up with a way to correctly handle paths with back slashes in them,
and this has caused the Windows builds to be failing for 7 hours now, so
I'm reverting the whole thing to bring them back to life. Sorry for the
disruption, but a couple of these were bug fixes anyways that can be
folded into a fresh commit.

Reverts the following patches:

r271756: Clean up the way we create the input filenames buffer (NFC)
r271748: Fix use-after-free from discarded MemoryBuffer (NFC)
r271710: Fix option description (NFC)
r271709: Add option to ingest filepaths from a file
llvm-svn: 271760
2016-06-04 03:08:01 +00:00
Vedant Kumar
bdf8e4b9f9 [llvm-profdata] Clean up the way we create the input filenames buffer (NFC)
Create the buffer before calling parseInputFilenamesFile(), and add a
comment explaining why this is done.

Thanks to David Li for the suggestion!

llvm-svn: 271756
2016-06-04 00:36:28 +00:00
Vedant Kumar
56ea31445a [llvm-profdata] Fix use-after-free from discarded MemoryBuffer (NFC)
Thanks to Justin Bogner for pointing this out!

Caught by ASAN.

llvm-svn: 271748
2016-06-03 23:12:38 +00:00
Vedant Kumar
9371a53dfc [llvm-profdata] Fix option description (NFC)
llvm-svn: 271710
2016-06-03 19:10:25 +00:00
Vedant Kumar
6bbf734940 [llvm-profdata] Add option to ingest filepaths from a file
Differential Revision: http://reviews.llvm.org/D20980

llvm-svn: 271709
2016-06-03 19:05:20 +00:00
Vedant Kumar
6e8ea28227 Trim some spaces (NFC)
llvm-svn: 271681
2016-06-03 15:58:59 +00:00
Xinliang David Li
25d45137cc [profile] show more statistics
Add value profile statistics with the 'show' command.

llvm-svn: 270450
2016-05-23 16:36:11 +00:00
Easwaran Raman
22b9d19212 Remove specializations of ProfileSummary
This removes the subclasses of ProfileSummary, moves the members of the derived classes to the base class.

Differential Revision: http://reviews.llvm.org/D20390

llvm-svn: 270143
2016-05-19 21:53:28 +00:00
Easwaran Raman
5807e047c7 Move ProfileSummary to IR.
This splits ProfileSummary into two classes: a ProfileSummary class that has methods to convert from/to metadata and a ProfileSummaryBuilder class that computes the profiles summary which is in ProfileData.

Differential Revision: http://reviews.llvm.org/D20314

llvm-svn: 270136
2016-05-19 21:07:12 +00:00
Vedant Kumar
d34b10ac08 Retry^3 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"
Transition InstrProf and Coverage over to the stricter Error/Expected
interface.

Changes since the initial commit:
- Fix error message printing in llvm-profdata.
- Check errors in loadTestingFormat() + annotateAllFunctions().
- Defer error handling in InstrProfIterator to InstrProfReader.
- Remove the base ProfError class to work around an MSVC ICE.

Differential Revision: http://reviews.llvm.org/D19901

llvm-svn: 270020
2016-05-19 03:54:45 +00:00
Vedant Kumar
e233548c19 Revert "Retry^2 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC""
This reverts commit r269694. MSVC says:

error C2086: 'char llvm::ProfErrorInfoBase<enum llvm::instrprof_error>::ID' : redefinition

llvm-svn: 269700
2016-05-16 21:03:38 +00:00
Vedant Kumar
511487a013 Retry^2 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"
Transition InstrProf and Coverage over to the stricter Error/Expected
interface.

Changes since the initial commit:
- Address undefined-var-template warning.
- Fix error message printing in llvm-profdata.
- Check errors in loadTestingFormat() + annotateAllFunctions().
- Defer error handling in InstrProfIterator to InstrProfReader.

Differential Revision: http://reviews.llvm.org/D19901

llvm-svn: 269694
2016-05-16 20:49:39 +00:00
Chandler Carruth
838142a962 Revert "Retry "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC""
This reverts commit r269491. It triggers warnings with Clang, breaking
builds for -Werror users including several build bots.

llvm-svn: 269547
2016-05-14 05:26:26 +00:00
Vedant Kumar
b1f881cc44 Retry "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"
Transition InstrProf and Coverage over to the stricter Error/Expected
interface.

Changes since the initial commit:
- Fix error message printing in llvm-profdata.
- Check errors in loadTestingFormat() + annotateAllFunctions().
- Defer error handling in InstrProfIterator to InstrProfReader.

Differential Revision: http://reviews.llvm.org/D19901

llvm-svn: 269491
2016-05-13 21:50:56 +00:00
Vedant Kumar
f80d958e78 Revert "(HEAD -> master, origin/master, origin/HEAD) [ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"
This reverts commit r269462. It fails two llvm-profdata tests.

llvm-svn: 269466
2016-05-13 20:09:39 +00:00
Vedant Kumar
edf8350f15 [ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC
Transition InstrProf and Coverage over to the stricter Error/Expected
interface.

Differential Revision: http://reviews.llvm.org/D19901

llvm-svn: 269462
2016-05-13 20:01:27 +00:00
Vedant Kumar
842b69e863 Remove unused header, NFC
llvm-svn: 268361
2016-05-03 05:05:38 +00:00
Mehdi Amini
ea195a382e Remove every uses of getGlobalContext() in LLVM (but the C API)
At the same time, fixes InstructionsTest::CastInst unittest: yes
you can leave the IR in an invalid state and exit when you don't
destroy the context (like the global one), no longer now.

This is the first part of http://reviews.llvm.org/D19094

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266379
2016-04-14 21:59:01 +00:00
Easwaran Raman
e7d97265e1 Add a profile summary class specific to instrumentation profiles.
Modify ProfileSummary class to make it not instrumented profile specific.
Add a new InstrumentedProfileSummary class that inherits from ProfileSummary.

Differential Revision: http://reviews.llvm.org/D17310

llvm-svn: 261119
2016-02-17 18:18:47 +00:00
Rong Xu
846b326ad9 [PGO] Differentiate Clang instrumentation and IR level instrumentation profiles
This patch uses one bit in profile version to differentiate Clang
instrumentation and IR level instrumentation profiles.

PGOInstrumenation generates a COMDAT variable __llvm_profile_raw_version so
that the compiler runtime can set the right profile kind.
For Maco-O platform, we generate the variable as linkonce_odr linkage as
COMDAT is not supported.

PGOInstrumenation now checks this bit to make sure it's an IR level
instrumentation profile.

The patch was submitted as r260164 but reverted due to a Darwin test breakage.
Original Differential Revision: http://reviews.llvm.org/D15540

Differential Revision: http://reviews.llvm.org/D17020

llvm-svn: 260385
2016-02-10 17:18:30 +00:00
Rong Xu
6836bd6879 [PGO] Revert r260146 as it breaks Darwin platforms.
r260146 | xur | 2016-02-08 13:07:46 -0800 (Mon, 08 Feb 2016) | 13 lines
[PGO] Differentiate Clang instrumentation and IR level instrumentation profiles

llvm-svn: 260170
2016-02-08 23:11:16 +00:00
Rong Xu
5b6f09e7f2 [PGO] Differentiate Clang instrumentation and IR level instrumentation profiles
This patch uses one bit in profile version to differentiate Clang
instrumentation and IR level instrumentation profiles.

PGOInstrumenation generates a COMDAT variable __llvm_profile_raw_version so
that the compiler runtime can set the right profile kind.
PGOInstrumenation now checks this bit to make sure it's an IR level
instrumentation profile.

Differential Revision: http://reviews.llvm.org/D15540

llvm-svn: 260146
2016-02-08 21:07:46 +00:00
Easwaran Raman
6960cdccb8 Refactor profile summary support code. NFC.
Summary computation is not just for instrumented profiling and so I have moved
the ProfileSummary class to ProfileCommon.h (named so to allow code unrelated
to summary but common to instrumented and sampled profiling to be placed there)

Differential Revision: http://reviews.llvm.org/D16661

llvm-svn: 259846
2016-02-04 23:34:31 +00:00
Vedant Kumar
e1a3d86600 [Profiling] Add a -sparse mode to llvm-profdata merge
Add an option to llvm-profdata merge for writing out sparse indexed
profiles. These profiles omit InstrProfRecords for functions which are
never executed.

Differential Revision: http://reviews.llvm.org/D16727

llvm-svn: 259258
2016-01-29 22:54:45 +00:00
Chris Bieneman
1b8d4f74aa Remove autoconf support
Summary:
This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

"I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened."
- Obi Wan Kenobi

Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark

Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits

Differential Revision: http://reviews.llvm.org/D16471

llvm-svn: 258861
2016-01-26 21:29:08 +00:00
Xinliang David Li
121c2832bb [PGO] fix a bug in profile summary computation
Entry block count was not counted and is corrected. Also
introduce a new metric that is MaxInternalBlockCount which
show command shows (as before).

llvm-svn: 257987
2016-01-16 05:29:49 +00:00
Xinliang David Li
6b68a0ee43 [PGO] Move profile summary interface/impl into InstrProf.[*] /NFC
llvm-svn: 257819
2016-01-14 22:10:49 +00:00
NAKAMURA Takumi
4b1f1aa597 llvm-profdata.cpp: Fix comment lines. [-Wdocumentation]
llvm-svn: 257726
2016-01-14 00:36:59 +00:00
Easwaran Raman
be7342fab7 Display detailed profile summary in llvm-profdata tool.
This adds a detailed profile summary in llvm-profdata. The summary is in the
form of one or more triples of the form (P, N, M) which is interpreted as if
we look at the Top-N counts in the profile, their sum accounts for P percentage
of the sum of all counts in the program and the minimum count in the Top-N is M.

Differential Revision: http://reviews.llvm.org/D16005

llvm-svn: 257680
2016-01-13 21:44:36 +00:00
Xinliang David Li
859c330e8f [PGO] Improve Indexed Profile Reader efficiency
With the support of value profiling added, the Indexed prof
reader gets less efficient. The prof reader initialization
used to be just reading the file header, but with VP support
added, initialization needs to walk through all profile keys
of ondisk hash table resulting in very poor locality and large
memory increase (keys are stored together with the profile data
in the mapped profile buffer). Even worse, when the reader is 
used by the compiler (not llvm-profdata too), the penalty becomes
very high as compilation of each single module requires touching
profile data buffer for the whole program. 

In this patch, the icall target values (MD5hash) are no longer eargerly 
converted back to name strings when the data is read into memory. New
interface is added to to profile reader so that InstrProfSymtab can be
lazily created for Indexed profile reader on-demand. Creating of the 
symtab is intended to be used by llvm-profdata tool for symbolic dumping
of  VP data. It can be used with compiler (for legacy out of tree uses)
too but not recommended due to compile time and memory reasons 
mentioned above.

Some other cleanups are also included: Function Addr to md5 map is now
consolated into InstrProfSymtab. InstrProfStringtab is no longer used and
eliminated.

llvm-svn: 256114
2015-12-20 06:22:13 +00:00
Nathan Slingerland
648ea4f74f [PGO] Handle and report overflow during profile merge for all types of data
Summary: Surface counter overflow when merging profile data. Merging still occurs on overflow but counts saturate to the maximum representable value. Overflow is reported to the user.

Reviewers: davidxl, dnovillo, silvas

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D15547

llvm-svn: 255825
2015-12-16 21:45:43 +00:00
Nathan Slingerland
b95c2eec31 [llvm-profdata] Add support for weighted merge of profile data (2nd try)
Summary:
This change adds support for specifying a weight when merging profile data with the llvm-profdata tool.
Weights are specified by using the --weighted-input=<weight>,<filename> option. Input files not specified
with this option (normal positional list after options) are given a default weight of 1.

Adding support for arbitrary weighting of input profile data allows for relative importance to be placed on the
input data from multiple training runs.

Both sampled and instrumented profiles are supported.

Reviewers: davidxl, dnovillo, bogner, silvas

Subscribers: silvas, davidxl, llvm-commits

Differential Revision: http://reviews.llvm.org/D15306

llvm-svn: 255659
2015-12-15 17:37:09 +00:00
Diego Novillo
c2f8d731bc Fix formatting. NFC.
llvm-svn: 255541
2015-12-14 20:37:15 +00:00
Nathan Slingerland
5a941550ef Revert "[llvm-profdata] Add support for weighted merge of profile data"
This reverts commit b7250858d96b8ce567681214273ac0e62713c661.

Reverting in order to investigate Windows test failure.

llvm-svn: 254687
2015-12-04 02:13:58 +00:00
Nathan Slingerland
e6205d97d7 [llvm-profdata] Add support for weighted merge of profile data
This change adds support for an optional weight when merging profile data with the llvm-profdata tool.
Weights are specified by adding an option ':<weight>' suffix to the input file names.

Adding support for arbitrary weighting of input profile data allows for relative importance to be placed on the
input data from multiple training runs.

Both sampled and instrumented profiles are supported.

Reviewers: dnovillo, bogner, davidxl

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D14547

llvm-svn: 254669
2015-12-04 00:00:20 +00:00
Xinliang David Li
0f29a15199 [PGO] Add --text option for llvm-profdata show|merge commands
The new option is similar to the SampleProfile dump option.

- dump raw/indexed format into text profile format
- merge the profile and output into text profile format.

Note that Value Profiling data text format is not yet designed. 
That functionality will be added later.

Differential Revision: http://reviews.llvm.org/D14894

llvm-svn: 253913
2015-11-23 20:47:38 +00:00
Nathan Slingerland
7993025023 [llvm-profdata] Use SmallSet rather that std::set for keeping track of profdata merge errors
Missed bit of feedback from D14720.

Use SmallSet<std::error_code> rather than std::set<...> in order to be more efficient.

llvm-svn: 253474
2015-11-18 17:10:24 +00:00
Nathan Slingerland
837191e935 [llvm-profdata] Fix unhandled enumeration values warning
Fix this:

llvm/tools/llvm-profdata/llvm-profdata.cpp:78:15: warning: 12 enumeration values not handled in switch: 'success', 'eof', 'unrecognized_format'... [-Wswitch]
      switch (instrError) {
                    ^

llvm-svn: 253413
2015-11-18 00:52:45 +00:00
Nathan Slingerland
a23131f082 [llvm-profdata] Show hint for other mismatch errors when merging instr profdata
Missed bit of feedback from D14720.

Show the same "Make sure that all profile
data to be merged is generated from the same binary." hint for hash mismatch
and value site count mismatch as we now do for counter mismatch when merging
incompatible instrumentation profile data.

llvm-svn: 253400
2015-11-17 23:37:09 +00:00
Nathan Slingerland
9c743e7e7f [llvm-profdata] Improve error messaging when merging mismatched profile data
Summary:
This change tries to make the root cause of instrumented profile data merge failures clearer.

Previous:

$ llvm-profdata merge test_0.profraw test_1.profraw -o test_merged.profdata
test_1.profraw: foo: Function count mismatch
test_1.profraw: bar: Function count mismatch
test_1.profraw: baz: Function count mismatch
...

Changed:

$ llvm-profdata merge test_0.profraw test_1.profraw -o test_merged.profdata
test_1.profraw: foo: Function basic block count change detected (counter mismatch)
Make sure that all profile data to be merged is generated from the same binary.
test_1.profraw: bar: Function basic block count change detected (counter mismatch)
test_1.profraw: baz: Function basic block count change detected (counter mismatch)
...

Reviewers: dnovillo, davidxl, bogner

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D14739

llvm-svn: 253384
2015-11-17 22:08:53 +00:00
Nathan Slingerland
6548debed0 [llvm-profdata] Add check for text profile formats and improve error reporting (2nd try)
Summary:
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 valid 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 -o foobar-sampled.profdata
error: foo.profdata: Unrecognized instrumentation profile encoding format
Perhaps you forgot to use the -sample option?

Reviewers: bogner, davidxl, dnovillo

Subscribers: davidxl, llvm-commits

Differential Revision: http://reviews.llvm.org/D14558

llvm-svn: 253009
2015-11-13 03:47:58 +00:00
Nathan Slingerland
8e7a949f3a reverting r252916 to investigate test failure
llvm-svn: 252921
2015-11-12 18:39:26 +00:00
Nathan Slingerland
33ebda0446 [llvm-profdata] Add check for text profile formats and improve error reporting
Summary:
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 valid 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 -o foobar-sampled.profdata
error: foo.profdata: Unrecognized instrumentation profile encoding format
Perhaps you forgot to use the -sample option?

Reviewers: bogner, davidxl, dnovillo

Subscribers: davidxl, llvm-commits

Differential Revision: http://reviews.llvm.org/D14558

llvm-svn: 252916
2015-11-12 18:06:18 +00:00
Xinliang David Li
1ef7153d55 [PGO] Value profiling (index format) code cleanup and testing
1. Added a set of public interfaces in InstrProfRecord
    class to access (read/write) value profile data.
 2. Changed IndexedProfile reader and writer code to 
    use the newly defined interfaces and hide implementation
    details.
 3. Added a couple of unittests for value profiling:
   - Test new interfaces to get and set value profile data
   - Test value profile data merging with various scenarios.

 No functional change is expected. The new interfaces will also
 make it possible to change on-disk format of value prof data
 to be more compact (to be submitted). 

llvm-svn: 251771
2015-11-02 05:08:23 +00:00
Diego Novillo
c49885ed99 Re-apply r249644: Handle inline stacks in gcov-encoded sample profiles.
This fixes memory allocation problems by making the merge operation keep
the profile readers around until the merged profile has been emitted.
This is needed to prevent the inlined function names to disappear from
the function profiles. Since all the names are kept as references, once
the reader disappears, the names are also deallocated.

Additionally, XFAIL on big-endian architectures. The test case uses a
gcov file generated on a little-endian system.

llvm-svn: 249724
2015-10-08 19:40:37 +00:00
Justin Bogner
b34b76538a InstrProf: Support for value profiling in the indexed profile format
Add support to the indexed instrprof reader and writer for the format
that will be used for value profiling.

Patch by Betul Buyukkurt, with minor modifications.

llvm-svn: 248833
2015-09-29 22:13:58 +00:00
Diego Novillo
c0de8306fc Check for errors after reading a sample profile in llvm-profdata.
After reading the profile, check if the reader returned any errors
before showing the profile.

llvm-svn: 247873
2015-09-17 00:17:21 +00:00
Duncan P. N. Exon Smith
4667732963 modules: Move ProfileKinds to an anonymous namespace
Fix a build failure with `LLVM_ENABLE_MODULES` due to
`ProfileData::instr` conflicting with a function `instr()` in
`<curses.h>`.

llvm-svn: 239793
2015-06-16 00:43:04 +00:00
Benjamin Kramer
45a545b9c6 Purge unused includes throughout libSupport.
NFC.

llvm-svn: 232976
2015-03-23 18:07:13 +00:00
Benjamin Kramer
5ce1e9672a Make helper functions static.
Found by -Wmissing-prototypes. NFC.

llvm-svn: 231664
2015-03-09 16:23:46 +00:00
Chris Bieneman
9a06c4c87f Assigning and copying command line option objects shouldn't be allowed.
Summary:
The default copy and assignment operators for these objects probably don't actually do what the clients intend, so they should be deleted.

Places using the assignment operator to set the value of an option should cast to the option's data type first to call into the override for operator=. Places using the copy constructor just need to be changed to not copy (i.e. passing by const reference instead of value).

Reviewers: dexonsmith, chandlerc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D7114

llvm-svn: 226762
2015-01-22 01:49:59 +00:00
Chandler Carruth
0b619fcc8e [cleanup] Re-sort all the #include lines in LLVM using
utils/sort_includes.py.

I clearly haven't done this in a while, so more changed than usual. This
even uncovered a missing include from the InstrProf library that I've
added. No functionality changed here, just mechanical cleanup of the
include order.

llvm-svn: 225974
2015-01-14 11:23:27 +00:00
Diego Novillo
ba36fbe7cb Use ErrorOr for the ::create factory on instrumented and sample profilers.
Summary:
As discussed in
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141027/242445.html,
the creation of reader and writer instances is better done using
ErrorOr. There are no functional changes, but several callers needed to
be adjusted.

Reviewers: bogner

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6076

llvm-svn: 221120
2014-11-03 00:51:45 +00:00
NAKAMURA Takumi
fe65e1d9ef [CMake] llvm-profdata requires Core.
llvm-svn: 221046
2014-11-01 11:46:04 +00:00
Diego Novillo
7ba22bc99a Add show and merge tools for sample PGO profiles.
Summary:
This patch extends the 'show' and 'merge' commands in llvm-profdata to handle
sample PGO formats. Using the 'merge' command it is now possible to convert
one sample PGO format to another.

The only format that is currently not working is 'gcc'. I still need to
implement support for it in lib/ProfileData.

The changes in the sample profile support classes are needed for the
merge operation.

Reviewers: bogner

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6065

llvm-svn: 221032
2014-11-01 00:56:55 +00:00
Rafael Espindola
1d5713d9bf Modernize raw_fd_ostream's constructor a bit.
Take a StringRef instead of a "const char *".
Take a "std::error_code &" instead of a "std::string &" for error.

A create static method would be even better, but this patch is already a bit too
big.

llvm-svn: 216393
2014-08-25 18:16:47 +00:00
Justin Bogner
aaa0b69577 Support: Fix option handling when using cl::Required with aliasopt
Until now, attempting to create an alias of a required option would
complain if the user supplied the alias, because the required option
didn't have a value. Similarly, if you said the alias was required,
then using the base option would complain that the alias wasn't
supplied. Lastly, if you put required on both, *neither* option would
work.

By changning alias to overload addOccurrence and setting cl::Required
on the original option, we can get this to behave in a more useful
way. I've also added a test and updated a user that was getting this
wrong.

llvm-svn: 212986
2014-07-14 20:53:57 +00:00
Rafael Espindola
5c15b3d369 Remove 'using std::error_code' from tools.
llvm-svn: 210876
2014-06-13 03:07:50 +00:00
Rafael Espindola
e0e308ff6d Don't use 'using std::error_code' in include/llvm.
This should make sure that most new uses use the std prefix.

llvm-svn: 210835
2014-06-12 21:46:39 +00:00
Benjamin Kramer
4f8fb8ff6c raw_ostream: Forward declare OpenFlags and include FileSystem.h only where necessary.
llvm-svn: 207593
2014-04-29 23:26:49 +00:00
Craig Topper
0e2ab5732c [C++] Use 'nullptr'. Tools edition.
llvm-svn: 207176
2014-04-25 04:24:47 +00:00
Justin Bogner
532de088bc ProfileData: Treat missing function counts as malformed
llvm-svn: 207172
2014-04-25 02:45:33 +00:00
Justin Bogner
426c7606ff ProfileData: Add support for the indexed instrprof format
This adds support for an indexed instrumentation based profiling
format, which is just a small header and an on disk hash table.  This
format will be used by clang's -fprofile-instr-use= for PGO.

llvm-svn: 206656
2014-04-18 21:48:40 +00:00
Justin Bogner
92a3f4949e llvm-profdata: Check for bad data in the show command
llvm-svn: 204573
2014-03-23 20:55:53 +00:00
Justin Bogner
ae98297352 llvm-profdata: Use Format.h instead of handrolling a formatter
llvm-svn: 204571
2014-03-23 20:43:50 +00:00
NAKAMURA Takumi
abbb9ce154 llvm-profdata doesn't require LLVMCore.
llvm-svn: 204552
2014-03-23 01:23:26 +00:00
NAKAMURA Takumi
f6af0a00b3 llvm-profdata: Avoid F_Text in "merge" for now, since "llvm-profdata show" is confused with CRLF.
FIXME: line_iterator should be tolerant of CR.
llvm-svn: 204540
2014-03-22 05:38:22 +00:00
Justin Bogner
d63f8d1914 ProfileData: Introduce InstrProfWriter using the naive text format
This isn't a format we'll want to write out in practice, but moving it
to the writer library simplifies llvm-profdata and isolates it from
further changes to the format.

This also allows us to update the tests to not rely on the text output
format.

llvm-svn: 204489
2014-03-21 17:46:22 +00:00
Justin Bogner
b204d62d40 llvm-profdata: Implement show command
The `llvm-profdata show` command summarizes a profdata file's contents
in a human readable format.

llvm-svn: 204485
2014-03-21 17:29:44 +00:00
Justin Bogner
a2a74068a7 ProfileData: Introduce the InstrProfReader interface and a text reader
This introduces the ProfileData library and updates llvm-profdata to
use this library for reading profiles. InstrProfReader is an abstract
base class that will be subclassed for both the raw instrprof data
from compiler-rt and the efficient instrprof format that will be used
for PGO.

llvm-svn: 204482
2014-03-21 17:24:48 +00:00
Justin Bogner
e18a7b6b19 llvm-profdata: Remove an empty comment
llvm-svn: 204370
2014-03-20 18:37:27 +00:00