1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

344 Commits

Author SHA1 Message Date
Diego Novillo
4fd12b32db Sample profiles - Add documentation for binary profile encoding. NFC.
This adds documentation for the binary profile encoding and moves the
documentation for the text encoding into the header file
SampleProfReader.h.

llvm-svn: 250309
2015-10-14 18:36:30 +00:00
Diego Novillo
5316879830 Sample profile reader - remove dead code. NFC.
This removes old remnants from the gcov reader. I missed these when I
re-wrote it recently.

llvm-svn: 250242
2015-10-13 22:48:48 +00:00
Diego Novillo
c53fb25fe1 Sample profiles - Add a name table to the binary encoding.
Binary encoded profiles used to encode all function names inline at
every reference.  This is clearly suboptimal in terms of space.  This
patch fixes this by adding a name table to the header of the file.

llvm-svn: 250241
2015-10-13 22:48:46 +00:00
Diego Novillo
60beea56a8 Remove unused function in sample profile writer API - NFC.
These functions are not needed and are getting in the way of changes
for implementing a table of contents for the binary format.

llvm-svn: 249907
2015-10-09 21:33:13 +00:00
Diego Novillo
550aed332d Add inline stack streaming to binary sample profiles.
With this patch we can now read and write inline stacks in sample
profiles to the binary encoded profiles.

In a subsequent patch, I will add a string table to the binary encoding.
Right now function names are emitted as strings every time we find them.
This is too bloated and will produce large files in applications with
lots of inlining.

llvm-svn: 249861
2015-10-09 17:54:24 +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
Diego Novillo
cd224d43cd Revert "Handle inline stacks in gcov-encoded sample profiles."
This reverts commit r249644.

The buildbots are failing the new test I added. Investigating.

llvm-svn: 249648
2015-10-08 01:17:26 +00:00
Diego Novillo
87a89a64fa Handle inline stacks in gcov-encoded sample profiles.
This patch adds support for reading sample profiles with inline stacks.
Inline stacks in a profile are generated when the sampled binary has
samples in inlined functions.

For instance, if main() calls foo() and foo() calls bar(), and bar() is
inlined into foo() and foo() inlined into main(), the profile may look
something like:

main total:364084 head:0
  [ ... ]
  2.3: _Z3fool total:243786
    1: 60149
    1.2: 38568
    1.4: 46511
    1.7: _Z3bari total:98558
      1.1: 52672
      1.2: 45886

At line 2, discriminator 3, main() calls foo(). In turn, foo() calls
bar() at line 1, discriminator 7.

In the textual format, this stacking of inline calls is represented
with indentation.

With this change, LLVM can now read sample profile files generated by
the create_gcov tool from https://github.com/google/autofdo.

llvm-svn: 249644
2015-10-08 00:39:11 +00:00
Diego Novillo
4cb50fee06 Remove AutoFDO profile handling for GCC's LIPO. NFC.
Given the work we are doing on ThinLTO, we will never need to support
module groups and working sets in GCC's implementation of LIPO. These
are currently dead code, and will continue to be so.

llvm-svn: 249351
2015-10-05 21:08:05 +00:00
Dehao Chen
ab10674b4f Update sample profile propagation algorithm.
http://reviews.llvm.org/D13218

llvm-svn: 248968
2015-10-01 00:26:56 +00:00
Dehao Chen
0024ada446 http://reviews.llvm.org/D13145
Support hierarachical sample profile format.

llvm-svn: 248865
2015-09-30 00:42:46 +00:00
Justin Bogner
c3ca6cd921 InstrProf: Add a missing const_cast from r248833
llvm-svn: 248859
2015-09-29 23:42:47 +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
Dehao Chen
a883fbf7ee http://reviews.llvm.org/D13231
Change lookup functions to const functions.

llvm-svn: 248818
2015-09-29 18:28:15 +00:00
Craig Topper
e3fc758778 Use makeArrayRef or None to avoid unnecessarily mentioning the ArrayRef type extra times. NFC
llvm-svn: 248140
2015-09-21 05:32:41 +00:00
Diego Novillo
3ccc9d9f6a GCC AutoFDO profile reader - Initial support.
This adds enough machinery to support reading simple GCC AutoFDO
profiles. It now supports reading flat profiles (no function calls).
Subsequent patches will add support for:

- Inlined calls (in particular, the inline call stack is not traversed
  to accumulate samples).

- Working sets and modules. These are used mostly for GCC's LIPO
  optimizations, so they're not needed in LLVM atm. I'm not sure that
  we will ever need them. For now, I've if0'd around the calls.

The patch also adds support in GCOV.h for gcov version V704 (generated
by GCC's profile conversion tool).

llvm-svn: 247874
2015-09-17 00:17:24 +00:00
Benjamin Kramer
69a3fdb314 Fix some comment typos.
llvm-svn: 244402
2015-08-08 18:27:36 +00:00
Justin Bogner
bc637e62b6 Re-apply "InstrProf: When reading, copy the data instead of taking a reference. NFC"
This version fixes a missing include that MSVC noticed and
clarifies the ownership of the counter buffer that's passed to
InstrProfRecord.

This restores r240206, which was reverted in r240208.

Patch by Betul Buyukkurt.

llvm-svn: 240360
2015-06-22 23:58:05 +00:00
Frederic Riss
0c3b9888f7 [Object] Search for architecures by name in MachOUniversalBinary::getObjectForArch()
The reason we need to search by name rather than by Triple::ArchType
is to handle subarchitecture correclty. There is no different ArchType
for the x86_64h architecture (it identifies itself as x86_64), or for
the various ARM subarches. The only way to get to the subarch slice
in an universal binary is to search by name.

This issue led to hard to debug and transient symbolication failures
in Asan tests (it mostly works, because the files are very similar).

This also affects the Profiling infrastucture as it is the other user
of that API.

Reviewers: samsonov, bogner

Subscribers: llvm-commits

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

llvm-svn: 240339
2015-06-22 21:33:24 +00:00
Justin Bogner
5391d5c278 Revert "InstrProf: When reading, copy the data instead of taking a reference. NFC"
Seems like MSVC doesn't like this:

  InstrProf.h(49) : error C2614: 'llvm::InstrProfRecord' : illegal member initialization: 'Hash' is not a base or member

This reverts r240206.

llvm-svn: 240208
2015-06-20 01:37:56 +00:00
Justin Bogner
f4084a2560 InstrProf: When reading, copy the data instead of taking a reference. NFC
This consolidates the logic to read instrprof records into the on disk
hash table's lookup trait and makes us copy the counter data instead
of taking references to it as we read. This will simplify further
changes to the format.

Patch by Betul Buyukkurt.

llvm-svn: 240206
2015-06-20 01:26:04 +00:00
Diego Novillo
501a284115 Tidy comments in SampleProfile header. NFC.
llvm-svn: 237197
2015-05-12 22:03:00 +00:00
Justin Bogner
aa99b531f2 InstrProf: Give coverage its own errors instead of piggy backing on instrprof
Since the coverage mapping reader and the instrprof reader were
emitting a shared set of error codes, the error messages you'd get
back from llvm-cov were ambiguous about what was actually wrong. Add
another error category to fix this.

I've also improved the wording on a couple of the instrprof errors,
for consistency.

llvm-svn: 236665
2015-05-06 23:19:35 +00:00
Justin Bogner
a01489eaf6 InstrProf: Remove a function that just returns its argument (NFC)
llvm-svn: 236664
2015-05-06 23:15:55 +00:00
Justin Bogner
ba70a38423 InstrProf: Teach llvm-cov to handle universal binaries when given -arch
llvm-svn: 231902
2015-03-11 02:30:51 +00:00
Benjamin Kramer
19bb0a5bca Add another missing header that used to be included transitively.
llvm-svn: 230927
2015-03-02 01:08:07 +00:00
Justin Bogner
a0537de57c InstrProf: Simplify the construction of BinaryCoverageReader
Creating BinaryCoverageReader is a strange and complicated dance where
the constructor sets error codes that member functions will later
read, and the object is in an invalid state if readHeader isn't
immediately called after construction.

Instead, make the constructor private and add a static create method
to do the construction properly. This also has the benefit of removing
readHeader completely and simplifying the interface of the object.

llvm-svn: 230676
2015-02-26 20:06:28 +00:00
Justin Bogner
fd3c2961be InstrProf: Rename ObjectFileCoverageMappingReader to BinaryCoverageReader
The current name is long and confusing. A shorter one is both easier
to understand and easier to work with.

llvm-svn: 230675
2015-02-26 20:06:24 +00:00
Justin Bogner
2218fa75da InstrProf: Remove dead code in CoverageMappingReader
Remove a default argument that's never passed and a constructor that's
never called.

llvm-svn: 230563
2015-02-25 22:44:50 +00:00
Justin Bogner
8ab6d199d1 InstrProf: Handle unknown functions if they consist only of zero-regions
This comes up when we generate coverage for a function but don't end
up emitting the function at all - dead static functions or inline
functions that aren't referenced in a particular TU, for example. In
these cases we'd like to show that the function was never called,
which is trivially true.

llvm-svn: 229717
2015-02-18 18:40:46 +00:00
Justin Bogner
dfdc3baaba InstrProf: Make CoverageMapping testable and add a basic unit test
Make CoverageMapping easier to create, so that we can write targeted
unit tests for its internals, and add a some infrastructure to write
these tests. Finally, add a simple unit test for basic functionality.

llvm-svn: 229709
2015-02-18 18:01:14 +00:00
Justin Bogner
a033796bf5 Re-apply "InstrProf: Add unit tests for the profile reader and writer"
Have the InstrProfWriter return a MemoryBuffer instead of a
std::string. This fixes the alignment issues the reader would hit, and
it's a more appropriate type for this anyway.

I've also removed an ugly helper function that's not needed since
we're allowing initializer lists now, and updated some error code
checks based on MSVC's issues with r229473.

This reverts r229483, reapplying r229478.

llvm-svn: 229602
2015-02-18 01:58:17 +00:00
Justin Bogner
892964de44 Revert "InstrProf: Add unit tests for the profile reader and writer"
This added API to the InstrProfWriter to write to a string so I could
write unittests without using temp files. This doesn't really work,
since the format has tighter alignment requirements than a char.

This reverts r229478 and its follow-up, r229481.

llvm-svn: 229483
2015-02-17 09:21:43 +00:00
Justin Bogner
5a941203c6 Re-apply "InstrProf: Add unit tests for the profile reader and writer"
Add these tests again, but use va_list instead of initializer lists.

This reverts r229456, reapplying r229455.

llvm-svn: 229478
2015-02-17 07:50:59 +00:00
Justin Bogner
7e3c504766 Revert "InstrProf: Add unit tests for the profile reader and writer"
Looks like the bots don't like my initializer lists.

This reverts r229455

llvm-svn: 229456
2015-02-16 23:31:07 +00:00
Justin Bogner
116967eecd InstrProf: Add unit tests for the profile reader and writer
This required some minor API to be added to these types to avoid
needing temp files.

Also, I've used initializer lists in the tests, as MSVC 2013 claims to
support them. I'll redo this without them if the bots complain.

llvm-svn: 229455
2015-02-16 23:27:48 +00:00
Justin Bogner
bb1f720b6c InstrProf: Use ErrorOr for IndexedInstrProfReader::create (NFC)
The other InstrProfReader::create factories were updated to return
ErrorOr in r221120, and it's odd for these APIs not to match.

llvm-svn: 229433
2015-02-16 21:28:58 +00:00
Aaron Ballman
0b45511a2e Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition.
llvm-svn: 229340
2015-02-15 22:54:22 +00:00
Justin Bogner
620c405abf InstrProf: Make CounterMappingRegions less confusing to construct
Creating empty and expansion regions is awkward with the current API.
Expose static methods to make this simpler.

llvm-svn: 228075
2015-02-03 23:59:33 +00:00
Justin Bogner
84c1a035e8 InstrProf: Remove CoverageMapping::HasCodeBefore, it isn't used
It's not entirely clear to me what this field was meant for, but it's
always false. Remove it.

llvm-svn: 228034
2015-02-03 21:35:36 +00:00
Justin Bogner
67c8b5392c InstrProf: Simplify RawCoverageMappingReader's API slightly
This is still kind of a weird API, but dropping the (partial) update
of the passed in CoverageMappingRecord makes it a little easier to
understand and use.

llvm-svn: 227900
2015-02-03 00:20:11 +00:00
Justin Bogner
4f542cbac2 InstrProf: Add operator!= to coverage counters
I'll use this in clang shortly. Also makes the operator definition
style more consistent in this class.

llvm-svn: 227018
2015-01-24 21:13:23 +00:00
Justin Bogner
2bfe2d33c6 InstrProf: debug dumps should go to dbgs(), not outs()
llvm-svn: 226964
2015-01-23 23:28:30 +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
Justin Bogner
8365fe2ec3 llvm-cov: Sink some reporting logic into CoverageMapping
This teaches CoverageMapping::getCoveredFunctions to filter to a
particular file and uses that to replace most of the logic found in
llvm-cov report.

llvm-svn: 221962
2014-11-14 01:50:32 +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
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
Diego Novillo
cf4c21ac5d Fix comment spelling and tidy diagnostic call in profile reader.
No functional changes.

llvm-svn: 220922
2014-10-30 20:19:19 +00:00
Diego Novillo
a5ff3524ec Add profile writing capabilities for sampling profiles.
Summary:
This patch finishes up support for handling sampling profiles in both
text and binary formats. The new binary format uses uleb128 encoding to
represent numeric values. This makes profiles files about 25% smaller.

The profile writer class can write profiles in the existing text and the
new binary format. In subsequent patches, I will add the capability to
read (and perhaps write) profiles in the gcov format used by GCC.

Additionally, I will be adding support in llvm-profdata to manipulate
sampling profiles.

There was a bit of refactoring needed to separate some code that was in
the reader files, but is actually common to both the reader and writer.

The new test checks that reading the same profile encoded as text or
raw, produces the same results.

Reviewers: bogner, dexonsmith

Subscribers: llvm-commits

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

llvm-svn: 220915
2014-10-30 18:00:06 +00:00
Justin Bogner
2d6abf2acf InstrProf: Avoid linear search in a hot loop
Every time we were adding or removing an expression when generating a
coverage mapping we were doing a linear search to try and deduplicate
the list. The indices in the list are important, so we can't just
replace it by a DenseMap entirely, but an auxilliary DenseMap for fast
lookup massively improves the performance issues I was seeing here.

llvm-svn: 218892
2014-10-02 17:14:18 +00:00
Justin Bogner
3fc53772d2 Reapply "InstrProf: Don't keep a large sparse list around just to zero it"
When I was preparing r218879 for commit, I removed an early return
that I decided was just noise. It wasn't. This is r218879 no-crash
edition.

This reverts commit r218881, reapplying r218879.

llvm-svn: 218887
2014-10-02 16:43:31 +00:00
Justin Bogner
802732f427 Revert "InstrProf: Don't keep a large sparse list around just to zero it"
This seems to be crashing on some buildbots. Reverting to investigate.

This reverts commit r218879.

llvm-svn: 218881
2014-10-02 16:15:27 +00:00
Justin Bogner
7cb2c316a5 InstrProf: Don't keep a large sparse list around just to zero it
The Terms vector here represented a polynomial of of all possible
counters, and is used to simplify expressions when generating coverage
mapping. There are a few problems with this:

1. Keeping the vector as a member is wasteful, since we clear it every
   time we use it.
2. Most expressions refer to a subset of the counters, so we end up
   iterating over a large number of zeros doing nothing a lot of the
   time.

This updates the user of the vector to store the terms locally, and
uses a sort and combine approach so that we only operate on counters
that are actually used in a given expression. For small cases this
makes very little difference, but in cases with a very large number of
counted regions this is a significant performance fix.

llvm-svn: 218879
2014-10-02 16:04:03 +00:00
Justin Bogner
4ceb3df28e InstrProf: Make coverage::Counter comparable
I'll be using this in a clang change very soon.

llvm-svn: 218736
2014-10-01 03:31:58 +00:00
Alex Lorenz
5990711e78 llvm-cov: Use the number of executed functions for the function coverage metric.
This commit fixes llvm-cov's function coverage metric by using the number of executed functions instead of the number of fully covered functions.

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

llvm-svn: 218672
2014-09-30 12:45:13 +00:00
Justin Bogner
a18cefcbb1 llvm-cov: Combine segments that cover the same location
If we have multiple coverage counts for the same segment, we need to
add them up rather than arbitrarily choosing one. This fixes that and
adds a test with template instantiations to exercise it.

llvm-svn: 218432
2014-09-25 00:34:18 +00:00
Justin Bogner
38cb80c7b7 llvm-cov: Allow creating CoverageMappings from filenames
llvm-svn: 218185
2014-09-20 17:19:52 +00:00
Justin Bogner
521deeff36 llvm-cov: Disentangle the coverage data logic from the display (NFC)
This splits the logic for actually looking up coverage information
from the logic that displays it. These were tangled rather thoroughly
so this change is a bit large, but it mostly consists of moving things
around. The coverage lookup logic itself now lives in the library,
rather than being spread between the library and the tool.

llvm-svn: 218184
2014-09-20 15:31:56 +00:00
Justin Bogner
46a2bb923b LineIterator: Provide a variant that keeps blank lines
It isn't always useful to skip blank lines, as evidenced by the
somewhat awkward use of line_iterator in llvm-cov. This adds a knob to
control whether or not to skip blanks.

llvm-svn: 217960
2014-09-17 15:43:01 +00:00
Justin Bogner
4bb118ab83 llvm-cov: Simplify CounterMappingRegion, pushing logic to its user
A single function in SourceCoverageDataManager was the only user of
some of the comparisons in CounterMappingRegion, and at this point we
know that only one file is relevant. This lets us use slightly simpler
logic directly in the client.

llvm-svn: 217745
2014-09-15 03:41:01 +00:00
Justin Bogner
50f453be5f llvm-cov: Move FunctionCoverageMapping into CoverageMapping.h (NFC)
llvm-svn: 217657
2014-09-12 06:52:44 +00:00
Diego Novillo
db1c3903c1 Re-factor sample profile reader into lib/ProfileData.
Summary:
This patch moves the profile reading logic out of the Sample Profile
transformation into a generic profile reader facility in
lib/ProfileData.

The intent is to use this new reader to implement a sample profile
reader/writer that can be used to convert sample profiles from external
sources into LLVM.

This first patch introduces no functional changes. It moves the profile
reading code from lib/Transforms/SampleProfile.cpp into
lib/ProfileData/SampleProfReader.cpp.

In subsequent patches I will:

- Add a bitcode format for sample profiles to allow for more efficient
  encoding of the profile.
- Add a writer for both text and bitcode format profiles.
- Add a 'convert' command to llvm-profdata to be able to convert between
  the two (and serve as entry point for other sample profile formats).

Reviewers: bogner, echristo

Subscribers: llvm-commits

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

llvm-svn: 217437
2014-09-09 12:40:50 +00:00
Justin Bogner
951fd60695 llvm-cov: Combine two types that were nearly identical (NFC)
llvm-cov had a SourceRange type that was nearly identical to a
CountedRegion except that it shaved off a couple of fields. There
aren't likely to be enough of these for the minor memory savings to be
worth the extra complexity here.

llvm-svn: 217417
2014-09-09 05:32:18 +00:00
Justin Bogner
8f071790c7 llvm-cov: Rename MappingRegion to coverage::CountedRegion (NFC)
This name was too similar to CoverageMappingRegion, and the type
really belongs in the coverage library anyway.

llvm-svn: 217416
2014-09-09 05:32:14 +00:00
Justin Bogner
b977873733 llvm-cov: Use ErrorOr rather than an error_code* (NFC)
llvm-svn: 217404
2014-09-08 21:04:00 +00:00
Alex Lorenz
d123485f6e Coverage Mapping: add function's hash to coverage function records.
The profile data format was recently updated and the new indexing api
requires the code coverage tool to know the function's hash as well
as the function's name to get the execution counts for a function.

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

llvm-svn: 216207
2014-08-21 19:23:25 +00:00
Rafael Espindola
08aa78de63 Don't own the buffer in object::Binary.
Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries
(like Archive) and we had to create dummy buffers just to handle that. It is
also a bad fit for IRObjectFile where the Module wants to own the buffer too.

Keeping this ownership would make supporting IR inside native objects
particularly painful.

This patch focuses in lib/Object. If something elsewhere used to own an Binary,
now it also owns a MemoryBuffer.

This patch introduces a few new types.

* MemoryBufferRef. This is just a pair of StringRefs for the data and name.
  This is to MemoryBuffer as StringRef is to std::string.
* OwningBinary. A combination of Binary and a MemoryBuffer. This is needed
  for convenience functions that take a filename and return both the
  buffer and the Binary using that buffer.

The C api now uses OwningBinary to avoid any change in semantics. I will start
a new thread to see if we want to change it and how.

llvm-svn: 216002
2014-08-19 18:44:46 +00:00
Benjamin Kramer
da144ed5a2 Canonicalize header guards into a common format.
Add header guards to files that were missing guards. Remove #endif comments
as they don't seem common in LLVM (we can easily add them back if we decide
they're useful)

Changes made by clang-tidy with minor tweaks.

llvm-svn: 215558
2014-08-13 16:26:38 +00:00
Alex Lorenz
faf4f53aec Coverage: add HasCodeBefore flag to a mapping region.
This flag will be used by the coverage tool to help 
compute the execution counts for each line in a source file.

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

llvm-svn: 214740
2014-08-04 18:00:51 +00:00
Justin Bogner
48a07cae49 InstrProf: Allow multiple functions with the same name
This updates the instrumentation based profiling format so that when
we have multiple functions with the same name (but different function
hashes) we keep all of them instead of rejecting the later ones.

There are a number of scenarios where this can come up where it's more
useful to keep multiple function profiles:

* Name collisions in unrelated libraries that are profiled together.
* Multiple "main" functions from multiple tools built against a common
  library.
* Combining profiles from different build configurations (ie, asserts
  and no-asserts)

The profile format now stores the number of counters between the hash
and the counts themselves, so that multiple sets of counts can be
stored. Since this is backwards incompatible, I've bumped the format
version and added some trivial logic to skip this when reading the old
format.

llvm-svn: 214585
2014-08-01 22:50:07 +00:00
Justin Bogner
0e75ee1f72 ProfileData: Don't redundantly default initialize a member
We're default constructing RecordIterator anyway, so it needn't appear
in the mem-initializer-list.

llvm-svn: 214182
2014-07-29 15:56:06 +00:00
Alex Lorenz
2a0c5d7867 coverage: remove empty mapping regions
This patch removes the empty coverage mapping regions.
Those regions were produced by clang's old mapping region generation 
algorithm, but the new algorithm doesn't generate them.

llvm-svn: 213981
2014-07-25 22:22:24 +00:00
Alex Lorenz
9c8d526a9f Add code coverage mapping data, reader, and writer.
This patch implements the data structures, the reader and
the writers for the new code coverage mapping system. 
The new code coverage mapping system uses the instrumentation
based profiling to provide code coverage analysis.

llvm-svn: 213910
2014-07-24 23:57:54 +00:00
Justin Bogner
8f4d6f2007 ProfileData: Fix copy-paste type in RawInstrProfReader
These deleted definitions had the wrong types.

Patch by Alex L!

llvm-svn: 211199
2014-06-18 18:20:44 +00:00
Artyom Skrobov
9d70ea6c1e Renaming SwapByteOrder() to getSwappedBytes()
The next commit will add swapByteOrder(), acting in-place

llvm-svn: 210973
2014-06-14 11:36:01 +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
Rafael Espindola
38dc624425 Remove system_error.h.
This is a minimal change to remove the header. I will remove the occurrences
of "using std::error_code" in a followup patch.

llvm-svn: 210803
2014-06-12 17:38:55 +00:00
Rafael Espindola
b0ac81f225 Don't import error_category into the llvm namespace.
llvm-svn: 210733
2014-06-12 01:45:43 +00:00
Rafael Espindola
cb080681ac Use std::error_code instead of llvm::error_code.
The idea of this patch is to turn llvm/Support/system_error.h into a
transitional header that just brings in the erorr_code api to the llvm
namespace. I will remove it shortly afterwards.

The cases where the general idea needed some tweaking:

* std::errc is a namespace in msvc, so we cannot use "using std::errc". I could
add an #ifdef, but there were not that many uses, so I just added std:: to
them in this patch.

* Template specialization had to be moved to the std namespace in this
patch set already.

* The msvc implementation of default_error_condition doesn't seem to
provide the same transformations as we need. Not too surprising since
the standard doesn't actually say what "equivalent" means. I fixed the
problem by keeping our old mapping and using it at error_code
construction time.

Despite these shortcomings I think this is still a good thing. Some reasons:

* The different implementations of system_error might improve over time.
* It removes 925 lines of code from llvm already.
* It removes 6313 bytes from the text segment of the clang binary when
it is built with gcc and 2816 bytes when building with clang and
libstdc++.

llvm-svn: 210687
2014-06-11 19:05:50 +00:00
Rafael Espindola
a65e0b524d Use an enum class.
Might also fix the windows build.

llvm-svn: 210077
2014-06-03 05:12:33 +00:00
Justin Bogner
7e39763d14 ProfileData: Allow multiple profiles in RawInstrProfReader
Allow multiple raw profiles to coexist in a single .profraw file,
given the following conditions:

- Zero padding at the end of or between profiles will be skipped.
- Each profile must start with a valid header.
- Mixing endianness or pointer sizes in concatenated profiles files is
  not allowed.

This is needed to handle cases where a program's shared libraries are
profiled as well as the main executable itself, as we'll need to emit
each executable's counters. Combining the tables in the runtime would
be expensive for the instrumented program.

rdar://16918688

llvm-svn: 208938
2014-05-16 00:38:00 +00:00
Justin Bogner
40987a4daf OnDiskHashTable: Audit types and use offset_type consistently
llvm-svn: 206675
2014-04-19 00:33:15 +00:00
Justin Bogner
9db8945e3b ProfileData: Avoid UB when reading
llvm-svn: 206674
2014-04-19 00:33:12 +00:00
Justin Bogner
d9f7325c10 ProfileData: Don't forward declare ComputeHash and make it static inline
llvm-svn: 206663
2014-04-18 22:00:22 +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
Duncan P. N. Exon Smith
5b4570b273 InstrProf: Check pointer size in raw profile
Since the profile can come from 32-bit machines, we need to check the
pointer size.  Change the magic number to facilitate this.

Adds tests for reading 32-bit and 64-bit binaries (both big- and
little-endian).  The tests write a binary using printf in RUN lines
(like raw-magic-but-no-header.test).  Assuming the bots don't complain,
this seems like a better way forward for testing RawInstrProfReader than
committing binary files.

<rdar://problem/16400648>

llvm-svn: 204557
2014-03-23 03:38:12 +00:00
Duncan P. N. Exon Smith
2b05ab77e3 InstrProf: Move constructor to the header
Fixes 80-column violation at the same time.

<rdar://problem/15950346>

llvm-svn: 204516
2014-03-21 20:59:19 +00:00
Duncan P. N. Exon Smith
1afa51c6d0 InstrProf: Use move semantics with unique_ptr
<rdar://problem/15950346>

llvm-svn: 204512
2014-03-21 20:42:34 +00:00
Duncan P. N. Exon Smith
c8aaf38ed4 InstrProf: Detect magic numbers in a more scalable way
No functionality change.

<rdar://problem/15950346>

llvm-svn: 204511
2014-03-21 20:42:31 +00:00
Duncan P. N. Exon Smith
3920850b70 InstrProf: Actually detect bad headers
<rdar://problem/15950346>

llvm-svn: 204510
2014-03-21 20:42:28 +00:00
Justin Bogner
905c56e22d ProfileData: Avoid double underscores in header guards
llvm-svn: 204501
2014-03-21 18:46:29 +00:00
Duncan P. N. Exon Smith
3fc38faca0 InstrProf: Read raw binary profile in llvm-profdata
Read a raw binary profile that corresponds to a memory dump from the
runtime profile.

The test is a binary file generated from
cfe/trunk/test/Profile/c-general.c with the new compiler-rt runtime and
the matching text version of the input.  It includes instructions on how
to regenerate.

<rdar://problem/15950346>

llvm-svn: 204496
2014-03-21 18:26:05 +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
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