Commit Graph

384 Commits

Author SHA1 Message Date
Rong Xu
37444017a2 [PGO] PGOFuncName in LTO optimizations
PGOFuncNames are used as the key to retrieve the Function definition from the
MD5 stored in the profile. For internal linkage function, we prefix the source
file name to the PGOFuncNames. LTO's internalization privatizes many global linkage
symbols. This happens after value profile annotation, but those internal
linkage functions should not have a source prefix. To differentiate compiler
generated internal symbols from original ones, PGOFuncName meta data are
created and attached to the original internal symbols in the value profile
annotation step. If a symbol does not have the meta data, its original linkage
must be non-internal.

Also add a new map that maps PGOFuncName's MD5 value to the function definition.

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





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264902 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 18:37:52 +00:00
Rong Xu
34be7e62f2 [PGO] Use ArrayRef in annotateValueSite()
Using ArrayRef in annotateValueSite's parameter instead of using an array
and it's size.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264879 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 16:56:31 +00:00
Easwaran Raman
418032a1c8 Sample profile summary cleanup
Replace references to MaxHeadSamples with MaxFunctionCount

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264686 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 23:14:29 +00:00
Vedant Kumar
76bf991538 Reapply (2x) "[PGO] Fix name encoding for ObjC-like functions"
Function names in ObjC can have spaces in them. This interacts poorly
with name compression, which uses spaces to separate PGO names. Fix the
issue by using a different separator and update a test.

I chose "\01" as the separator because 1) it's non-printable, 2) we
strip it from PGO names, and 3) it's the next natural choice once "\00"
is discarded (that one's overloaded).

What's changed since the original commit?

- I fixed up the covmap-V2 binary format tests using a linux VM.
- I weakened the CHECK lines in instrprof-comdat.h to account for the
  fact that there have been bugfixes to clang coverage. These will be
  fixed up in a follow-up.
- I added an assert to make sure we don't get bitten by this again.
- I constructed the c-general.profraw file without name compression
  enabled to appease some bots.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264658 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 21:06:42 +00:00
Vedant Kumar
0afb669256 Revert "Reapply "[PGO] Fix name encoding for ObjC-like functions""
This reverts commit r264641 to investigate why c-general.test is failing
on the bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264643 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 20:20:40 +00:00
Vedant Kumar
e15d81ae23 Reapply "[PGO] Fix name encoding for ObjC-like functions"
Function names in ObjC can have spaces in them. This interacts poorly
with name compression, which uses spaces to separate PGO names. Fix the
issue by using a different separator and update a test.

I chose "\01" as the separator because 1) it's non-printable, 2) we
strip it from PGO names, and 3) it's the next natural choice once "\00"
is discarded (that one's overloaded).

This reverts the revert commit beaf3d18. What's changed?

- I fixed up the covmap-V2 binary format tests using a linux VM.
- I updated the expected counts in instrprof-comdat.h to account for
  the fact that there have been bugfixes to clang coverage.
- I added an assert to make sure we don't get bitten by this again.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264641 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 20:12:07 +00:00
Easwaran Raman
91fbac1a08 Profile summary cleanup.
Differential Revision: http://reviews.llvm.org/D18468



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264619 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 18:58:05 +00:00
Adam Nemet
4ba91c0bea [PGO] Comment how function pointers for indirect calls are mapped to function names
Summary:
Hopefully this will make it easier for the next person to figure all
this out...

Reviewers: bogner, davidxl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264611 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 18:27:44 +00:00
Vedant Kumar
beaf3d18cf Revert "[PGO] Fix name encoding for ObjC-like functions"
This reverts commit r264587. Reverting to investigate 6 unexpected
failures on the ppc bot:

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264590 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 16:14:07 +00:00
Vedant Kumar
f63fe23e0d [PGO] Fix name encoding for ObjC-like functions
Function names in ObjC can have spaces in them. This interacts poorly
with name compression, which uses spaces to separate PGO names. Fix the
issue by using a different separator and update a test.

I chose "\01" as the separator because 1) it's non-printable, 2) we
strip it from PGO names, and 3) it's the next natural choice once "\00"
is discarded (that one's overloaded).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264587 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 15:52:08 +00:00
Vedant Kumar
ab3787a574 [Coverage] Strip <unknown> from PGO names if no filenames are available
Patch suggested by David Li!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264586 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 15:49:08 +00:00
Vedant Kumar
9c51ac3626 [Coverage] Fix the way we load "<unknown>:func" records
When emitting coverage mappings for functions with local linkage and an
unknown filename, we use "<unknown>:func" for the PGO function name. The
problem is that we don't strip "<unknown>" from the name when loading
coverage data, like we do for other file names. Fix that and add a test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264559 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 01:16:12 +00:00
Xinliang David Li
082ab5fb03 Variable name cleanup /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263666 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-16 22:13:41 +00:00
Vedant Kumar
4e25daf577 [ProfileData] Make a utility method public, NFC
The swift frontend needs to be able to look up PGO function name
variables based on the original raw function name. That's because it's
not possible to create PGO function name variables while emitting swift
IR. Instead, we have to create the name variables while lowering swift
IR to llvm IR, at which point we fix up all calls to the increment
intrinsic to point to the right name variable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263662 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-16 20:49:26 +00:00
Teresa Johnson
54d058ed76 Move global ID computation from Function to GlobalValue (NFC)
Since the static getGlobalIdentifier and getGUID methods are now called
for global values other than functions, reflect that by moving these
methods to the GlobalValue class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263524 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-15 02:13:19 +00:00
Dehao Chen
5c299caf16 Use LineLocation instead of CallsiteLocation to index callsite profile.
Summary: With discriminator, LineLocation can uniquely identify a callsite without the need to specifying callee name. Remove Callee function name from the key, and put it in the value (FunctionSamples).

Reviewers: davidxl, dnovillo

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262634 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-03 18:09:32 +00:00
David Blaikie
d93c63989b Fix some warnings a bit harder/different
This is an alternate fix to 262378 and a fix to a pessimizing-move
warning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262390 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-01 20:41:17 +00:00
Reid Kleckner
ecaa1e76a7 Fix -Wnon-virtual-dtor warnings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262378 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-01 19:39:54 +00:00
Easwaran Raman
88e8bafbd5 Fix breakage caused by r262360.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262363 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-01 18:59:11 +00:00
Easwaran Raman
1283c1d7af Metadata support for profile summary.
This adds support to convert ProfileSummary object to Metadata and create a
ProfileSummary object from metadata. This would allow attaching profile summary
information to Module allowing optimization passes to use it.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262360 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-01 18:30:58 +00:00
Dehao Chen
5261d1373d Add prefix based function layout when profile is available.
Summary: If a function is hot, put it in text.hot section.

Reviewers: davidxl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261607 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-23 03:39:24 +00:00
Duncan P. N. Exon Smith
d6f29696e2 Revert "Add prefix based function layout when profile is available."
This reverts commit r261582, since this bot has been broken for four
hours:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/19399/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-23 02:28:40 +00:00
Dehao Chen
c1ae1f5b84 Add prefix based function layout when profile is available.
Summary: If a function is hot, put it in text.hot section.

Reviewers: davidxl

Subscribers: eraman, mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261582 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-22 22:14:14 +00:00
Easwaran Raman
448784058c Add profile summary support for sample profile.
Differential Revision: http://reviews.llvm.org/D17178



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261304 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-19 03:15:33 +00:00
Easwaran Raman
233e7d3773 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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261119 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-17 18:18:47 +00:00
Rong Xu
2ee5bb8ea1 [PGO] Add another interface for annotateValueSite
Add another interface to function annotateValueSite() which directly uses the
VauleData array.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260741 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-12 21:36:17 +00:00
Rong Xu
2465700839 [PGO] Make the number of records for each value site metada adjustable
The patch adds a parameter in annotateValueSite() to control the max number
of records written to the value profile meta data for each value site. The
default is kept as the current value of 3.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260450 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-10 22:19:43 +00:00
Rong Xu
c7d7fb02f4 [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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260385 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-10 17:18:30 +00:00
Teresa Johnson
9ac7dceace Refactor PGO function naming and MD5 hashing support out of ProfileData
Summary:
Move the function renaming logic into the Function class, and the
MD5Hash routine into the MD5 header.

This will enable these routines to be shared with ThinLTO, which
will be changed to store the MD5 hash instead of full function name
in the combined index for significant size reductions. And using the same
function naming for locals in the function index facilitates future
integration with indirect call value profiles.

Reviewers: davidxl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260197 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-09 05:12:44 +00:00
Rong Xu
aab8d7f3e3 [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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260170 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-08 23:11:16 +00:00
Rong Xu
c9a01773b0 [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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260146 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-08 21:07:46 +00:00
Xinliang David Li
04638a608b [PGO] Enable compression in pgo instrumentation
This reduces sizes of instrumented object files, final binaries,
process images, and raw profile data.

The format of the indexed profile data remain the same.

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





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260117 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-08 18:13:49 +00:00
Benjamin Kramer
4ab360d3cc Move classes defined in a cpp file into an anonymous namespace.
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259883 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-05 13:50:53 +00:00
Xinliang David Li
51000e37d1 Function name change /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259851 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-04 23:59:09 +00:00
Easwaran Raman
4bf45e8313 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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259846 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-04 23:34:31 +00:00
Xinliang David Li
f45c13d3a1 [PGO] Add interfaces to annotate instr with VP data
Add interfaces to do value profile data IR annnotation
  and read. Needed by both FE and IR based PGO.





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259813 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-04 19:11:43 +00:00
Xinliang David Li
730d9343ca [PGO] Profile interface cleanup
- Remove unused valuemapper parameter
  - add totalcount optional parameter





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259756 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-04 05:29:51 +00:00
Xinliang David Li
916e1f1bd4 Fix a typo in comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259631 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-03 06:24:11 +00:00
Xinliang David Li
42800d1361 Fix uninitiazed variable use problem
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259630 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-03 06:23:16 +00:00
Xinliang David Li
8fd9cfb481 [PGO] Profile summary reader/writer support
With this patch, the profile summary data will be available in indexed
profile data file so that profiler reader/compiler optimizer can start
to make use of.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259626 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-03 04:08:18 +00:00
Vedant Kumar
0c94d7d441 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259258 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-29 22:54:45 +00:00
Yaron Keren
55307987a1 Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment.
clang part in r259232, this is the LLVM part of the patch.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259240 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-29 20:50:44 +00:00
Xinliang David Li
5b815438f1 [PGO] allow pgo name collector to disable compression (for testing)/NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258876 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26 23:13:00 +00:00
Chris Bieneman
caeade4234 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258861 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26 21:29:08 +00:00
Eugene Zelenko
51ecde1f0a Fix Clang-tidy modernize-use-nullptr and modernize-use-override warnings; other minor fixes.
Differential revision: reviews.llvm.org/D16568


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258831 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26 18:48:36 +00:00
Xinliang David Li
5c32749d7b [PGO] Remove use of static variable. /NFC
Make the variable a member of  the writer trait object owned
now by the writer. Also use a different generator interface
to pass the infoObject from the writer. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258544 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 20:25:56 +00:00
Xinliang David Li
8c37fa8006 Revert 258486 -- for a better fix coming soon
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258538 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 19:53:31 +00:00
Xinliang David Li
860ed4e8ad [PGO] eliminate use of static variable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258486 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 05:48:40 +00:00
Xinliang David Li
6d3068a6fb [PGO] Add a new interface to be used by Indirect Call Promotion
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258271 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-20 01:26:34 +00:00
Xinliang David Li
306bcccc42 Fix a coverage reading bug
function record pointer is not advanced when
duplicate entry is found.

Test case to be added.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258188 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-19 21:18:12 +00:00
Xinliang David Li
b54fac2787 [Coverage] move a local var to be BinaryCoverageReader's member
The symtab is logically referenced beyond the call to the create
method. This changes makes sure its lifetime matches that of
the reader.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258036 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-18 06:48:01 +00:00
Xinliang David Li
f223b5182f Fix -Wmismatched-tags warning/error
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257924 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-15 19:22:41 +00:00
Xinliang David Li
48b8a6c6a9 [PGO] Commonize (more) index profile file and buffer writer.
The file and buffer writer code are mostly shared except for the
stream back-patching. This is because raw_string_ostream does not
support seek like interface. The result is that the data patching
code needs to be pushed to the caller which is not quite readable 
(passing around offset, value etc). This also makes future enhancement
(which needs more patching) more difficult (and can make impl messy).

In this patch, two types of streams needed by the writer are now
unified with same set of interfaces under ProfOStream class. The patch
method is added so that common implementation becomes cleaner. It
also enables future enhancement. Should be NFC.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257921 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-15 19:01:04 +00:00
Xinliang David Li
fc8577b821 [PGO] Move profile summary interface/impl into InstrProf.[*] /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257819 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-14 22:10:49 +00:00
Xinliang David Li
183e87ecde Rename local variable to avoid conflict
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257748 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-14 06:38:52 +00:00
Xinliang David Li
94d8cb3cbf Cleanup: shorten prefix to consistent with other decls /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257744 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-14 06:21:25 +00:00
Xinliang David Li
5fd06e2add [PGO] clean up and documentation
Introduce enum for indexed format versions and 
document indexed format change history.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257737 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-14 02:47:01 +00:00
Xinliang David Li
a4ccbcef22 Add virtual dtor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257734 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-14 02:10:49 +00:00
Xinliang David Li
8a0c782515 [Coverage] introduce class hierarchy (funcRecordReader) to support multiple versions of coverage data
[resubmit after fixing build bot failures: qualify make_unique and eliminate -Wcovered-switch-default warning.
With the planned size reduction change, the coverage format version is expected to be bumped up. This patch adds necessary support such that backward compatibility can be kept with maximal code sharing. Reading different versions of coverage data just requires instantiating the reader according to the version.

No functional change is intended.

Differiential Revision: http://reviews.llvm.org/D16133


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257708 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 23:29:33 +00:00
Xinliang David Li
0d31a22edd Revert r257699 -- windows buildbot failure TBI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257703 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 23:12:53 +00:00
Xinliang David Li
b68354f729 [Coverage] introduce class hierarchy (funcRecordReader) to support multiple versions of coverage data
With the planned size reduction change, the coverage format version is expected to be bumped up. This patch adds necessary support such that backward compatibility can be kept with maximal code sharing. Reading different versions of coverage data just requires instantiating the reader according to the version.

No functional change is intended.

Differiential Revision: http://reviews.llvm.org/D16133


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257699 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 22:58:42 +00:00
Xinliang David Li
561f3680a1 [Coverage] Refactor coverage mapping reader code
(Resubmit after fixing a typo that breaks test on big endian 
 machines)

In this refactoring, member functions are introduced to access
CovMap header/func record members and hide layout details. This
will enable further code restructuring to support reading multiple
versions of coverage mapping data with shared/templatized code. 
(When coveremap format version changes, backward compatibtility
should be preserved).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257571 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 04:36:15 +00:00
Xinliang David Li
805ea32835 Rollback r257551 -- unexpected test failures TBI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257564 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 02:46:40 +00:00
Xinliang David Li
2c77694774 [Coverage] Refactor coverage mapping reader code /NFC
(Resubmit after fixing build bot failures)

In this refactoring, member functions are introduced to access
CovMap header/func record members and hide layout details. This
will enable further code restructuring to support reading multiple
versions of coverage mapping data with shared/templatized code. 
(When coveremap format version changes, backward compatibtility
should be preserved).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257551 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 00:53:46 +00:00
Xinliang David Li
913815ec02 Rollback r257547 -- buildbot failure TBI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257549 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 00:27:24 +00:00
Xinliang David Li
084942c12e [Coverage] Refactor coverage mapping reader code /NFC
In this refactoring, member functions are introduced to access
CovMap header/func record members and hide layout details. This
will enable further code restructuring to support reading multiple
versions of coverage mapping data with shared/templatized code. 
(When coveremap format version changes, backward compatibtility
should be preserved).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257547 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 00:16:43 +00:00
Nathan Slingerland
21314fb768 [Support] Add saturating multiply-add support function
Summary: Add SaturatingMultiplyAdd convenience function template since A + (X * Y) comes up frequently when doing weighted arithmetic.

Reviewers: davidxl, silvas

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257532 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-12 22:34:00 +00:00
Xinliang David Li
66a4a1fe87 Move coveragemap_error enum into coverage namespace and InstrProf.h /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257295 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-10 21:56:33 +00:00
Xinliang David Li
36838feb74 [PGO] Ensure vp data in indexed profile always sorted
Done in  InstrProfWriter to eliminate the need for client
code to do the sorting. The operation is done once and reused 
many times so it is more efficient. Update unit test to remove
sorting. Also update expected output of affected tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257145 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-08 05:45:21 +00:00
Xinliang David Li
4f87d1237a [PGO] Fix a bug in InstProfWriter addRecord
For a new record with weight != 1, only edge profiling
counters are scaled, VP data is not properly scaled.

This patch refactors the code and fixes the problem.
Also added sort by count interface (for follow up patch).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257143 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-08 03:49:59 +00:00
Xinliang David Li
dcf208db21 [PGO] Minor refactoring /NFC
Move common defs into common header files.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257108 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-07 22:46:29 +00:00
Xinliang David Li
cc6a69d0c0 [PGO] Simplify string parsing
Patch Suggested by Vedant.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256785 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-04 22:09:26 +00:00
Xinliang David Li
d8ecf86295 [PGO] Refactor string writer code
For readability and code sharing.
(Adapted from Suggestions by Vedant).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256784 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-04 22:01:02 +00:00
Xinliang David Li
8abd63fcbb [PGO]: Use efficient 'join' API for uncompressed string
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256781 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-04 21:31:09 +00:00
Xinliang David Li
1de675f473 [PGO]: reserve space for string to avoid excessive memory realloc/copy (non linear)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256776 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-04 20:26:05 +00:00
Xinliang David Li
6922bab653 [PGO] Code refactoring to use header struct def /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256712 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-03 18:57:40 +00:00
Xinliang David Li
0620569576 [PGO] simple refactoring (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256695 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-03 04:38:13 +00:00
Xinliang David Li
f2f39d6f7b [PGO]: Implement Func PGO name string compression
This is part of the effort/prepration to reduce the size
instr-pgo (object, binary, memory footprint, and raw data).

The functionality is currently off by default and not yet
used by any clients.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256667 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-31 07:57:16 +00:00
Benjamin Kramer
8f447cb9c3 [ProfileData] Make helper function static.
No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256375 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-24 10:03:37 +00:00
Xinliang David Li
cb4197f621 Fix a latent UAF bug in profwriter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256116 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-20 08:46:18 +00:00
Xinliang David Li
cfbaf11a0d [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.







git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256114 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-20 06:22:13 +00:00
Xinliang David Li
272ce19ebd Minor clean up -- move large single use method out of header(NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256113 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-20 05:15:45 +00:00
Xinliang David Li
bde8257dd7 [PGO] Cleanup: Move large member functions out of line (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256058 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18 23:06:37 +00:00
Xinliang David Li
5c542537c1 [PGO] Simplify computehash interface (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256047 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18 22:22:12 +00:00
Xinliang David Li
88a450e9e9 [PGO] InstrPGO and coverage code refactoring (NFC)
Introduce a new class InstrProfSymtab to abstract
the PGO symbol table for prof and coverage reader.
The symtab is is to lookup function's PGO name
using function keys. The first user of the class
is CoverageMapping Reader. More will follow.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255862 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-17 00:53:37 +00:00
Nathan Slingerland
fd56824d39 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255825 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-16 21:45:43 +00:00
Xinliang David Li
7284c4e48d Initialize all bytes in vp data (msan error)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255680 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15 21:57:08 +00:00
Xinliang David Li
28aa0a5f68 Coverage code refactoring /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255670 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15 19:44:45 +00:00
Nathan Slingerland
824c3eccff [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255659 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15 17:37:09 +00:00
Xinliang David Li
ea0570fdaf [PGO] Value profiling text format reader/writer support
This patch adds the missing functionality in parsable
text format support for value profiling.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255523 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-14 18:44:01 +00:00
Xinliang David Li
59ef72d321 [PGO] Stop using invalid char in instr variable names.
Before the patch, -fprofile-instr-generate compile will fail
if no integrated-as is specified when the file contains
any static functions (the -S output is also invalid).

This is the second try. The fix in this patch is very localized.
Only profile symbol names of profile symbols with internal 
linkage are fixed up while initializer of name syms are not 
changes. This means there is no format change nor version bump.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255434 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-12 17:28:03 +00:00
Xinliang David Li
d70808f6bb [PGO] Revert r255365: solution incomplete, not handling lambda yet
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255369 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-11 20:23:22 +00:00
Xinliang David Li
b6b389aaac [PGO] Stop using invalid char in instr variable names.
Before the patch, -fprofile-instr-generate compile will fail
if no integrated-as is specified when the file contains
any static functions (the -S output is also invalid).

This patch fixed the issue. With the change, the index format
version will be bumped up by 1. Backward compatibility is 
preserved with this change.

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




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255365 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-11 19:53:19 +00:00
Xinliang David Li
6f139ce20b [PGO] Read VP raw data without depending on the Value field
Before this patch, each function's on-disk VP data is 'pointed'
to by the Value field of per-function ProfileData structue, and 
read relies on this field (relocated with ValueDataDelta field)
to read the value data. However this means the Value field needs
to be updated during runtime before dumping, which creates undesirable
data races.

With this patch, the reading of VP data no longer depends on Value
field. There is no format change. ValueDataDelta header field becomes
obsolute but will be kept for compatibility reason (will be removed
next time the raw format change is needed).





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255329 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-11 06:53:53 +00:00
Vedant Kumar
88b8ce2202 [ProfileData] clang-format TextInstrProfReader::hasFormat. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255317 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-11 00:40:05 +00:00
Xinliang David Li
849df7927e Format fix (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255313 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-10 23:48:05 +00:00
Nathan Slingerland
46cf0f07dc [ProfileData] Add unit test infrastructure for sample profile reader/writer
Summary:
Adds support for in-memory round-trip of sample profile data along with basic
round trip unit tests. This will also make it easier to include unit tests for
future changes to sample profiling.

Reviewers: davidxl, dnovillo, silvas

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255264 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-10 17:21:42 +00:00
Xinliang David Li
a8bc4db3b2 [PGO] Add version to getPGOFuncName method
Different version of indexed format may use different
name uniquing schemes for static functions. Pass the
version info to the name interface so that different
schmes can be picked (for profile lookup).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254838 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-05 05:16:36 +00:00
Nathan Slingerland
8061fe5c67 Revert "[llvm-profdata] Add support for weighted merge of profile data"
This reverts commit b7250858d9.

Reverting in order to investigate Windows test failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254687 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-04 02:13:58 +00:00
Xinliang David Li
7579d3aaed [PGO] Unify VP data format between raw and indexed profile (Reader)
With the latest refactoring and code sharing patches landed, 
it is possible to unify the value profile implementation between
raw and indexed profile. This is the patch in raw profile reader 
that uses the common interface. 

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254677 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-04 01:02:10 +00:00
Nathan Slingerland
b7250858d9 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254669 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-04 00:00:20 +00:00
Nathan Slingerland
1c2b998913 [llvm-profdata] Change instr prof counter overflow to saturate rather than discard
Summary: This changes overflow handling during instrumentation profile merge. Rathar than throwing away records that would result in counter overflow, merged counts are instead clamped to the maximum representable value. A warning about counter overflow is still surfaced to the user as before.

Reviewers: dnovillo, davidxl, silvas

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254525 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-02 18:19:24 +00:00
Xinliang David Li
d89494bf03 [PGO] Add support for reading multiple versions of indexed profile format profile data
Profile readers using incompatible on-disk hash table format can now share the same 
implementation and interfaces. 

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254458 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-01 20:26:26 +00:00
Xinliang David Li
67b32b2810 Use nullptr (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254447 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-01 19:47:32 +00:00
Xinliang David Li
ea177884e9 [PGO] Move value profile format related structures and APIs to common file
This is the last step to enable profile runtime to share the same value prof
data format and reader/writer code with llvm host tools. The VP related 
data structures are moved to a section in InstrProfData.inc enabled with macro
INSTR_PROF_VALUE_PROF_DATA, and common API implementations are enabled with
INSTR_PROF_COMMON_API_IMPL. There should be no functional change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254235 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-28 19:07:09 +00:00
Xinliang David Li
feed6dbc9f [PGO] Add return code for vp rt record init routine to indicate error condition
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254220 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-28 05:47:34 +00:00
Xinliang David Li
9bee4a8249 [PGO] Allow value profile writer interface to allocated target buffer
Raw profile writer needs to write all data of one kind in one continuous block,
so the buffer needs to be pre-allocated and passed to the writer method in
pieces for function profile data. The change adds the support for raw value data
writing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254219 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-28 05:37:01 +00:00
Xinliang David Li
52a156fb30 Function name cleanup (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254218 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-28 05:06:00 +00:00
Xinliang David Li
170357c9b7 [PGO] Extract VP data integrity check code into a helper function (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254217 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-28 04:56:07 +00:00
Xinliang David Li
931217997c [PGO] Implement ValueProfiling Closure interfaces for runtime value profile data
This is one of the many steps to commonize value profiling support between profile
runtime and compiler/llvm tools.

After this change, profiler runtime now can share the same C APIs to do VP
serialization/deseriazation with LLVM host tools (and produces value data
in identical format between indexed and raw profile).

It is not yet enabled in profiler runtime yet.

Also added a unit test case to test runtime profile data serialization/deserialization
interfaces implemented using common closure code.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254110 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-25 23:31:18 +00:00
Xinliang David Li
f722f529e7 [PGO] Regroup functions in better order (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254080 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-25 19:13:00 +00:00
Xinliang David Li
72f9544cc0 [PGO] Convert InstrProfRecord based serialization methods to use common C methods
1. Convert serialization methods using InstrProfRecord as source into C (impl)
   interfaces using Closure.
2. Reimplement InstrProfRecord serialization method to use new C interface
   as dummy wrapper. 

Now it is ready to implement wrapper for runtime value profile data.

(The new code need better source location -- but not changed in this patch to
 minimize diffs. )



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254057 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-25 06:23:38 +00:00
Xinliang David Li
8fc17088bb [PGO] convert a subset of C++ interfaces into C (for sharing) (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254056 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-25 04:29:24 +00:00
Xinliang David Li
059b6b4a21 Move member functions closer to others of the same class (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254055 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-25 03:24:37 +00:00
Xinliang David Li
5c7d512e13 Fix function naming (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254045 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-25 00:08:49 +00:00
Xinliang David Li
7de0a38604 [PGO] Add mapper callback to interfaces retrieving value data for site (NFC)
This allows cleaner implementation and merging retrieving/mapping in
one pass.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254038 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-24 23:36:52 +00:00
Xinliang David Li
1386907d27 [PGO] Small interface change to be profile rt ready
Convert two C++ static member functions to be C APIs. This
is one of the many steps to get ready to share VP writer code
with profiler runtime. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253999 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-24 18:15:46 +00:00
Xinliang David Li
019c78a994 Minor refactor to make VP writing more efficient
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253994 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-24 17:03:24 +00:00
Xinliang David Li
54daffcbaa [PGO] In llvm-profdata text dump, add comment lines as annotations
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253930 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-23 22:31:22 +00:00
Xinliang David Li
55f78334c1 [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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253913 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-23 20:47:38 +00:00
Reid Kleckner
368c7cb1bd Fix the Windows build, include <tuple> for std::tie
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253698 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20 19:29:40 +00:00
Nathan Slingerland
e0a7f28fc6 [llvm-profdata] Add merge() to InstrProfRecord
Summary:
This change refactors two aspects of InstrProfRecord:

1) Add a merge() method to InstrProfRecord (previously InstrProfWriter combineInstrProfRecords()) in order to better encapsulate this functionality and to make the InstrProfRecord and SampleRecord APIs more consistent.

2) Make InstrProfRecord mergeValueProfData() a private method since it is only ever called internally by merge().

Reviewers: dnovillo, bogner, davidxl

Subscribers: silvas, vsk, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253695 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20 19:12:43 +00:00
Diego Novillo
8003b38f27 SamplePGO - Tweak debugging output for function samples. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253612 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-19 22:18:30 +00:00
Diego Novillo
5d8ee1bd0d SamplePGO - Sort samples by source location when emitting as text.
When dumping function samples or writing them out as text format, it
helps if the samples are emitted sorted by source location. The sorting
of the maps is a bit slow, so we only do it on demand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253568 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-19 15:33:08 +00:00
Xinliang David Li
2d31815e4b Minor cleanups (from review feedback)
1. remove uneeded header inclusion
2. use reinterpret_cast instead of c ctyle
3. other format change


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253515 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-18 22:42:27 +00:00
Betul Buyukkurt
a5be9e3cfb [PGO] Value profiling support
This change introduces an instrumentation intrinsic instruction for
value profiling purposes, the lowering of the instrumentation intrinsic
and raw reader updates. The raw profile data files for llvm-profdata
testing are updated.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253484 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-18 18:14:55 +00:00
Xinliang David Li
e34401de05 [PGO] Move value profile data definitions out of IndexedInstrProf
Move the data structure defintions out of the namespace. The defs will
be shared by raw format. [NFC]



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253394 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17 23:00:40 +00:00
Nathan Slingerland
0833ccb526 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253384 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17 22:08:53 +00:00
Diego Novillo
64725c314d SamplePGO - Move debug/dump function bodies out of header files. NFC.
No point polluting the header declarations with debugging code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253361 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17 19:04:46 +00:00
Xinliang David Li
4d60f67763 Fix unaligned memory read issue exposed by ubsan
Indexed profile data as designed today does not guarantee
counter data to be well aligned, so reading needs to use
the slower form (with memcpy). This is less than ideal and 
should be improved in the future (i.e., with fixed length
function key instead of variable length name key).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253309 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17 03:47:21 +00:00
Diego Novillo
dbe26eba86 SamplePGO - Add dump routines for LineLocation, SampleRecord and FunctionSamples
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253071 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-13 20:24:28 +00:00
Nathan Slingerland
572e633224 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253009 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-13 03:47:58 +00:00
Nathan Slingerland
69c9ea3b39 reverting r252916 to investigate test failure
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252921 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12 18:39:26 +00:00
Nathan Slingerland
7b81b822ba [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252916 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12 18:06:18 +00:00
Diego Novillo
7e02753319 SamplePGO - Move FunctionSamples::print() to a better location. NFC.
The class is declared in SampleProf.h, so a better home for this is
SampleProf.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252915 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12 17:58:14 +00:00
Xinliang David Li
a8ea67eb80 Fix problems in coding style
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252829 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12 00:32:17 +00:00
David Blaikie
9650aeb6c8 unique_ptrify the AllocValueProfData helper function introduced in r252783
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252799 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-11 20:44:52 +00:00
Xinliang David Li
3e07540b57 Refactoring and fix another instance of asan error
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252783 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-11 19:31:53 +00:00
Aaron Ballman
88d51ce445 Silencing a signed vs unsigned type mismatch warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252732 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-11 14:57:28 +00:00
Xinliang David Li
69323c693c Fix asan warning (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252617 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-10 17:11:33 +00:00
Xinliang David Li
bcd8e0aae7 [PGO] Make indexed value profile data more compact
- Make indexed value profile data more compact by peeling out 
  the per-site value count field into its own smaller sized array.
- Introduced formal data structure definitions to specify value 
  profile data layout in indexed format. Previously the layout 
  of the data is only assumed in the client code (scattered in 
  three different places : size computation, EmitData, and ReadData
- The new data structure  serves as a central place for layout documentation.
- Add interfaces to force BE output for value profile data (testing purpose)
- Add byte swap unit tests

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252563 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-10 00:24:45 +00:00
Xinliang David Li
ec3b8e9653 [PGO] Instr func name var creation code refactoring
Move the code from cfe to LLMV and become shared interfaces.
There is no functional change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252433 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-09 00:01:22 +00:00
Xinliang David Li
4d774a3941 Code style fix (caused by wrongly default clang-format style) (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252276 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 07:54:21 +00:00
Xinliang David Li
0bf62648ad [PGO] Use template file to define runtime structures
With this change, instrumentation code and reader/write
code related to profile data structs are kept strictly
in-sync. THis will be extended to cfe and compile-rt 
references as well.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252113 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-05 00:47:26 +00:00
Xinliang David Li
61c7e68339 [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). 



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251771 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-02 05:08:23 +00:00
Xinliang David Li
1e668490c0 [PGO] RawProf Reader code cleanup
Add a couple of helper methods to make the primary
raw profile reader interface's implementation more
readable. It also hides more format details. This
patch has no functional change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251546 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28 19:34:04 +00:00
Xinliang David Li
50b691de42 [PGO] Indexed Prof Reader refactoring (NFC)
Change InstrProfReaderIndex from typedef into a wrapper
class with helper methods. This makes the index profile
reader code more readable. It also hides the implementation 
detail of the index format and make it more flexible to allow 
support different (or more than one) format in the future.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251491 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28 04:20:31 +00:00
Xinliang David Li
c417afc098 Add helper functions and remove hard coded references to instProf related name/name-prefixes
This is a clean up patch that defines instr prof section and variable 
name prefixes in a common header with access helper functions. 
clang FE change will be done as a follow up once this patch is in.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251058 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-22 20:32:12 +00:00
Dehao Chen
491ae53e26 Tolerate negative offset when matching sample profile.
In some cases (as illustrated in the unittest), lineno can be less than the heade_lineno because the function body are included from some other files. In this case, offset will be negative. This patch makes clang still able to match the profile to IR in this situation.

http://reviews.llvm.org/D13914



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250873 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-21 01:22:27 +00:00
Xinliang David Li
09717fa07b Minor Instr PGO code restructuring
1. Key constant values (version, magic) and data structures related to raw and 
   indexed profile format are moved into one centralized file: InstrProf.h.
2. Utility function such as MD5Hash computation is also moved to the common 
   header to allow sharing with other components in the future.
3. A header data structure is introduced for Indexed format so that the reader
   and writer can always be in sync.
4. Added some comments to document different places where multiple definition
   of the data structure must be kept in sync (reader/writer, runtime, lowering 
   etc).  No functional change is intended.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250638 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-18 01:02:29 +00:00