summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Writer
Commit message (Collapse)AuthorAgeFilesLines
...
* Bitcode: Try to emit metadata in function blocksDuncan P. N. Exon Smith2016-04-023-39/+231
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Whenever metadata is only referenced by a single function, emit the metadata just in that function block. This should improve lazy-loading by reducing the amount of metadata in the global block. For now, this should catch all DILocations, and anything else that happens to be referenced only by a single function. It's also a first step toward a couple of possible future directions (which this commit does *not* implement): 1. Some debug info metadata is only referenced from compile units and individual functions. If we can drop the link from the compile unit, this optimization will get more powerful. 2. Any uniqued metadata that isn't referenced globally can in theory be emitted in every function block that references it (trading off bitcode size and full-parse time vs. lazy-load time). Note: this assumes the new BitcodeReader error checking from r265223. The metadata stored in function blocks gets purged after parsing each function, which means unresolved forward references will get lost. Since all the global metadata should have already been resolved by the time we get to the function metadata blocks we just need to check for that case. (If for some reason we need to handle bitcode that fails the checks in r265223, the fix is to store about-to-be-dropped unresolved nodes in MetadataList::shrinkTo until they can be handled succesfully by a future call to MetadataList::tryToResolveCycles.) llvm-svn: 265226
* Fix doxygen comments from r265224, NFCDuncan P. N. Exon Smith2016-04-021-2/+2
| | | | llvm-svn: 265225
* BitcodeWriter: Further unify function metadata, NFCDuncan P. N. Exon Smith2016-04-023-12/+17
| | | | | | | | | | | | | Further unify the handling of function-local metadata with global metadata, by exposing the same interface in ValueEnumerator. Both contexts use the same accessors: - getMDStrings(): get the strings for this block. - getNonMDStrings(): get the non-strings for this block. A future commit will start adding strings to the function-block. llvm-svn: 265224
* Reverts r265219.Mehdi Amini2016-04-021-15/+15
| | | | | | | Unintentionally commited... time to call the day off! From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265221
* wipMehdi Amini2016-04-021-15/+15
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265219
* Create a typedef GlobalValue::GUID for uint64_t and RAUW (NFC)Mehdi Amini2016-04-021-8/+8
| | | | | | | | | | | | | Summary: This should make the code more readable, especially all the map declarations. Reviewers: tejohnson Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18721 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265215
* Swift Calling Convention: add swifterror attribute.Manman Ren2016-04-011-2/+3
| | | | | | | | | | | | A ``swifterror`` attribute can be applied to a function parameter or an AllocaInst. This commit does not include any target-specific change. The target-specific optimization will come as a follow-up patch. Differential Revision: http://reviews.llvm.org/D18092 llvm-svn: 265189
* Add a module Hash in the bitcode and the combined index, implementing a kind ↵Mehdi Amini2016-04-011-9/+65
| | | | | | | | | | | | | of "build-id" This is intended to be used for ThinLTO incremental build. Differential Revision: http://reviews.llvm.org/D18213 This is a recommit of r265095 after fixing the Windows issues. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265111
* Revert "Add support for computing SHA1 in LLVM"Mehdi Amini2016-04-011-65/+9
| | | | | | | | This reverts commit r265096, r265095, and r265094. Windows build is broken, and the validation does not pass. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265102
* Add a module Hash in the bitcode and the combined index, implementing a kind ↵Mehdi Amini2016-04-011-9/+65
| | | | | | | | | | | of "build-id" This is intended to be used for ThinLTO incremental build. Differential Revision: http://reviews.llvm.org/D18213 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265095
* Swift Calling Convention: add swiftself attribute.Manman Ren2016-03-291-0/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D17866 llvm-svn: 264754
* BitcodeWriter: Replace dead code with an assertion, NFCDuncan P. N. Exon Smith2016-03-281-7/+1
| | | | | | | The caller of ValueEnumerator::EnumerateOperandType never sends in metadata. Assert that, and remove the unnecessary logic. llvm-svn: 264558
* BitcodeWriter: Reuse writeMetadataRecords, NFCDuncan P. N. Exon Smith2016-03-271-5/+2
| | | | | | | | Change writeFunctionMetadata to call writeMetadataRecords. For now there's no functionality change, but makes it easy to serialize other types of metadata in the function block in the future. llvm-svn: 264557
* BitcodeWriter: Rename some functions for consistency, NFCDuncan P. N. Exon Smith2016-03-271-35/+34
| | | | | | | | | | | | | | | | To match writeMetadataRecords, writeNamedMetadata and writeMetadataStrings, change: WriteModuleMetadata => writeModuleMetadata WriteFunctionLocalMetadata => writeFunctionMetadata Write##CLASS => write##CLASS The only major change is "FunctionLocal" => "Function". The point is to be less specific, in preparation for emitting normal metadata records inside function metadata blocks (currently we only emit `LocalAsMetadata` there). llvm-svn: 264556
* BitcodeWriter: Split out writeMetadataRecords, NFCDuncan P. N. Exon Smith2016-03-271-9/+17
| | | | | | | Besides being a nice cleanup, this is preparation for reusing the code in function metadata blocks. llvm-svn: 264555
* BitcodeWriter: Restructure WriteFunctionLocalMetadata, NFCDuncan P. N. Exon Smith2016-03-271-11/+9
| | | | | | Use an early return to simplify logic. llvm-svn: 264554
* BitcodeWriter: Simplify tracking of function-local metadata, NFCDuncan P. N. Exon Smith2016-03-273-12/+5
| | | | | | | | We don't really need a separate vector here; instead, point at a range inside the main MDs array. This matches how r264551 references the ranges of strings and non-strings. llvm-svn: 264552
* Reapply ~"Bitcode: Collect all MDString records into a single blob"Duncan P. N. Exon Smith2016-03-273-31/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Spiritually reapply commit r264409 (reverted in r264410), albeit with a bit of a redesign. Firstly, avoid splitting the big blob into multiple chunks of strings. r264409 imposed an arbitrary limit to avoid a massive allocation on the shared 'Record' SmallVector. The bug with that commit only reproduced when there were more than "chunk-size" strings. A test for this would have been useless long-term, since we're liable to adjust the chunk-size in the future. Thus, eliminate the motivation for chunk-ing by storing the string sizes in the blob. Here's the layout: vbr6: # of strings vbr6: offset-to-blob blob: [vbr6]: string lengths [char]: concatenated strings Secondly, make the output of llvm-bcanalyzer readable. I noticed when debugging r264409 that llvm-bcanalyzer was outputting a massive blob all in one line. Past a small number, the strings were impossible to split in my head, and the lines were way too long. This version adds support in llvm-bcanalyzer for pretty-printing. <STRINGS abbrevid=4 op0=3 op1=9/> num-strings = 3 { 'abc' 'def' 'ghi' } From the original commit: Inspired by Mehdi's similar patch, http://reviews.llvm.org/D18342, this should (a) slightly reduce bitcode size, since there is less record overhead, and (b) greatly improve reading speed, since blobs are super cheap to deserialize. llvm-svn: 264551
* Rename ModuleSummaryIndex::modPathStringEntries() into modulePaths()Mehdi Amini2016-03-261-1/+1
| | | | | | | It now return the map instead of an iterator. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264489
* [ThinLTO] Rename edges() to calls() for clarity (NFC)Teresa Johnson2016-03-251-3/+3
| | | | | | Helps distinguish from refs() which iterates over non-call references. llvm-svn: 264445
* Revert "Bitcode: Collect all MDString records into a single blob"Duncan P. N. Exon Smith2016-03-253-92/+31
| | | | | | | This reverts commit r264409 since it failed to bootstrap: http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_build/8302/ llvm-svn: 264410
* Bitcode: Collect all MDString records into a single blobDuncan P. N. Exon Smith2016-03-253-31/+92
| | | | | | | | | | | | | | | | | | | | | | | Optimize output of MDStrings in bitcode. This emits them in big blocks (currently 1024) in a pair of records: - BULK_STRING_SIZES: the sizes of the strings in the block, and - BULK_STRING_DATA: a single blob, which is the concatenation of all the strings. Inspired by Mehdi's similar patch, http://reviews.llvm.org/D18342, this should (a) slightly reduce bitcode size, since there is less record overhead, and (b) greatly improve reading speed, since blobs are super cheap to deserialize. I needed to add support for blobs to streaming input to get the test suite passing. - StreamingMemoryObject::getPointer reads ahead and returns the address of the blob. - To avoid a possible reallocation of StreamingMemoryObject::Bytes, BitstreamCursor::readRecord needs to move the call to JumpToEnd forward so that getPointer is the last bitstream operation. llvm-svn: 264409
* Bitcode: Use std::stable_partition for reproducible buildsDuncan P. N. Exon Smith2016-03-251-2/+2
| | | | | | | Caught by inspection while working on partitioning metadata. It's nice to produce the same bitcode if you run the compiler twice. llvm-svn: 264381
* Bitcode: Stop using MODULE_CODE_METADATA_VALUESDuncan P. N. Exon Smith2016-03-251-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | The motivation for MODULE_CODE_METADATA_VALUES was to enable an -flto=thin scheme where: 1. First, one function is cherry-picked from a bitcode file. 2. Later, another function is cherry-picked. 3. Later, ... 4. Finally, the metadata needed by all the previous functions is loaded. This was abandoned in favour of: 1. Calculate the superset of functions needed from a Module. 2. Link all functions at once. Delayed metadata reading no longer serves a purpose. It also adds a few complication, since we can't count on metadata being properly parsed when exiting the BitcodeReader. After discussing with Teresa, we agreed to remove it. The code that depended on this was removed/updated in r264326. llvm-svn: 264378
* BitcodeWriter: Move abbreviation for GenericDINode; almost NFCDuncan P. N. Exon Smith2016-03-243-21/+19
| | | | | | | | | | | | Simplify ValueEnumerator and WriteModuleMetadata by shifting the logic for the METADATA_GENERIC_DEBUG abbreviation into WriteGenericDINode. (This is just like r264302, but for GenericDINode.) The only change is that the abbreviation is emitted later in the bitcode, just before the first `GenericDINode` record. This shouldn't be observable though. llvm-svn: 264303
* BitcodeWriter: Move abbreviation for DILocation; almost NFCDuncan P. N. Exon Smith2016-03-243-20/+18
| | | | | | | | | | | Simplify ValueEnumerator and WriteModuleMetadata by shifting the logic for the METADATA_LOCATION abbreviation into WriteDILocation. The only change is that the abbreviation is emitted later in the bitcode, just before the first `DILocation` record. This shouldn't be observable though. llvm-svn: 264302
* BitcodeWriter: Split out named metadata; almost NFCDuncan P. N. Exon Smith2016-03-241-25/+31
| | | | | | | | | | | | Split writeNamedMetadata out of WriteModuleMetadata to write named metadata, and createNamedMetadataAbbrev for the abbreviation. There should be no effective functionality change, although the layout of the bitcode will change. Previously, the abbreviation was emitted at the top of the block, but now it is delayed until immediately before the named metadata records are emitted. llvm-svn: 264301
* Bitcode: Module* -> Module&, NFCDuncan P. N. Exon Smith2016-03-241-5/+5
| | | | llvm-svn: 264299
* Add getBlockProfileCount method to BlockFrequencyInfoEaswaran Raman2016-03-231-7/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D18233 llvm-svn: 264179
* [ThinLTO] Record all global variable defs in the summaryTeresa Johnson2016-03-151-11/+10
| | | | | | | Record all variable defs with a summary record to aid in building a complete reference graph and locating constant variable defs to import. llvm-svn: 263576
* BitcodeWriter dyn_cast cleanup for r263275 (NFC)Teresa Johnson2016-03-151-8/+5
| | | | | | | Address review suggestions from dblaikie: change a few dyn_cast to cast and fold a cast into if condition. llvm-svn: 263526
* [ThinLTO] Renaming of function index to module summary index (NFC)Teresa Johnson2016-03-152-16/+13
| | | | | | | | | | | | | | | (Resubmitting after fixing missing file issue) With the changes in r263275, there are now more than just functions in the summary. Completed the renaming of data structures (started in r263275) to reflect the wider scope. In particular, changed the FunctionIndex* data structures to ModuleIndex*, and renamed related variables and comments. Also renamed the files to reflect the changes. A companion clang patch will immediately succeed this patch to reflect this renaming. llvm-svn: 263513
* Revert "[ThinLTO] Renaming of function index to module summary index (NFC)"Teresa Johnson2016-03-142-13/+16
| | | | | | This reverts commit r263490. Missed a file. llvm-svn: 263493
* [ThinLTO] Renaming of function index to module summary index (NFC)Teresa Johnson2016-03-142-16/+13
| | | | | | | | | | | | | With the changes in r263275, there are now more than just functions in the summary. Completed the renaming of data structures (started in r263275) to reflect the wider scope. In particular, changed the FunctionIndex* data structures to ModuleIndex*, and renamed related variables and comments. Also renamed the files to reflect the changes. A companion clang patch will immediately succeed this patch to reflect this renaming. llvm-svn: 263490
* [Bitcode] Make writeComdats less strangeDavid Majnemer2016-03-131-2/+2
| | | | | | | | It had a weird artificial limitation on the write side: the comdat name couldn't be bigger than 2**16. However, the reader had no such limitation. Make the reader and the writer agree. llvm-svn: 263377
* [ThinLTO] Support for reference graph in per-module and combined summary.Teresa Johnson2016-03-112-92/+375
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds support for including a full reference graph including call graph edges and other GV references in the summary. The reference graph edges can be used to make importing decisions without materializing any source modules, can be used in the plugin to make file staging decisions for distributed build systems, and is expected to have other uses. The call graph edges are recorded in each function summary in the bitcode via a list of <CalleeValueIds, StaticCount> tuples when no PGO data exists, or <CalleeValueId, StaticCount, ProfileCount> pairs when there is PGO, where the ValueId can be mapped to the function GUID via the ValueSymbolTable. In the function index in memory, the call graph edges reference the target via the CalleeGUID instead of the CalleeValueId. The reference graph edges are recorded in each summary record with a list of referenced value IDs, which can be mapped to value GUID via the ValueSymbolTable. Addtionally, a new summary record type is added to record references from global variable initializers. A number of bitcode records and data structures have been renamed to reflect the newly expanded scope of the summary beyond functions. More cleanup will follow. Reviewers: joker.eph, davidxl Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D17212 llvm-svn: 263275
* Bitcode writer: fix a typo, using getName() instead of getSourceFileName()Mehdi Amini2016-02-161-2/+2
| | | | | | | | When emitting the source filename, the encoding of the string was checked against the name instead of the filename. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 261019
* Restore "[ThinLTO] Use MD5 hash in function index." with fixTeresa Johnson2016-02-101-62/+62
| | | | | | | | | | | This restores commit r260408, along with a fix for a bot failure. The bot failure was caused by dereferencing a unique_ptr in the same call instruction parameter list where it was passed via std::move. Apparently due to luck this was not exposed when I built the compiler with clang, only with gcc. llvm-svn: 260442
* Revert "[ThinLTO] Use MD5 hash in function index." due to bot failureTeresa Johnson2016-02-101-62/+62
| | | | | | This reverts commit r260408. Bot failure that I need to investigate. llvm-svn: 260412
* [ThinLTO] Use MD5 hash in function index.Teresa Johnson2016-02-101-62/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch uses the lower 64-bits of the MD5 hash of a function name as a GUID in the function index, instead of storing function names. Any local functions are first given a global name by prepending the original source file name. This is the same naming scheme and GUID used by PGO in the indexed profile format. This change has a couple of benefits. The primary benefit is size reduction in the combined index file, for example 483.xalancbmk's combined index file was reduced by around 70%. It should also result in memory savings for the index file in memory, as the in-memory map is also indexed by the hash instead of the string. Second, this enables integration with indirect call promotion, since the indirect call profile targets are recorded using the same global naming convention and hash. This will enable the function importer to easily locate function summaries for indirect call profile targets to enable their import and subsequent promotion. The original source file name is recorded in the bitcode in a new module-level record for use in the ThinLTO backend pipeline. Reviewers: davidxl, joker.eph Subscribers: llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D17028 llvm-svn: 260408
* Fix VST_CODE_* bitcode id comments (NFC)Teresa Johnson2016-02-101-14/+14
| | | | llvm-svn: 260382
* [ThinLTO] Include linkage type in function summaryTeresa Johnson2016-02-061-5/+11
| | | | | | | | | | | | | | | | Summary: Adds the linkage type to both the per-module and combined function summaries, which subsumes the current islocal bit. This will eventually be used to optimized linkage types based on global summary-based analysis. Reviewers: joker.eph Subscribers: joker.eph, davidxl, llvm-commits Differential Revision: http://reviews.llvm.org/D16943 llvm-svn: 259993
* [ThinLTO] Ensure function summary output order is stableTeresa Johnson2016-02-011-5/+11
| | | | | | | | | Iterate over the function list instead of a DenseMap of Function pointers when emitting the function summary into the module. This fixes PR26419. llvm-svn: 259398
* Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren2016-01-291-1/+1
| | | | | | | | r259192 post commit comment. clang part in r259232, this is the LLVM part of the patch. llvm-svn: 259240
* [llvm-bcanalyzer] Dump bitcode wrapper headerAkira Hatanaka2016-01-291-8/+4
| | | | | | | | | | This patch enables llvm-bcanalyzer to print the bitcode wrapper header if the file has one, which is needed to test the changes made in r258627 (bitcode-wrapper-header-armv7m.ll is the test case for r258627). Differential Revision: http://reviews.llvm.org/D16642 llvm-svn: 259162
* One more batch of self-containing headers.Benjamin Kramer2016-01-271-0/+1
| | | | llvm-svn: 258974
* Make more headers self-contained.Benjamin Kramer2016-01-271-0/+1
| | | | | | A lot of this comes from the new complete type requirement of DenseMap. llvm-svn: 258956
* Remove autoconf supportChris Bieneman2016-01-261-15/+0
| | | | | | | | | | | | | | | | 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 llvm-svn: 258861
* [Bitcode] Insert the darwin wrapper at the beginning of a file when theAkira Hatanaka2016-01-231-2/+2
| | | | | | | | | | | target is macho. It looks like the check for macho was accidentally dropped in r132959. I don't have a test case, but I'll add one if anyone knows how this can be tested. llvm-svn: 258627
* NFC Test Commit whitespace change in a commentChris Ray2016-01-191-1/+1
| | | | | | Changed whitespace so comments line up. llvm-svn: 258151
OpenPOWER on IntegriCloud