Commit Graph

329 Commits

Author SHA1 Message Date
Kevin Enderby
e9ddf3a4a7 Change llvm-objdump, llvm-nm and llvm-size when reporting an object file error
when the object is from a slice of a Mach-O Universal Binary use something like
"foo.o (for architecture i386)" as part of the error message when expected.

Also fixed places in these tools that were ignoring object file errors from
MachOUniversalBinary::getAsObjectFile() when the code moved on to see if
the slice was an archive.

To do this MachOUniversalBinary::getAsObjectFile() and
MachOUniversalBinary::getObjectForArch() were changed from returning
ErrorOr<...> to Expected<...> then that was threaded up to its users.

Converting these interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now the use of
errorToErrorCode() is still used in two places yet to be fully converted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271332 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 20:35:34 +00:00
Benjamin Kramer
2ff22b74ed [ProfileData] Clean up string handling a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271180 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-29 10:31:00 +00:00
Benjamin Kramer
c4a6700e58 [ProfData] Remove global constructor from ProfileSummaryBuilder.
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271021 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 17:38:16 +00:00
Peter Collingbourne
84e27c2068 Add FIXMEs to all derived classes of std::error_category.
This helps make clear that we're moving away from std::error_code.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 20:13:46 +00:00
Benjamin Kramer
e3bf66476f [ProfileData] Thread unique_ptr through the summary builder to avoid leaks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270195 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20 09:18:37 +00:00
Igor Kudrin
88a127497f [Coverage] Fix an issue where improper coverage mapping data could be loaded for an inline function.
If an inline function is observed but unused in a translation unit, dummy
coverage mapping data with zero hash is stored for this function.
If such a coverage mapping section came earlier than real one, the latter
was ignored. As a result, llvm-cov was unable to show coverage information
for those functions.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270194 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20 09:14:24 +00:00
Easwaran Raman
30c760d801 Remove specializations of ProfileSummary
This removes the subclasses of ProfileSummary, moves the members of the derived classes to the base class.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270143 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 21:53:28 +00:00
Easwaran Raman
17e7f1191f Move ProfileSummary to IR.
This splits ProfileSummary into two classes: a ProfileSummary class that has methods to convert from/to metadata and a ProfileSummaryBuilder class that computes the profiles summary which is in ProfileData.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270136 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 21:07:12 +00:00
Vedant Kumar
c77570e062 Retry^3 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"
Transition InstrProf and Coverage over to the stricter Error/Expected
interface.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270020 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 03:54:45 +00:00
Igor Kudrin
24466cded7 [Coverage] Ensure that coverage mapping data has an expected alignment in 'covmapping' files.
Coverage mapping data is organized in a sequence of blocks, each of which is expected
to be aligned by 8 bytes. This feature is used when reading those blocks, see
VersionedCovMapFuncRecordReader::readFunctionRecords(). If a misaligned covearge
mapping data has more than one block, it causes llvm-cov to fail.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269887 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 07:43:27 +00:00
Vedant Kumar
ce4aff93aa Revert "Retry^2 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC""
This reverts commit r269694. MSVC says:

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269700 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 21:03:38 +00:00
Vedant Kumar
515ee3e025 Retry^2 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"
Transition InstrProf and Coverage over to the stricter Error/Expected
interface.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269694 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 20:49:39 +00:00
Chandler Carruth
2e531af53a Revert "Retry "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC""
This reverts commit r269491. It triggers warnings with Clang, breaking
builds for -Werror users including several build bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269547 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-14 05:26:26 +00:00
Vedant Kumar
db1d476217 Retry "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"
Transition InstrProf and Coverage over to the stricter Error/Expected
interface.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269491 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-13 21:50:56 +00:00
Vedant Kumar
8007bdd41f Revert "(HEAD -> master, origin/master, origin/HEAD) [ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"
This reverts commit r269462. It fails two llvm-profdata tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269466 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-13 20:09:39 +00:00
Vedant Kumar
5b34ed8191 [ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC
Transition InstrProf and Coverage over to the stricter Error/Expected
interface.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269462 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-13 20:01:27 +00:00
Vedant Kumar
6d6b3df09a [ProfileData] Use SoftInstrProfErrors to count soft errors, NFC
Differential Revision: http://reviews.llvm.org/D20082

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269222 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-11 19:42:19 +00:00
Vedant Kumar
412cddb08e Use an emplace_back for consistency, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269199 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-11 16:03:02 +00:00
Easwaran Raman
d56f6d6de3 Revert r269131
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269138 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-10 23:26:04 +00:00
Easwaran Raman
79f2742cf7 Reapply r266477 and r266488
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269131 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-10 22:03:23 +00:00
Rong Xu
3a963d121a [PGO] Use rsplit to parse value-data line in text profile file.
The value-data line is <PGOFuncName>:<Count_Value>. PGOFuncName might contain
':' for the internal linkage functions. We therefore need to use rsplit,
rather split, to extract the data from the line. This fixes the error when
merging a text profile file to an indexed profile file.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268818 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-06 23:20:58 +00:00
Sean Silva
d4c22d2f8d Add a note about the "entry count" used the profile summary
Thanks to David Li for the clarification.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268669 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-05 19:54:13 +00:00
Xinliang David Li
8fa402e863 [profile] Remove unneeded field in raw profile reader
Differential Revision: http://reviews.llvm.org/D19956


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268667 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-05 19:41:18 +00:00
Igor Kudrin
68065ba043 [Coverage] Combine counts of expansion regions if there are no code regions for the same area.
Differential Revision: http://reviews.llvm.org/D18831


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268620 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-05 09:39:45 +00:00
Vedant Kumar
f8e08351d3 [ProfileData] Propagate an error from InstrProfSymtab
CovMapFuncReader::get should propagate up errors from InstrProfSymtab.

This is part of a series of patches to transition ProfileData over to
the stricter Error/Expected interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268428 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03 20:01:01 +00:00
Vedant Kumar
707e782733 [ProfileData] Add error codes for compression failures
Be more specific in describing compression failures. Also, check for
this kind of error in emitNameData().

This is part of a series of patches to transition ProfileData over to
the stricter Error/Expected interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268400 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03 16:53:17 +00:00
Vedant Kumar
0cd16495ba Remove redundant return, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268312 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-02 21:33:36 +00:00
Easwaran Raman
a96d5370cb Move coverage related code into a separate library.
Differential Revision: http://reviews.llvm.org/D19333



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268089 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-29 18:53:05 +00:00
Igor Kudrin
3c7ad33b0b [Coverage] Restore the correct count value after processing a nested region in case of combined regions.
If several regions cover the same area of code, we have to restore
the combined value for that area when return from a nested region.

This patch achieves that by combining regions before calling buildSegments.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267390 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25 09:43:37 +00:00
Rong Xu
efee6b3938 [PGO] change the interface for createPGOFuncNameMetadata()
This patch changes the interface for createPGOFuncNameMetadata() where we add
another PGOFuncName argument.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267216 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22 21:00:17 +00:00
Vedant Kumar
089f755c04 [ProfileData] Report errors from InstrProfSymtab::create
InstrProfSymtab::create can fail with instrprof_error::malformed, but
this error is silently dropped. Propagate the error up to the caller so
we fail early.

Eventually, I'd like to transition ProfileData over to the new Error
class so we can't ignore hard failures like this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267055 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21 21:07:25 +00:00
Igor Kudrin
66a92f3b19 Reapply "[Coverage] Prevent detection of false instantiations in case of macro expansion."
The root of the problem was that findMainViewFileID(File, Function)
could return some ID for any given file, even though that file
was not the main file for that function.

This patch ensures that the result of this function is conformed
with the result of findMainViewFileID(Function).

This commit reapplies r266436, which was reverted by r266458,
with the .covmapping file serialized in v1 format.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266620 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 15:36:30 +00:00
Eric Liu
dcefe3154e Revert "Replace the use of MaxFunctionCount module flag"
This reverts commit r266477.

This commit introduces cyclic dependency. This commit has "Analysis" depend on "ProfileData",
while "ProfileData" depends on "Object", which depends on "BitCode", which
depends on "Analysis".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266619 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 15:31:11 +00:00
Mehdi Amini
f6071e14c5 [NFC] Header cleanup
Removed some unused headers, replaced some headers with forward class declarations.

Found using simple scripts like this one:
clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap'

Patch by Eugene Kosov <claprix@yandex.ru>

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266595 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 09:17:29 +00:00
Easwaran Raman
b87a1e69c3 Replace the use of MaxFunctionCount module flag
Adds an interface to get ProfileSummary for a module and makes InlineCost use ProfileSummary to get max function count.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266477 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 21:39:58 +00:00
Igor Kudrin
665e18d2ac Revert "[Coverage] Prevent detection of false instantiations in case of macro expansion."
This reverts commit r266436 as it broke buildbot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266458 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 17:53:48 +00:00
Igor Kudrin
cfdf5c2193 [Coverage] Prevent detection of false instantiations in case of macro expansion.
The root of the problem was that findMainViewFileID(File, Function)
could return some ID for any given file, even though that file
was not the main file for that function.

This patch ensures that the result of this function is conformed
with the result of findMainViewFileID(Function).

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266436 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 14:56:50 +00:00
Betul Buyukkurt
d14f0dbc9b [PGO] Do not attach VP metadata if value count at site is 0 [NFC]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266335 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 16:25:45 +00:00
Igor Kudrin
78732b7659 [Coverage] Avoid unnecessary copying of std::vector
Approved by: Justin Bogner <mail@justinbogner.com>

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266284 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 09:10:00 +00:00
Xinliang David Li
6a7ae27ea4 Add code comment/NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265966 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 17:13:08 +00:00
Xinliang David Li
6aa584fdaf [PGO] Fix deserialize bug
Raw function pointer collected by value
profile data may be from external functions
that are not instrumented. They won't have
mapping data to be used by the deserializer.
Force the value to be 0 in this case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265890 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-10 03:32:02 +00:00
Kevin Enderby
c6bf9be16d Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message
Produce the first specific error message for a malformed Mach-O file describing
the problem instead of the generic message for object_error::parse_failed of
"Invalid data was encountered while parsing the file”.  Many more good error
messages will follow after this first one.

This is built on Lang Hames’ great work of adding the ’Error' class for
structured error handling and threading Error through MachOObjectFile
construction.  And making createMachOObjectFile return Expected<...> .

So to to get the error to the llvm-obdump tool, I changed the stack of
these methods to also return Expected<...> :

  object::ObjectFile::createObjectFile()
  object::SymbolicFile::createSymbolicFile()
  object::createBinary()

Then finally in ParseInputMachO() in MachODump.cpp the error can
be reported and the specific error message can be printed in llvm-objdump
and can be seen in the existing test case for the existing malformed binary
but with the updated error message.

Converting these interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now use of
errorToErrorCode() and errorOrToExpected() are used where the callers
are yet to be converted.

Also there some were bugs in the existing code that did not deal with the
old ErrorOr<> return values.  So now with Expected<> since they must be
checked and the error handled, I added a TODO and a comment:
“// TODO: Actually report errors helpfully” and a call something like
consumeError(ObjOrErr.takeError()) so the buggy code will not crash
since needed to deal with the Error.

Note there is one fix also needed to lld/COFF/InputFiles.cpp that goes along
with this that I will commit right after this.  So expect lld not to built
after this commit and before the next one.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265606 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 22:14:09 +00:00
Rong Xu
ba623ac1b5 Fix buildbot lldb-amd64-ninja-netbsd7 failure
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265180 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 20:15:04 +00:00
Rong Xu
a7f5174cd1 [PGO] Refactor PGOFuncName meta data code to be used in clang
Refactor the code that gets and creates PGOFuncName meta data so that it can be
used in clang's value profile annotation.

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





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265149 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 16:43:30 +00:00
Rong Xu
051ce12b53 [PGO] use emplace_back. NFC.
Use emplace_back instead of push_back for simplicity.





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265030 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 17:39:33 +00:00
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