summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData/CoverageMappingReader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move coverage related code into a separate library.Easwaran Raman2016-04-291-619/+0
| | | | | | Differential Revision: http://reviews.llvm.org/D19333 llvm-svn: 268089
* Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump ↵Kevin Enderby2016-04-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 265606
* [PGO] Enable compression in pgo instrumentationXinliang David Li2016-02-081-0/+5
| | | | | | | | | | | | 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 llvm-svn: 260117
* Move classes defined in a cpp file into an anonymous namespace.Benjamin Kramer2016-02-051-0/+2
| | | | | | No functionality change intended. llvm-svn: 259883
* Fix a coverage reading bug Xinliang David Li2016-01-191-1/+3
| | | | | | | | | function record pointer is not advanced when duplicate entry is found. Test case to be added. llvm-svn: 258188
* [Coverage] move a local var to be BinaryCoverageReader's memberXinliang David Li2016-01-181-8/+11
| | | | | | | | The symtab is logically referenced beyond the call to the create method. This changes makes sure its lifetime matches that of the reader. llvm-svn: 258036
* Rename local variable to avoid conflictXinliang David Li2016-01-141-5/+5
| | | | llvm-svn: 257748
* Cleanup: shorten prefix to consistent with other decls /NFCXinliang David Li2016-01-141-10/+8
| | | | llvm-svn: 257744
* Add virtual dtorXinliang David Li2016-01-141-0/+2
| | | | llvm-svn: 257734
* [Coverage] introduce class hierarchy (funcRecordReader) to support multiple ↵Xinliang David Li2016-01-131-22/+82
| | | | | | | | | | | | | 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 llvm-svn: 257708
* Revert r257699 -- windows buildbot failure TBIXinliang David Li2016-01-131-85/+22
| | | | llvm-svn: 257703
* [Coverage] introduce class hierarchy (funcRecordReader) to support multiple ↵Xinliang David Li2016-01-131-22/+85
| | | | | | | | | | | | 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 llvm-svn: 257699
* [Coverage] Refactor coverage mapping reader code Xinliang David Li2016-01-131-17/+13
| | | | | | | | | | | | | | (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). llvm-svn: 257571
* Rollback r257551 -- unexpected test failures TBIXinliang David Li2016-01-131-13/+17
| | | | llvm-svn: 257564
* [Coverage] Refactor coverage mapping reader code /NFCXinliang David Li2016-01-131-17/+13
| | | | | | | | | | | | | (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). llvm-svn: 257551
* Rollback r257547 -- buildbot failure TBIXinliang David Li2016-01-131-13/+17
| | | | llvm-svn: 257549
* [Coverage] Refactor coverage mapping reader code /NFCXinliang David Li2016-01-131-17/+13
| | | | | | | | | | | 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). llvm-svn: 257547
* [PGO] Minor refactoring /NFCXinliang David Li2016-01-071-5/+1
| | | | | | Move common defs into common header files. llvm-svn: 257108
* [PGO] Code refactoring to use header struct def /NFCXinliang David Li2016-01-031-5/+10
| | | | llvm-svn: 256712
* [ProfileData] Make helper function static.Benjamin Kramer2015-12-241-1/+1
| | | | | | No functional change. llvm-svn: 256375
* [PGO] InstrPGO and coverage code refactoring (NFC)Xinliang David Li2015-12-171-46/+33
| | | | | | | | | | 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. llvm-svn: 255862
* [PGO] Use template file to define runtime structuresXinliang David Li2015-11-051-6/+9
| | | | | | | | | | | 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 llvm-svn: 252113
* Add helper functions and remove hard coded references to instProf related ↵Xinliang David Li2015-10-221-2/+3
| | | | | | | | | | | | 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 llvm-svn: 251058
* Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko2015-06-231-1/+1
| | | | | | Apparently, the style needs to be agreed upon first. llvm-svn: 240390
* [Object] Search for architecures by name in ↵Frederic Riss2015-06-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-191-1/+1
| | | | | | | | | | | | | The patch is generated using this command: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ llvm/lib/ Thanks to Eugene Kosov for the original patch! llvm-svn: 240137
* InstrProf: Fix reading of consecutive 32 bit coverage mapsJustin Bogner2015-06-051-0/+5
| | | | | | | | | | | | | | | | | When we generate coverage data, we explicitly set each coverage map's alignment to 8 (See InstrProfiling::lowerCoverageData), but when we read the coverage data, we assume consecutive maps are exactly adjacent. When we're dealing with 32 bit, maps can end on a 4 byte boundary, causing us to think the padding is part of the next record. Fix this by adjusting the buffer to an appropriately aligned address between records. This is pretty awkward to test, as it requires a binary with multiple coverage maps to hit, so we'd need to check in multiple source files and a binary blob as inputs. llvm-svn: 239129
* InstrProf: Simplify looking up sections for coverage dataJustin Bogner2015-05-071-18/+19
| | | | llvm-svn: 236685
* InstrProf: Give coverage its own errors instead of piggy backing on instrprofJustin Bogner2015-05-061-29/+29
| | | | | | | | | | | | 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
* InstrProf: Remove a function that just returns its argument (NFC)Justin Bogner2015-05-061-20/+20
| | | | llvm-svn: 236664
* Re-sort includes with sort-includes.py and insert raw_ostream.h where it's used.Benjamin Kramer2015-03-231-0/+1
| | | | llvm-svn: 232998
* InstrProf: Fix CoverageMappingReader on big endianJustin Bogner2015-03-161-16/+28
| | | | | | | | This makes the reader check the endianness of the object file its given and behave appropriately. For the test I dug up a really old linker and created a ppc-apple-darwin file for llvm-cov to read. llvm-svn: 232422
* InstrProf: Do a better job of reading coverage mapping data.Justin Bogner2015-03-161-59/+41
| | | | | | | | | | | | | | | | | | | | | | This code was casting regions of a memory buffer to a couple of different structs. This is wrong in a few ways: 1. It breaks aliasing rules. 2. If the buffer isn't aligned, it hits undefined behaviour. 3. It completely ignores endianness differences. 4. The structs being defined for this aren't specifying their padding properly, so this doesn't even represent the data properly on some platforms. This commit is mostly NFC, except that it fixes reading coverage for 32 bit binaries as a side effect of getting rid of the mispadded structs. I've included a test for that. I've also baked in that we only handle little endian more explicitly, since that was true in practice already. I'll fix this to handle endianness properly in a followup commit. llvm-svn: 232346
* InstrProf: Teach llvm-cov to handle universal binaries when given -archJustin Bogner2015-03-111-6/+28
| | | | llvm-svn: 231902
* InstrProf: Simplify the construction of BinaryCoverageReaderJustin Bogner2015-02-261-60/+55
| | | | | | | | | | | | | 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
* InstrProf: Rename ObjectFileCoverageMappingReader to BinaryCoverageReaderJustin Bogner2015-02-261-5/+5
| | | | | | | The current name is long and confusing. A shorter one is both easier to understand and easier to work with. llvm-svn: 230675
* InstrProf: Remove dead code in CoverageMappingReaderJustin Bogner2015-02-251-13/+3
| | | | | | | Remove a default argument that's never passed and a constructor that's never called. llvm-svn: 230563
* InstrProf: Make CounterMappingRegions less confusing to constructJustin Bogner2015-02-031-4/+3
| | | | | | | Creating empty and expansion regions is awkward with the current API. Expose static methods to make this simpler. llvm-svn: 228075
* InstrProf: Remove CoverageMapping::HasCodeBefore, it isn't usedJustin Bogner2015-02-031-8/+5
| | | | | | | It's not entirely clear to me what this field was meant for, but it's always false. Remove it. llvm-svn: 228034
* InstrProf: Simplify RawCoverageMappingReader's API slightlyJustin Bogner2015-02-031-7/+9
| | | | | | | | 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
* InstrProf: Simplify some logic by using ArrayRef::slice (NFC)Justin Bogner2015-02-031-1/+1
| | | | llvm-svn: 227898
* [Object] Modify OwningBinary's interface to separate inspection from ownership.Lang Hames2014-10-311-1/+1
| | | | | | | | The getBinary and getBuffer method now return ordinary pointers of appropriate const-ness. Ownership is transferred by calling takeBinary(), which returns a pair of the Binary and a MemoryBuffer. llvm-svn: 221003
* Reduce double set lookups. NFC.Benjamin Kramer2014-10-101-2/+2
| | | | llvm-svn: 219505
* Remove bogus std::error_code returns form SectionRef.Rafael Espindola2014-10-081-1/+2
| | | | | | | | | | | | | | There are two methods in SectionRef that can fail: * getName: The index into the string table can be invalid. * getContents: The section might point to invalid contents. Every other method will always succeed and returning and std::error_code just complicates the code. For example, a section can have an invalid alignment, but if we are able to get to the section structure at all and create a SectionRef, we will always be able to read that invalid alignment. llvm-svn: 219314
* llvm-cov: Move some reader debug output out of the tool.Justin Bogner2014-09-201-0/+15
| | | | | | | This debug output is really for testing CoverageMappingReader, not the llvm-cov tool. Move it to where it can be more useful. llvm-svn: 218183
* llvm-cov: add code coverage tool that's based on coverage mapping format and ↵Alex Lorenz2014-08-221-26/+71
| | | | | | | | | | | | | clang's pgo. This commit expands llvm-cov's functionality by adding support for a new code coverage tool that uses LLVM's coverage mapping format and clang's instrumentation based profiling. The gcov compatible tool can be invoked by supplying the 'gcov' command as the first argument, or by modifying the tool's name to end with 'gcov'. Differential Revision: http://reviews.llvm.org/D4445 llvm-svn: 216300
* Coverage Mapping: add function's hash to coverage function records.Alex Lorenz2014-08-211-2/+4
| | | | | | | | | | 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
* Don't own the buffer in object::Binary.Rafael Espindola2014-08-191-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Coverage: add HasCodeBefore flag to a mapping region.Alex Lorenz2014-08-041-6/+10
| | | | | | | | | 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
* Use std::unique_ptr to make the ownership explicit.Rafael Espindola2014-07-311-2/+2
| | | | llvm-svn: 214377
OpenPOWER on IntegriCloud