Commit Graph

237 Commits

Author SHA1 Message Date
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